Merge pull request #7 from sschneid/json_annotation

Store annotation in JSON format
This commit is contained in:
Scott Schneider 2014-02-12 12:36:34 -08:00
commit 443c9728ab

View file

@ -1,5 +1,6 @@
#!/usr/bin/ruby
require 'json'
require 'rbvmomi'
require 'redis'
require 'time'
@ -164,9 +165,12 @@ def clone_vm template, pool, folder, datastore
# Annotate with creation time, origin template, etc.
configSpec = RbVmomi::VIM.VirtualMachineConfigSpec(
:annotation =>
'Base template: ' + vm['template'] + "\n" +
'Creation time: ' + Time.now.strftime("%Y-%m-%d %H:%M")
:annotation => JSON.pretty_generate({
name: vm['hostname'],
created_by: $config[:vsphere]['username'],
base_template: vm['template'],
creation_timestamp: Time.now.utc
})
)
# Put the VM in the specified folder and resource pool