mirror of
https://github.com/puppetlabs/vmpooler-provider-vsphere.git
synced 2026-01-26 11:28:40 -05:00
Collect the ip address of created VM for use with dns plugins
This commit is contained in:
parent
26ad5a7a74
commit
daa49dd1c9
1 changed files with 23 additions and 0 deletions
|
|
@ -382,11 +382,34 @@ module Vmpooler
|
|||
spec: clone_spec
|
||||
).wait_for_completion
|
||||
|
||||
# Make optional?
|
||||
ip = get_vm_ip_address(new_vm_object)
|
||||
|
||||
@redis.with_metrics do |redis|
|
||||
redis.hset("vmpooler__vm__#{new_vmname}", 'ip', ip)
|
||||
end
|
||||
|
||||
vm_hash = generate_vm_hash(new_vm_object, pool_name)
|
||||
end
|
||||
vm_hash
|
||||
end
|
||||
|
||||
# The inner method requires vmware tools running in the guest os
|
||||
def get_vm_ip_address(vm_object, maxloop = 0, loop_delay = 1, max_age = 60)
|
||||
loop_count = 1
|
||||
ip = nil
|
||||
while ip.nil?
|
||||
sleep(loop_delay)
|
||||
ip = vm_object.guest_ip
|
||||
unless maxloop == 0
|
||||
break if loop_count >= maxloop
|
||||
|
||||
loop_count += 1
|
||||
end
|
||||
end
|
||||
return ip
|
||||
end
|
||||
|
||||
def create_config_spec(vm_name, template_name, extra_config)
|
||||
RbVmomi::VIM.VirtualMachineConfigSpec(
|
||||
annotation: JSON.pretty_generate(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue