From e6e05b99aba26c1e798e3873fd8220a3b143b602 Mon Sep 17 00:00:00 2001 From: Scott Schneider Date: Thu, 31 Oct 2013 12:25:07 -0700 Subject: [PATCH] Add some basic VM annotation --- vmware-host-pooler | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vmware-host-pooler b/vmware-host-pooler index 1bc3448..c59969f 100755 --- a/vmware-host-pooler +++ b/vmware-host-pooler @@ -223,13 +223,20 @@ loop do end if vm['template'].length == 0 - raise "Unable to find template '#{h['template']}'!" + raise "Unable to find template '#{vm['template']}'!" end # Generate a randomized hostname o = [('a'..'z'),('0'..'9')].map{|r| r.to_a}.flatten vm['hostname'] = o[rand(25)]+(0...14).map{o[rand(o.length)]}.join + # 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") + ) + # Put the VM in the specified folder and resource pool relocateSpec = RbVmomi::VIM.VirtualMachineRelocateSpec( :datastore => vsphere_helper.find_datastore(pool['datastore']), @@ -240,6 +247,7 @@ loop do # Create a clone spec spec = RbVmomi::VIM.VirtualMachineCloneSpec( :location => relocateSpec, + :config => configSpec, :powerOn => true, :template => false )