Refactor obtaining and saving ip address

This commit is contained in:
Jake Spain 2023-02-17 09:01:53 -05:00
parent 1375093b43
commit 36e9044087
No known key found for this signature in database
GPG key ID: BC1C4DA0A085E113

View file

@ -206,14 +206,14 @@ module Vmpooler
result = connection.insert_instance(project, zone(pool_name), client) result = connection.insert_instance(project, zone(pool_name), client)
wait_for_operation(project, pool_name, result) wait_for_operation(project, pool_name, result)
created_instance = get_vm(pool_name, new_vmname) created_instance = get_vm(pool_name, new_vmname)
# Exceptions thrown if ip does not exist in preexisting vm? Redis::CommandError: ERR wrong number of arguments for 'hset' command
@redis.with_metrics do |redis|
ip = created_instance['ip']
redis.hset("vmpooler__vm__#{new_vmname}", 'ip', ip)
end
created_instance created_instance
end end
def get_vm_ip_address(vm_name, pool_name)
vm_object = get_vm(pool_name, vm_name)
return vm_object['ip']
end
# create_disk creates an additional disk for an existing VM. It will name the new # create_disk creates an additional disk for an existing VM. It will name the new
# disk #{vm_name}-disk#{number_disk} where number_disk is the next logical disk number # disk #{vm_name}-disk#{number_disk} where number_disk is the next logical disk number
# starting with 1 when adding an additional disk to a VM with only the boot disk: # starting with 1 when adding an additional disk to a VM with only the boot disk: