vCloud API tools

Yesterday I discovered that GDS have open-sourced a whole bunch of products on their Github account.

The most interesting to me is that they have written and published Rubygems which provide an easy interaction with the vCloud API. Some customers of mine (who ironically are working closely with GDS) use UK hosting companies where the technology underpinning their cloud is vCloud Director.

GDS' tools such as the 'vcloud-query' and 'vcloud-walk' commands are really useful for power users, but the syntax for filtering for something simple like a specific VM can be a bit tricky to remember. I decided to write a simple little shell script wrapper which makes it easier to query for a specific VM (or otherwise display the attributes of all VMs as YAML objects)

The script is here and can be simply invoked likeso:

vcloud-vm-lookup -n example.com

.. where example.com is the name of the VM.

Expected output:

- :vdc: https://vcloud.example.com/api/vdc/XXXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX
  :storageProfileName: Tier1
  :status: POWERED_ON
  :numberOfCpus: '1'
  :name: example.com
  :memoryMB: '1024'
  :isVAppTemplate: 'false'
  :isPublished: 'false'
  :isInMaintenanceMode: 'false'
  :isDeployed: 'true'
  :isDeleted: 'false'
  :isBusy: 'false'
  :hardwareVersion: '9'
  :guestOs: Ubuntu Linux (64-bit)
  :containerName: vApp_DEV
  :container: https://vcloud.example.com/api/vApp/vapp-XXXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX
  :href: https://vcloud.example.com/api/vApp/vm-XXXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX
  :isVdcEnabled: 'true'
  :pvdcHighestSupportedHardwareVersion: '9'
  :taskStatus: success
  :task: https://vcloud.example.com/api/task/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  :taskDetails: ' '
  :vmToolsVersion: 'XXXXXXXX'
  :networkName: example_com_SDC01-CUST
  :taskStatusName: vappDeploy

Hope it is of use to someone. This is just a simple script for fast lookups of VMs and their attributes. If you find you start to need to filter on vApp or networks etc, then you are edging to the point where you may as well use the native 'vcloud-query' command directly.

Tags: