Searching for a VApp by the External IP address of one of its child VMs

This script will search through all the network adaptors in your organisation and find the one with the correct IP address assigned to it. From there, you can work out which VM/vApp has that IP.

Unfortunately this method is quite slow, due to the fact that the Get-CINetworkAdapter command takes quite a while to respond. If I come up with a way to achieve this via the REST api, I’ll post it here.

Set VM memory and CPU Cores in PowerCLI (vCloud)

PowerCLI for vCloud seems to be a lot less convenient to use than vSphere Powercli, but it’s certainly no less powerful! A routine operation (setting the RAM of a VM) in vCloud had me scratching my head for a while until I found this very enlightening post by @jakerobinson (http://geekafterfive.com/2012/06/29/add-vcloud-harddisks-with-powercli). The article provides an example of using the REST api with Powershell+PowerCLI, in this case to add a new hard disk to the VM.

After reading (and understanding!) what he was doing, it was relatively easy to come up with my own cmdlet to set memory and CPU like I used to with Set-VM for vSphere.  You don’t need to set both MemoryMB and CpuCores at the same time, you can set either or both. Read more

Setting vApp customisation scripts with PowerCLI (vCloud)

The bulk of my experience in VMWare PowerCLI since I started a year ago has been spent creating scripts that work with a local vSphere installation. I’ve been looking into the API that VMware provides for vCloud Director 5.1, which I find to be quite a different kettle of fish.

One difference I’ve found is the way in which guest customisation scripts are handled. In vSphere PowerCLI, you create customisation profiles in the GUI, then pass the profile name as a parameter to the VM;

In vCloud’s flavour of PowerCLI though, there is no concept of a guest customisation profile – customisation scripts need to be added to each VM in a vApp, either as part of a template specification, or after it’s been deployed. What I needed was a way of changing the value of the “Customization script” property in each VM in a vApp, but there appeared at first to be no support for this via the default vCloud PowerCLI cmdlets.

As luck would have it though, VMware have provided us with a way to directly access the vCloud API via the ExtensionData property of the VM object; Read more

Disabling firefox auto-update in CI environments

Auto-update prompts can become a problem during automated testing, as they will block the tests while waiting for user input, and can make it hard to say for certain which version of the browser you are testing against!

Manual:

Enter “about:config” into the Firefox URL bar, then change the following values. You can click on them to toggle.

app.update.auto = false
app.update.enabled = false

Scriptable:

Append the file C:\Program Files (x86)\Mozilla Firefox\defaults\pref\channel-prefs.js with the following text;

pref("app.update.auto","false")
pref("app.update.enabled","false")

Some people prefer to enter this configuration into profiles, but I prefer to replace this file after installation using a Chef template file.

 

Using virtual appliances that don’t tell you the login details!

This guide is useful if you have created a linux VApp from a public catalog, but have no idea what the login details are.

  1. Press ESC when the GRUB bootloader list loads (hold down shift if it doesn’t show up).
  2. Press “e” to enter edit mode.
  3. Highlight the line that starts with “kernel” and press the e key again.
  4. Append the following to the end of the line: rw init=/bin/bash
  5. Press Enter and then press b.
  6. You should now be in a bash environment logged in as root.
  7. Type in “passwd” to reset your password.
  8. Reboot the system and log in!

A comparison of free VM management solutions

This post is not about comparing VM performance with specific benchmarking software, rather it is a feature comparison to match my requirements. Important factors in my decision are ease of installation, ease of scripting and how easy it is to copy VMs.

My workplace hosts a VMware ESX cluster connected via vCenter. The cluster hosts over 200 VMs, which are easily managed via vSphere – VM templates, live migration and load balancing are key features that make managing the VM farm feasible. Unfortunately these features are licensed by VMware on top of the bare-bones VM server software at quite a large cost, beyond the scope of an individual hobbyist.

I have a PC at home that I am using less frequently for its intended purpose, running high performance games. I would like to repurpose it as a server that hosts VMs that I can easily manage from my laptop, which I use as a development environment. Cloud based solutions are not feasible, as I do not have the finances to pay for continuous online hosting.

My development environment is a Macbook Pro running OSX Mountain Lion, so any VM management software should ideally not be Windows-specific.

The aim is to be able to deploy and provision a VM by running one script from my laptop or via Jenkins, without manual intervention. Jenkins will be manually provisioned onto a linux instance that is hosted on the VM host, another linux VM will run Chef server. Any other VMs will be testing environments that are provisioned by Chef, and controlled by Jenkins. Read more

Video recording UI tests in a Maven project

In many automated builds that I’ve worked on screenshots are taken when a build fails. These screenshots are then accessible via the CI server. This is often too little too late, by the time the screenshot is taken the test has usually moved on. A screenshot lacks the context that caused the error in the first place.

To collect information, developers often request remote access to the virtual machines so that they can watch the test as it happens. Experience has taught me that the build environments should only be accessed by the CI server and whoever set up the environment in the first place, I don’t like the idea of developers getting their hands on the build environments. People tend to leave a mess when it’s not their responsibility to keep the environments clean. This can cause unstable builds, if a particular build machine has a different configuration from the rest due to unchecked meddling.

My solution is to record a video of the tests from start to finish, so that the developers can peruse the results without interfering with the machine that the tests run on. I have made this possible via the maven failsafe plugin and VLC 2.0.3 portable.

Read more

Instant notification when a GO agent goes missing

Computers are not infallible, even the most well written software breaks sometimes. Thoughtworks GO communicates with each build agent via the Go Agent software running as a service, which can go down due to hardware or software failures.

By default, the only way to monitor which agents are online, is by navigating to the Agent tab inside GO, and searching for “missing” agents. Read more

Killing a list of processes in Solaris by name

In GNU/Linux or OSX, you’d simply use the killall command to kill a process by its name, unfortunately the core Solaris utilities are about 10 years behind the competition in terms of functionality.

The solution is to use this script.

ps -ef gets the list of currently running processes

grep <process name> filters the list to only include entries that includes the process name

awk ‘{print $2}’ prints out the 2nd column of every entry in the list

xargs kill -9 takes all the items in the list to use as an argument and kills each process ID that it reads

 

jQuery mobile vertical slider

November 2011: I was involved in a company event that we like to call a “Hack day“. Inspired by companies like Google, that thrive on the innovation of their employees, my company likes to see what we can come up with in one day, offering pizza and red bull for everyone, and a nice prize for the best effort. To provide some sort of direction, each hack day has some sort of theme. Read more