VMWare released “Photon” earlier this week, which is a lightweight Linux OS for hosting Docker containers. It’s amazingly slim like CoreOS and deploys in a matter of seconds. I gave it a spin today and it worked pretty well. Installing it on vSphere was pretty straightforward following documentation on the Photon GitHub site. Once it was installed, I needed to make a few changes to get it working smoothly.

Setting the proxy

If your environment uses a proxy to connect to the internet, continue with this section. If not, skip.

First, create a new directory to store the extra configuration.

1
mkdir /etc/systemd/system/docker.service.d

Next, create a http-proxy.conf file in the directory and edit it.

1
2
touch /etc/systemd/system/docker.service.d/http-proxy.conf
nano /etc/systemd/system/docker.service.d/http-proxy.conf

Add the following information to the file (substituting where necessary) and save with Ctrl + X.

1
2
[Service]
Environment="HTTP_PROXY=http://username:password@proxy.example.com:8080/"

Reload the systemd daemon and restart Docker.

1
2
systemctl daemon-reload
systemctl restart docker

Docker now has access to the internet.

Allow Docker connection via TCP

By default, Docker only allows connection through UNIX sockets. Since we will be controlling it via the Windows client, we need TCP access.

Open up the Docker service file in nano

1
nano /etc/systemd/system/multi-user.target.wants/docker.service

Edit the Service -> ExecStart line to allow TCP connections by changing:

1
ExecStart=/bin/docker -d -s overlay

to

1
ExecStart=/bin/docker -d -s overlay -H tcp://0.0.0.0:2375

Reload the systemd daemon and restart Docker.

1
2
systemctl daemon-reload
systemctl restart docker

Upgrade the Docker binary

Photon comes with Docker 1.5.0 but unfortunately the Windows client only works with 1.6.0 and above.

If you are using a corporate proxy, you will first need to set the http_proxy environmental variable so wget works

1
export https_proxy="http://username:password@proxy.example.com:8080/"

Download the Docker 1.6.0 binary

1
wget https://get.docker.com/builds/Linux/x86_64/docker-1.6.0

Move the binary to /bin/ and mark it as executable

1
2
3
4
5
systemctl stop docker
rm -r /bin/docker
mv docker-1.6.0 /bin/docker
chmod +x /bin/docker
systemctl start docker

You will now have Docker 1.6.0 running.

Connecting from Windows

Download Docker 1.6.0 for Windows from Docker.com - 32-bit or 64-bit and open PowerShell in that directory. At this point I recommend renaming the file to docker.exe.

To connect to the Photon host, run the following:

1
.\docker.exe -H=tcp://photon.ip.address.here:2375 info

This will show information about the Docker host like so:

1
2
3
4
5
6
7
8
9
10
11
Containers: 12
Images: 49
Storage Driver: overlay
Backing Filesystem: extfs
Execution Driver: native-0.2
Kernel Version: 3.19.2
Operating System: <unknown>
CPUs: 2
Total Memory: 489.7 MiB
Name: bvdocker1
ID: <id here>

You are now connected!

Comment and share

A nice little one-liner. This assumes you have already ran Connect-MsolService.

1
Get-MsolUser | select firstname,lastname,userprincipalname,islicensed,@{N="License";E={switch -regex ($_.licenses.accountskuid) { ("ENTERPRISEPACK") { "E3" } ("STANDARDPACK") { "E1" } }}} | ft

You can add more switches for more license types but we only use E3 and E1. Types are:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
"DESKLESSPACK" = "Office 365 (Plan K1)"
"DESKLESSWOFFPACK" = "Office 365 (Plan K2)"
"LITEPACK" = "Office 365 (Plan P1)"
"EXCHANGESTANDARD" = "Office 365 Exchange Online Only"
"STANDARDPACK" = "Office 365 (Plan E1)"
"STANDARDWOFFPACK" = "Office 365 (Plan E2)"
"ENTERPRISEPACK" = "Office 365 (Plan E3)"
"ENTERPRISEPACKLRG" = "Office 365 (Plan E3)"
"ENTERPRISEWITHSCAL" = "Office 365 (Plan E4)"
"STANDARDPACK_STUDENT" = "Office 365 (Plan A1) for Students"
"STANDARDWOFFPACKPACK_STUDENT" = "Office 365 (Plan A2) for Students"
"ENTERPRISEPACK_STUDENT" = "Office 365 (Plan A3) for Students"
"ENTERPRISEWITHSCAL_STUDENT" = "Office 365 (Plan A4) for Students"
"STANDARDPACK_FACULTY" = "Office 365 (Plan A1) for Faculty"
"STANDARDWOFFPACKPACK_FACULTY" = "Office 365 (Plan A2) for Faculty"
"ENTERPRISEPACK_FACULTY" = "Office 365 (Plan A3) for Faculty"
"ENTERPRISEWITHSCAL_FACULTY" = "Office 365 (Plan A4) for Faculty"
"ENTERPRISEPACK_B_PILOT" = "Office 365 (Enterprise Preview)"
"STANDARD_B_PILOT" = "Office 365 (Small Business Preview)"

Comment and share

Email2SMS

We’ve switched SMS providers at work to Nexmo, however they don’t have a SMTP API. I whipped up a quick EWS script to monitor a mailbox for emails in the correct format and to send SMS’ based off it. Script below.

The script should be run as the user whos mailbox will be monitored (ours is set up as a scheduled task). Next, it should have to subfolders called “Error” and “Processed”. Successful emails get marked as read and send to “Processed”, and unsuccessful emails get kept as unread and moved to “Error”. Because we send from some systems that don’t have SMTP authentication, there is a field called “Secret” that should be defined at the top of the PowerShell script and put in each email.

The format for the email is:

1
2
3
4
From: fromuser
To: number in international format (ie. +61404040404)
Text: any text here
Secret: secret code defined in script

The script is set to run every 20 seconds.

Comment and share

This isn’t really documented anywhere on the VMware website, but it comes in really handy if require certain users to have console access to machines without the complication of the vSphere Web Client.

  • Install VMware Player from the VMware website

  • Get the Managed Object ID of the VM. This can be done through PowerCLI with the following script:

1
2
3
4
5
6
7
8
9
$vcenter = "vcenter.domain.name"
$targetvm = "targetvm"
Add-PSSnapin VMware.VimAutomation.Core
Connect-VIServer -Server $vcenter -Force
$vmid = (Get-VM $targetvm).id -replace "VirtualMachine-",""
Disconnect-VIServer -Server $vcenter -Confirm:$false
Write-Output "VM MOID is $vmid"
  • Give the user access to the VM. The permission “Virtual Machine\Interaction\Console Interation” needs to be given on both the VM and the host. It doesn’t need to inherit to children so deselect “Propagate to children” in the permisisons screen”.

  • Create a shortcut to connect straight to the VM. The following PowerShell script can create the shortcut automatically.

1
2
3
4
5
6
7
8
9
$desktop = [Environment]::GetFolderPath("Desktop")
$vcenter = "vcenter.domain.name"
$targetvm = "targetvm"
$vmid = "vm-moid"
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$desktop\$targetvm.lnk")
$Shortcut.TargetPath = "vmrc://$vcenter/?moid=$vmid"
$Shortcut.Save()

Afterwards, double click on the shortcut on the desktop and enter appropriate credentials. You’ll be straight in to the console.

Comment and share

Powershell Desired State Configuration (DSC) is relatively new but wow, it is so powerful! I’ve had troubles getting Pydio up and running in the past, so I created a consistent configuration file to get it working.

Simply save the file as pydio.ps1 and run it on the target server. Make sure to download the prerequisite files (PHP, VC++ 2012 Redistributable, PHP Manager for IIS) and put them in an accessible location.

Comment and share

The iLO interface on one of our servers complete broke and we had no way of accessing it, and it wasn’t updating through the HP SPP media. Fortunately I was able to update it through SSH.

However, because the firmware on the iLO interface was so old, it needed to be upgraded to an earlier version first before updating to the latest. This is documented on the HP Support Centre.

Download a iLO3 1.2x firmware. It will come with the filename ilo3_12x.bin, with x being the minor version number. Upload the file to a web server that can be accessed by the iLO interface. Now, open a SSH session and connect to the iLO IP address. Run the following commands, replacing webserver with your web server FQDN/IP and the filename with the file you downloaded:

1
2
cd map1/firmware1
load -source http://webserver/ilo3_12x.bin

The iLO will now update and reboot, disconnecting you from SSH in the process. Once it’s back up, it will be upgraded and ready for the final upgrade through the HP SPP.

Comment and share

Jacob Ludriks

Nerd


System Administrator


Australia