How to mass update virtual machines in XenServer

Introduction

Ever needed to add additional resources to multiple VMs at once in Xen? Here's how I do it:

Steps
(3 total)

1

Get a usable UUID list

Every action in XenServer is applied to UUIDs - host UUIDs, SR UUIDs, VM UUIDs, etc.
Therefore, in order to pull this off, you'll need the list of VM UUIDs in a format that you can work with. This is done with a combination of the xe vm-list command, and some unix trickery.
For this example, I wanted to add a second vCPU to all VMs in this pool. Knowing that you have to have the VMs powered off to add vCPUs, I shut them all down, which means I can use the command
xe vm-list power-state=halted to get a list - but I can't use this in any usable format. On to step 2.

2

Parse results of xe vm-list

In order to feed the UUIDs back into another command for modification, I had to cut the result set down to just the UUIDS. I did this with a combination of grep, gawk, and cut:
xe vm-list power-state=halted | grep uuid | gawk '{ print $5 }' | cud -d ":" -f 2

The first statement takes the result of the xe vm-list command and parses it into the variable x. Each time through the loop, the xe vm-param-set command is executed with uuid=$x, which is the current uuid value in x from statement 1. Finally, after it has iterated through all UUIDs, the loop terminates.

Conclusion

Quick bash scripting like this can be invaluable if you have a large number of VMs that you need to modify quickly. I ran this on 150 Windows 7 VMs in the matter of a few seconds, and would have taken me more time than I care to think about to do it by hand. I hope this helps someone in the future.

A vendor claims Ciscos hardware routers would out perform Sophos firewalls as gateway devices. Each vendor claims their stuff is superior. What do you think, is the hardware advantage enough to overcome the extra hop/processing cost?