Skip to content

Commit bef9c18

Browse files
A-Beckjeffwarnica
authored andcommitted
Set and use 'destination_ip_address' var correctly (#139)
Automate/RedHatConsulting_Utilities/AutomationManagement/AnsibleTower/Operations/Methods.class/__methods__/add_host_to_inventory.rb + use 'destination_ip_address' instead of 'acquired_ip_address' Automate/RedHatConsulting_Utilities/Infrastructure/Network/Operations/Methods.class/__methods__/acquire_ip_address.rb + use 'destination_ip_address' instead of 'acquired_ip_address' Automate/RedHatConsulting_Utilities/Infrastructure/VM/Provisioning/StateMachines/Methods.class/__methods__/wait_for_vm_ip_addresses.rb + set 'destination_ip_address' as a state var + this enables the variable to be used if a retry is triggered in the state machine + collecting it during a step may result it the variable being unable to be accessed later if there is a retry
1 parent f63a3c2 commit bef9c18

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

Automate/RedHatConsulting_Utilities/AutomationManagement/AnsibleTower/Operations/Methods.class/__methods__/add_host_to_inventory.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ def determine_host_ip_address(vm)
2929
log(:info, "Unable to determine VM IP address for Ansible Tower Inventory - no IP Addresses associated with VM.")
3030
return nil
3131
end
32-
acquired_ip_address = get_param(:acquired_ip_address)
33-
log(:info, "Aquired IP Address => #{acquired_ip_address}" )
34-
ip_address = vm.ipaddresses.include?(acquired_ip_address) ? acquired_ip_address : vm.ipaddresses.first
32+
destination_ip = get_param(:destination_ip_address)
33+
log(:info, "Host Destination IP Address => #{destination_ip}" )
34+
ip_address = vm.ipaddresses.include?(destination_ip) ? destination_ip : vm.ipaddresses.first
3535
log(:info, "Discovered IP Address for Ansible Tower Inventory => #{ip_address}" )
3636
return ip_address
3737
end

Automate/RedHatConsulting_Utilities/Infrastructure/Network/Operations/Methods.class/__methods__/acquire_ip_address.rb

+5
Original file line numberDiff line numberDiff line change
@@ -227,5 +227,10 @@ def get_network_configuration(network_name)
227227
# set the acquired IP
228228
$evm.object['acquired_ip_address'] = acquired_ip_address
229229
$evm.set_state_var(:acquired_ip_address, acquired_ip_address)
230+
231+
# set destination IP address to acquired IP address
232+
$evm.object['destination_ip_address'] = acquired_ip_address
233+
$evm.set_state_var(:destination_ip_address, acquired_ip_address)
234+
230235
$evm.log(:info, "$evm.object['acquired_ip_address'] => #{$evm.object['acquired_ip_address']}") if @DEBUG
231236
end

Automate/RedHatConsulting_Utilities/Infrastructure/VM/Provisioning/StateMachines/Methods.class/__methods__/wait_for_vm_ip_addresses.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def main
2121
error("vm parameter not found") if vm.blank?
2222

2323
# check to see if there is an expected destination ip
24-
expected_ip = options[:destination_ip] || get_param(:destination_ip)
24+
expected_ip = options[:destination_ip_address] || get_param(:destination_ip_address)
2525

2626
# ensure VM IP addresses are set
2727
if vm.ipaddresses.nil? || vm.ipaddresses.empty?

0 commit comments

Comments
 (0)