add guestinfo.hostname to VirtualMachineConfigSpecs

This commit adds a custom guestinfo keyword and hostname variable
that allows the VMware Tools to query the hostname.
This commit is contained in:
Heath Seals 2015-11-10 13:20:22 -08:00
parent 36f83fef82
commit 6b9bcc4307

View file

@ -197,13 +197,19 @@ module Vmpooler
$redis.hset('vmpooler__vm__' + vm['hostname'], 'template', vm['template']) $redis.hset('vmpooler__vm__' + vm['hostname'], 'template', vm['template'])
# Annotate with creation time, origin template, etc. # Annotate with creation time, origin template, etc.
# Add extraconfig options that can be queried by vmtools
configSpec = RbVmomi::VIM.VirtualMachineConfigSpec( configSpec = RbVmomi::VIM.VirtualMachineConfigSpec(
annotation: JSON.pretty_generate( annotation: JSON.pretty_generate(
name: vm['hostname'], name: vm['hostname'],
created_by: $config[:vsphere]['username'], created_by: $config[:vsphere]['username'],
base_template: vm['template'], base_template: vm['template'],
creation_timestamp: Time.now.utc creation_timestamp: Time.now.utc
) ),
extraConfig: [
{ key: 'guestinfo.hostname',
value: vm['hostname']
}
]
) )
# Choose a clone target # Choose a clone target