Have you ever noticed the “Notes” section when looking at the VirtualMachine view either from the web client or from the vi client? Its a handy little place to leave various bits of information. I like to use it to put in who built the VirtualMachine and when, and if it had a ticket number that I could tie it to.
Right now this VirtualMachine has no note set, and I want to set one using pyVmomi, but how do you do that? Well I made a sample that demonstrates how to do it. Lets walk though how to use this sample. First lets see what the options are:
± |master ✗| → python set_note.py -h usage: set_note.py [-h] -s HOST [-o PORT] -u USER [-p PASSWORD] -j UUID -m MESSAGE Standard Arguments for talking to vCenter optional arguments: -h, --help show this help message and exit -s HOST, --host HOST vSphere service to connect to -o PORT, --port PORT Port to connect on -u USER, --user USER User name to use when connecting to host -p PASSWORD, --password PASSWORD Password to use when connecting to host -j UUID, --uuid UUID UUID of the VirtualMachine you want to add a note to. -m MESSAGE, --message MESSAGE Message to add to the notes field.
Like the last couple of samples I have covered this one takes the same basic options of Host, User, Password, and Port. This sample adds 2 new options though. The first is the -j or –uuid. What is the UUID though and why do you need it? The UUID is a unique identifier given to the VirtualMachine by the vCenter. This makes it a good choice to use for tracking the asset. If you are unsure of where to get the UUID you can use the vminfo_quick script from my previous post. The next option is the -m or –message. This option set the message that will be added to the Notes section. Lets give it a try and see how it works out.
± |master ✗| → python set_note.py -s 10.12.254.137 -u 'email@example.com' -p password -j 421b3c9a-3aef-3662-c476-5b564d045c08 -m "Built by: Michael Rice" Found: vCloud Director Done.
Which leaves our vCenter with this:
If you have any questions about this process please feel free to ask me and Ill try to help. Happy note setting!