mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
Add some basic VM annotation
This commit is contained in:
parent
bf0150de4b
commit
e6e05b99ab
1 changed files with 9 additions and 1 deletions
|
|
@ -223,13 +223,20 @@ loop do
|
||||||
end
|
end
|
||||||
|
|
||||||
if vm['template'].length == 0
|
if vm['template'].length == 0
|
||||||
raise "Unable to find template '#{h['template']}'!"
|
raise "Unable to find template '#{vm['template']}'!"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Generate a randomized hostname
|
# Generate a randomized hostname
|
||||||
o = [('a'..'z'),('0'..'9')].map{|r| r.to_a}.flatten
|
o = [('a'..'z'),('0'..'9')].map{|r| r.to_a}.flatten
|
||||||
vm['hostname'] = o[rand(25)]+(0...14).map{o[rand(o.length)]}.join
|
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
|
# Put the VM in the specified folder and resource pool
|
||||||
relocateSpec = RbVmomi::VIM.VirtualMachineRelocateSpec(
|
relocateSpec = RbVmomi::VIM.VirtualMachineRelocateSpec(
|
||||||
:datastore => vsphere_helper.find_datastore(pool['datastore']),
|
:datastore => vsphere_helper.find_datastore(pool['datastore']),
|
||||||
|
|
@ -240,6 +247,7 @@ loop do
|
||||||
# Create a clone spec
|
# Create a clone spec
|
||||||
spec = RbVmomi::VIM.VirtualMachineCloneSpec(
|
spec = RbVmomi::VIM.VirtualMachineCloneSpec(
|
||||||
:location => relocateSpec,
|
:location => relocateSpec,
|
||||||
|
:config => configSpec,
|
||||||
:powerOn => true,
|
:powerOn => true,
|
||||||
:template => false
|
:template => false
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue