mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 01:58:41 -05:00
Refactor obtaining and saving ip address
This commit is contained in:
parent
0119126cd1
commit
da4015f5b3
2 changed files with 14 additions and 4 deletions
|
|
@ -445,16 +445,22 @@ module Vmpooler
|
||||||
start = Time.now
|
start = Time.now
|
||||||
provider.create_vm(pool_name, new_vmname)
|
provider.create_vm(pool_name, new_vmname)
|
||||||
finish = format('%<time>.2f', time: Time.now - start)
|
finish = format('%<time>.2f', time: Time.now - start)
|
||||||
|
$logger.log('s', "[+] [#{pool_name}] '#{new_vmname}' cloned in #{finish} seconds")
|
||||||
|
$metrics.timing("clone.#{pool_name}", finish)
|
||||||
|
|
||||||
|
$logger.log('d', "[ ] [#{pool_name}] Obtaining IP for '#{new_vmname}'")
|
||||||
|
ip_start = Time.now
|
||||||
|
ip = provider.get_vm_ip_address(new_vmname, pool_name)
|
||||||
|
ip_finish = format('%<time>.2f', time: Time.now - ip_start)
|
||||||
|
$logger.log('s', "[+] [#{pool_name}] Obtained IP for '#{new_vmname}' in #{ip_finish} seconds")
|
||||||
|
|
||||||
@redis.with_metrics do |redis|
|
@redis.with_metrics do |redis|
|
||||||
redis.pipelined do |pipeline|
|
redis.pipelined do |pipeline|
|
||||||
pipeline.hset("vmpooler__clone__#{Date.today}", "#{pool_name}:#{new_vmname}", finish)
|
pipeline.hset("vmpooler__clone__#{Date.today}", "#{pool_name}:#{new_vmname}", finish)
|
||||||
pipeline.hset("vmpooler__vm__#{new_vmname}", 'clone_time', finish)
|
pipeline.hset("vmpooler__vm__#{new_vmname}", 'clone_time', finish)
|
||||||
|
pipeline.hset("vmpooler__vm__#{new_vmname}", 'ip', ip)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
$logger.log('s', "[+] [#{pool_name}] '#{new_vmname}' cloned in #{finish} seconds")
|
|
||||||
|
|
||||||
$metrics.timing("clone.#{pool_name}", finish)
|
|
||||||
|
|
||||||
dns_plugin_class_name = get_dns_plugin_class_name_for_pool(pool_name)
|
dns_plugin_class_name = get_dns_plugin_class_name_for_pool(pool_name)
|
||||||
dns_plugin.create_or_replace_record(new_vmname) unless dns_plugin_class_name == 'dynamic-dns'
|
dns_plugin.create_or_replace_record(new_vmname) unless dns_plugin_class_name == 'dynamic-dns'
|
||||||
|
|
|
||||||
|
|
@ -261,6 +261,10 @@ module Vmpooler
|
||||||
raise("#{self.class.name} does not implement purge_unconfigured_resources")
|
raise("#{self.class.name} does not implement purge_unconfigured_resources")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_vm_ip_address(vm_name, pool_name)
|
||||||
|
raise("#{self.class.name} does not implement get_vm_ip_address")
|
||||||
|
end
|
||||||
|
|
||||||
# DEPRECATED if a provider does not implement the new method, it will hit this base class method
|
# DEPRECATED if a provider does not implement the new method, it will hit this base class method
|
||||||
# and return a deprecation message
|
# and return a deprecation message
|
||||||
def purge_unconfigured_folders(_deprecated, _deprecated2, allowlist)
|
def purge_unconfigured_folders(_deprecated, _deprecated2, allowlist)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue