Thunderhead Bug Release — The Python SDK for VMware vCloud Usage Meter

I ran into an issue the other day when non ascii characters were in the Customer name. I tracked down the issue and put out a bug fix release for that today. You can read more about the bug here. Coming up in the next couple of weeks for version 0.5 will be support for vCloud Director. To update to the latest version of thunderhead simply run:

pip install -U thunderhead

And this will update you from 0.4 to 0.4.1 If you have any questions or need any help please feel free to reach out to me.

How to update vCloud Usage Meter to fix Shell Shock Bug

If you are running vCloud Usage Meter 3.3.1 or older your appliance is at risk and needs to be updated. VMware released an update but didnt exactly provide the best instructions for getting your systems updated. The purpose of this blog is to fill that gap and provide some detailed instructions.

To get started you should first go download 3.3.2 or newer vCloud Usage Meter OVA. Once you have that file you should make sure your current system has all the prerequisites taken care of, because if you dont when you upgrade and try to visit your updated Usage Meter you will only be greeted by a big ugly stack trace. Lets take care of those now. By default sshd is not running, but the upgrade script called importum requires it, and requires it to be running on the default port of 22. You can check your system by logging in as root and running the command service sshd status. If you get the response:

Checking for service sshd unused

then its not running and you will need to use service sshd start to start it up. Next just to be sure you should verify it is running on port 22 and listening on all interfaces like this: ss -an|grep 22 That should give you some output like the following:

LISTEN 0 128 :::22 :::*
LISTEN 0 128 *:22 *:*

If your output shows this then you are ready to move on to the next step which is to make sure your root password is set. By default there is no root password set and if that is the case with your system its time to set a password using passwd. Once that is set you should test ssh connectivity to make sure you can connect to the server as root. Once you have successfully logged in as root from a remote system you are ready to upgrade.

The upgrade process is pretty simple. All you need to do is deploy your new OVA and once it boots up log in as root with no password. Next issue the importum command. It takes 2 params. The first one should be the hostname or IP of the old Usage Meter, the next param is the version of the usage meter software. In my case I wanted to update the host and it was running 3.3.1 so I ran the command:

importum 331

Here is the output from my command:

localhost:~ # importum 331
Connecting to Usage Meter at to dump and compress the database and copy files to transfer directory
The authenticity of host ' (' can't be established.
RSA key fingerprint is 42:d7:3a:ad:9c:b1:b0:41:7f:93:5a:fd:a5:13:d9:01.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '' (RSA) to the list of known hosts.
VMware vCloud Usage Meter
root@'s password:
Copying files from old Usage Meter
root@'s password:
Moving existing keystore file to /opt/vmware/cloudusagemetering/encryption/defaultks-20141004_195153
Renaming existing database to usgmtr_20141004_195153
Import is complete. See /var/log/usgmtr/import-20141004_195153.log for details.

Once this is complete you are all done. If you have any problems check the logs in /var/log/usgmtr/ Happy updating!

vCloud Usage Meter

Recently I was tasked with building a tool that would create customers and rules in vCloud Usage Meter to help enhance our monthly usage reports. The way this tool needed to work was to connect to all of our vCenter Servers, pull some data from them then connect to vCloud Usage Meter and create a customer, then make a rule that would tie their inventory to some managed object. Normally I do most of my code work in Groovy using the Grails framework, but for this project I decided to use python. The main reason for that was we needed to run this tool once a month, and they wanted it hands off. I knew our Ops Team would want to create a crontab for it on one of our Linux servers so I wanted to make something very portable. Python was an obvious choice for this based off of that requirement.

When I got started I went looking for some library that would make it easier for me to interact with vCloud Usage Meter but I didnt find anything. vCloud Usage Meter provides a REST based API so I decided to just write my own library and called it thunderhead. I thought it might be useful to others so I went ahead and open sourced the work via Apache-2.0. At the time of this writing it is not 100% feature complete, but does provide a lot of functionality, and I plan to continue development on it to get it 100% complete. I also always appreciate pull requests so if you need something I havent implemented please feel free to send me a pull request. For examples of how to use the library see the tests that are included. To install thunderhead simply

pip install thunderhead