-Collect VM IP Addresses
- [Arguments] ${fail_on_none} @{vm_list}
- [Documentation] Using the console-log on the provided ${vm_list} to search for the string "obtained" which
- ... correlates to the instance receiving it's IP address via DHCP. Also retrieved is the ip of the nameserver
- ... if available in the console-log output. The keyword will also return a list of the learned ips as it
- ... finds them in the console log output, and will have "None" for Vms that no ip was found.
- ${ip_list} Create List @{EMPTY}
- : FOR ${vm} IN @{vm_list}
- \ ${rc} ${vm_ip_line}= Run And Return Rc And Output openstack console log show ${vm} | grep -i "obtained"
- \ @{vm_ip} Get Regexp Matches ${vm_ip_line} [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
- \ ${vm_ip_length} Get Length ${vm_ip}
- \ Run Keyword If ${vm_ip_length}>0 Append To List ${ip_list} @{vm_ip}[0]
- \ ... ELSE Append To List ${ip_list} None
- \ ${rc} ${dhcp_ip_line}= Run And Return Rc And Output openstack console log show ${vm} | grep "^nameserver"
- \ ${dhcp_ip} Get Regexp Matches ${dhcp_ip_line} [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
- \ ${dhcp_ip_length} Get Length ${dhcp_ip}
- \ Run Keyword If ${dhcp_ip_length}<=0 Append To List ${dhcp_ip} None
- \ ${vm_console_output}= Run openstack console log show ${vm}
- \ Log ${vm_console_output}
- ${dhcp_length} Get Length ${dhcp_ip}
- Run Keyword If '${fail_on_none}' == 'true' Should Not Contain ${ip_list} None
- Run Keyword If '${fail_on_none}' == 'true' Should Not Contain ${dhcp_ip} None
- Should Be True ${dhcp_length} <= 1
- Return From Keyword If ${dhcp_length}==0 ${ip_list} ${EMPTY}
- [Return] ${ip_list} ${dhcp_ip}
-