[Arguments] ${vm_name}
[Documentation] Run these commands to check whether the created vm instance is active or not.
${rc} ${output}= Run And Return Rc And Output openstack server show ${vm_name} | grep OS-EXT-STS:vm_state
- Should Not Be True ${rc}
+ Should Be True '${rc}' == '0'
Should Contain ${output} active
Poll VM Is ACTIVE
${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"
- \ Log ${vm_ip_line}
- \ Log ${rc}
\ @{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"
- \ Log ${dhcp_ip_line}
- \ Log ${rc}
\ ${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
- \ Log ${dhcp_ip}
\ ${vm_console_output}= Run openstack console log show ${vm}
\ Log ${vm_console_output}
${dhcp_length} Get Length ${dhcp_ip}
Return From Keyword If ${dhcp_length}==0 ${ip_list} ${EMPTY}
[Return] ${ip_list} ${dhcp_ip}
+Get Match
+ [Arguments] ${text} ${regexp}
+ [Documentation] Wrapper around Get Regexp Matches to return None if not found or the first match if found.
+ @{matches} = String.Get Regexp Matches ${text} ${regexp}
+ ${matches_length} = Get Length ${matches}
+ BuiltIn.Set Test Variable ${match} None
+ BuiltIn.Run Keyword If ${matches_length} > 0 BuiltIn.Set Test Variable ${match} @{matches}[0]
+ [Return] ${match}
+
+Get VM IP
+ [Arguments] ${fail_on_none} ${vm}
+ [Documentation] Get the vm ip address and nameserver by scraping the vm's console log.
+ ${rc} ${vm_console_output} = Run And Return Rc And Output openstack console log show ${vm}
+ # TODO Add hooks to only tail the console log on subsequent runs, e.g. look for "info: initramfs:".
+ # This would drop repeatedly logging the kernel messages which are long.
+ # Also add flag to log or not
+ BuiltIn.Log ${vm_console_output}
+ ${match} = Get Match ${vm_console_output} ${REGEX_OBTAINED}
+ ${OSO_VM_IP} = Get Match ${match} ${REGEX_IPV4}
+ ${match} = Get Match ${vm_console_output} ${REGEX_NAMESERVER}
+ ${OSO_DHCP_IP} = Get Match ${match} ${REGEX_IPV4}
+ BuiltIn.Set Test Variable ${OSO_VM_IP}
+ BuiltIn.Set Test Variable ${OSO_DHCP_IP}
+ BuiltIn.Run Keyword If '${fail_on_none}' == 'true' Should Not Contain ${OSO_VM_IP} None
+ BuiltIn.Run Keyword If '${fail_on_none}' == 'true' Should Not Contain ${OSO_DHCP_IP} None
+
+Get VM IPs
+ [Arguments] @{vms}
+ [Documentation] Get the instance IP addresses and nameserver address for the list of given vms.
+ ... First poll for the vm instance to be in the active state, then poll for the vm ip address and nameserver.
+ ... ${OSO_VM_IP} and ${OSO_DHCP_IP} are test variables shared with Get VM IP.
+ @{OSO_VM_IPS} BuiltIn.Create List @{EMPTY}
+ : FOR ${vm} IN @{vms}
+ \ BuiltIn.Set Test Variable ${OSO_VM_IP} None
+ \ BuiltIn.Set Test Variable ${OSO_DHCP_IP} None
+ \ Poll VM Is ACTIVE ${vm}
+ \ ${status} ${message} Run Keyword And Ignore Error Wait Until Keyword Succeeds 60s 15s
+ \ Get VM IP true ${vm}
+ \ BuiltIn.Run Keyword If '${OSO_VM_IP}' != 'None' Collections.Append To List ${OSO_VM_IPS} ${OSO_VM_IP}
+ [Return] @{OSO_VM_IPS} ${OSO_DHCP_IP}
+
Collect VM IPv6 SLAAC Addresses
[Arguments] ${fail_on_none} ${prefix} @{vm_list}
[Documentation] Using the console-log on the provided ${vm_list} to search for the string "inet6" which
Create Vm Instances l2_network_2 ${NET_2_VM_GRP_NAME} sg=${SECURITY_GROUP} min=3 max=3
Check Vm Instances Have Ip Address
- [Documentation] Test case to verify that all created VMs are ready and have received their ip addresses.
- ... We are polling first and longest on the last VM created assuming that if it's received it's address
- ... already the other instances should have theirs already or at least shortly thereafter.
- # first, ensure all VMs are in ACTIVE state. if not, we can just fail the test case and not waste time polling
- # for dhcp addresses
- : FOR ${vm} IN @{NET_1_VM_INSTANCES} @{NET_2_VM_INSTANCES}
- \ Poll VM Is ACTIVE ${vm}
- ${status} ${message} Run Keyword And Ignore Error Wait Until Keyword Succeeds 60s 15s Collect VM IP Addresses
- ... true @{NET_1_VM_INSTANCES}
- ${status} ${message} Run Keyword And Ignore Error Wait Until Keyword Succeeds 60s 15s Collect VM IP Addresses
- ... true @{NET_2_VM_INSTANCES}
- ${NET1_VM_IPS} ${NET1_DHCP_IP} Collect VM IP Addresses false @{NET_1_VM_INSTANCES}
- ${NET2_VM_IPS} ${NET2_DHCP_IP} Collect VM IP Addresses false @{NET_2_VM_INSTANCES}
- ${VM_INSTANCES}= Collections.Combine Lists ${NET_1_VM_INSTANCES} ${NET_2_VM_INSTANCES}
- ${VM_IPS}= Collections.Combine Lists ${NET1_VM_IPS} ${NET2_VM_IPS}
- ${LOOP_COUNT} Get Length ${VM_INSTANCES}
- : FOR ${index} IN RANGE 0 ${LOOP_COUNT}
- \ ${status} ${message} Run Keyword And Ignore Error Should Not Contain @{VM_IPS}[${index}] None
- \ Run Keyword If '${status}' == 'FAIL' Write Commands Until Prompt openstack console log show @{VM_INSTANCES}[${index}] 30s
- Set Suite Variable ${NET1_VM_IPS}
- Set Suite Variable ${NET2_VM_IPS}
+ @{NET1_VM_IPS} ${NET1_DHCP_IP} = Get VM IPs @{NET_1_VM_INSTANCES}
+ @{NET2_VM_IPS} ${NET2_DHCP_IP} = Get VM IPs @{NET_2_VM_INSTANCES}
+ Set Suite Variable @{NET1_VM_IPS}
+ Set Suite Variable @{NET2_VM_IPS}
Should Not Contain ${NET1_VM_IPS} None
Should Not Contain ${NET2_VM_IPS} None
Should Not Contain ${NET1_DHCP_IP} None
${SECURITY_GROUP} sg-connectivity
@{NETWORKS_NAME} network_1 network_2 network_3
@{SUBNETS_NAME} subnet_1 subnet_2 subnet_3
-@{NET_1_VM_INSTANCES} l3_instance_net_1_1 l3_instance_net_1_2 l3_instance_net_1_3
-@{NET_2_VM_INSTANCES} l3_instance_net_2_1 l3_instance_net_2_2 l3_instance_net_2_3
-@{NET_3_VM_INSTANCES} l3_instance_net_3_1 l3_instance_net_3_2 l3_instance_net_3_3
+@{NET_1_VM_INSTANCES} l3_net_1_vm_1 l3_net_1_vm_2 l3_net_1_vm_3
+@{NET_2_VM_INSTANCES} l3_net_2_vm_1 l3_net_2_vm_2 l3_net_2_vm_3
+@{NET_3_VM_INSTANCES} l3_net_3_vm_1 l3_net_3_vm_2 l3_net_3_vm_3
@{SUBNETS_RANGE} 50.0.0.0/24 60.0.0.0/24 70.0.0.0/24
${network1_vlan_id} 1236
Create Vm Instances network_3 ${NET_3_VM_INSTANCES} sg=${SECURITY_GROUP}
Check Vm Instances Have Ip Address
- [Documentation] Test case to verify that all created VMs are ready and have received their ip addresses.
- ... We are polling first and longest on the last VM created assuming that if it's received it's address
- ... already the other instances should have theirs already or at least shortly thereafter.
- # first, ensure all VMs are in ACTIVE state. if not, we can just fail the test case and not waste time polling
- # for dhcp addresses
- : FOR ${vm} IN @{NET_1_VM_INSTANCES} @{NET_2_VM_INSTANCES} @{NET_3_VM_INSTANCES}
- \ Poll VM Is ACTIVE ${vm}
- ${status} ${message} Run Keyword And Ignore Error Wait Until Keyword Succeeds 60s 15s Collect VM IP Addresses
- ... true @{NET_1_VM_INSTANCES}
- ${status} ${message} Run Keyword And Ignore Error Wait Until Keyword Succeeds 60s 15s Collect VM IP Addresses
- ... true @{NET_2_VM_INSTANCES}
- ${status} ${message} Run Keyword And Ignore Error Wait Until Keyword Succeeds 60s 15s Collect VM IP Addresses
- ... true @{NET_3_VM_INSTANCES}
- ${NET3_L3_VM_IPS} ${NET3_DHCP_IP} Collect VM IP Addresses false @{NET_3_VM_INSTANCES}
- ${NET2_L3_VM_IPS} ${NET2_DHCP_IP} Collect VM IP Addresses false @{NET_2_VM_INSTANCES}
- ${NET1_L3_VM_IPS} ${NET1_DHCP_IP} Collect VM IP Addresses false @{NET_1_VM_INSTANCES}
- ${VM_INSTANCES}= Collections.Combine Lists ${NET_1_VM_INSTANCES} ${NET_2_VM_INSTANCES} ${NET_3_VM_INSTANCES}
- ${VM_IPS}= Collections.Combine Lists ${NET1_L3_VM_IPS} ${NET2_L3_VM_IPS} ${NET3_L3_VM_IPS}
- ${LOOP_COUNT} Get Length ${VM_INSTANCES}
- : FOR ${index} IN RANGE 0 ${LOOP_COUNT}
- \ ${status} ${message} Run Keyword And Ignore Error Should Not Contain @{VM_IPS}[${index}] None
- \ Run Keyword If '${status}' == 'FAIL' Write Commands Until Prompt openstack console log show @{VM_INSTANCES}[${index}] 30s
+ @{NET1_L3_VM_IPS} ${NET1_L3_DHCP_IP} = Get VM IPs @{NET_1_VM_INSTANCES}
+ @{NET2_L3_VM_IPS} ${NET2_L3_DHCP_IP} = Get VM IPs @{NET_2_VM_INSTANCES}
+ @{NET3_L3_VM_IPS} ${NET3_L3_DHCP_IP} = Get VM IPs @{NET_3_VM_INSTANCES}
Set Suite Variable ${NET1_L3_VM_IPS}
- Set Suite Variable ${NET1_DHCP_IP}
Set Suite Variable ${NET2_L3_VM_IPS}
- Set Suite Variable ${NET2_DHCP_IP}
Set Suite Variable ${NET3_L3_VM_IPS}
- Set Suite Variable ${NET3_DHCP_IP}
Should Not Contain ${NET1_L3_VM_IPS} None
Should Not Contain ${NET2_L3_VM_IPS} None
- Should Not Contain ${NET1_DHCP_IP} None
- Should Not Contain ${NET2_DHCP_IP} None
- Should Not Contain ${NET3_DHCP_IP} None
+ Should Not Contain ${NET3_L3_VM_IPS} None
+ Should Not Contain ${NET1_L3_DHCP_IP} None
+ Should Not Contain ${NET2_L3_DHCP_IP} None
+ Should Not Contain ${NET3_L3_DHCP_IP} None
[Teardown] Run Keywords Show Debugs @{NET_1_VM_INSTANCES} @{NET_2_VM_INSTANCES} @{NET_3_VM_INSTANCES}
... AND Get Test Teardown Debugs
OpenStackOperations.Create Vm Instances @{NETWORKS_NAME}[0] ${VM_INSTANCES_SNAT} sg=${SECURITY_GROUP}
Check Vm Instances Have Ip Address
- [Documentation] Test case to verify that all created VMs are ready and have received their ip addresses.
- ... We are polling first and longest on the last VM created assuming that if it's received it's address
- ... already the other instances should have theirs already or at least shortly thereafter.
- # first, ensure all VMs are in ACTIVE state. if not, we can just fail the test case and not waste time polling
- # for dhcp addresses
- : FOR ${vm} IN @{VM_INSTANCES_FLOATING} @{VM_INSTANCES_SNAT}
- \ Poll VM Is ACTIVE ${vm}
- ${status} ${message} Run Keyword And Ignore Error Wait Until Keyword Succeeds 60s 15s Collect VM IP Addresses
- ... true @{VM_INSTANCES_FLOATING}
- ${status} ${message} Run Keyword And Ignore Error Wait Until Keyword Succeeds 60s 15s Collect VM IP Addresses
- ... true @{VM_INSTANCES_SNAT}
- ${FLOATING_VM_IPS} ${FLOATING_DHCP_IP} Collect VM IP Addresses false @{VM_INSTANCES_FLOATING}
- ${SNAT_VM_IPS} ${SNAT_DHCP_IP} Collect VM IP Addresses false @{VM_INSTANCES_SNAT}
- ${VM_INSTANCES}= Collections.Combine Lists ${VM_INSTANCES_FLOATING} ${VM_INSTANCES_SNAT}
- ${VM_IPS}= Collections.Combine Lists ${FLOATING_VM_IPS} ${SNAT_VM_IPS}
- ${LOOP_COUNT} Get Length ${VM_INSTANCES}
- : FOR ${index} IN RANGE 0 ${LOOP_COUNT}
- \ ${status} ${message} Run Keyword And Ignore Error Should Not Contain @{VM_IPS}[${index}] None
- \ Run Keyword If '${status}' == 'FAIL' Write Commands Until Prompt openstack console log show @{VM_INSTANCES}[${index}] 30s
- Set Suite Variable ${FLOATING_VM_IPS}
- Set Suite Variable ${SNAT_VM_IPS}
+ @{FLOATING_VM_IPS} ${FLOATING_DHCP_IP} = Get VM IPs @{VM_INSTANCES_FLOATING}
+ @{SNAT_VM_IPS} ${SNAT_DHCP_IP} = Get VM IPs @{VM_INSTANCES_SNAT}
+ Set Suite Variable @{FLOATING_VM_IPS}
+ Set Suite Variable @{SNAT_VM_IPS}
Should Not Contain ${FLOATING_VM_IPS} None
Should Not Contain ${SNAT_VM_IPS} None
- Should Not Contain @{FLOATING_DHCP_IP}[0] None
- Should Not Contain @{SNAT_DHCP_IP}[0] None
+ Should Not Contain ${FLOATING_DHCP_IP} None
+ Should Not Contain ${SNAT_DHCP_IP} None
[Teardown] Run Keywords Show Debugs @{VM_INSTANCES_FLOATING} @{VM_INSTANCES_SNAT}
... AND Get Test Teardown Debugs
OpenStackOperations.Create Vm Instances @{NETWORKS_NAME}[1] ${NET_2_VM_INSTANCES} sg=${SECURITY_GROUP}
Check Vm Instances Have Ip Address
- [Documentation] Test case to verify that all created VMs are ready and have received their ip addresses.
- ... We are polling first and longest on the last VM created assuming that if it's received it's address
- ... already the other instances should have theirs already or at least shortly thereafter.
- # first, ensure all VMs are in ACTIVE state. if not, we can just fail the test case and not waste time polling
- # for dhcp addresses
- : FOR ${vm} IN @{NET_1_VM_INSTANCES}
- \ OpenStackOperations.Poll VM Is ACTIVE ${vm}
- ${status} ${message} BuiltIn.Run Keyword And Ignore Error BuiltIn.Wait Until Keyword Succeeds 60s 15s OpenStackOperations.Collect VM IP Addresses
- ... true @{NET_1_VM_INSTANCES}
- ${NET1_VM_IPS} ${NET1_DHCP_IP} OpenStackOperations.Collect VM IP Addresses false @{NET_1_VM_INSTANCES}
- ${NET2_VM_IPS} ${NET2_DHCP_IP} OpenStackOperations.Collect VM IP Addresses false @{NET_2_VM_INSTANCES}
- ${VM_INSTANCES}= Collections.Combine Lists ${NET_1_VM_INSTANCES}
- ${VM_IPS}= Collections.Combine Lists ${NET1_VM_IPS}
- ${LOOP_COUNT} BuiltIn.Get Length ${VM_INSTANCES}
- : FOR ${index} IN RANGE 0 ${LOOP_COUNT}
- \ ${status} ${message} BuiltIn.Run Keyword And Ignore Error BuiltIn.Should Not Contain @{VM_IPS}[${index}] None
- \ BuiltIn.Run Keyword If '${status}' == 'FAIL' DevstackUtils.Write Commands Until Prompt openstack console log show @{VM_INSTANCES}[${index}] 30s
- BuiltIn.Set Suite Variable ${NET1_VM_IPS}
- BuiltIn.Set Suite Variable ${NET1_DHCP_IP}
- BuiltIn.Should Not Contain ${NET1_VM_IPS} None
- BuiltIn.Should Not Contain ${NET1_DHCP_IP} None
- BuiltIn.Set Suite Variable ${NET2_VM_IPS}
- BuiltIn.Set Suite Variable ${NET2_DHCP_IP}
- BuiltIn.Should Not Contain ${NET2_VM_IPS} None
- BuiltIn.Should Not Contain ${NET2_DHCP_IP} None
+ @{NET1_VM_IPS} ${NET1_DHCP_IP} = Get VM IPs @{NET_1_VM_INSTANCES}
+ @{NET2_VM_IPS} ${NET2_DHCP_IP} = Get VM IPs @{NET_2_VM_INSTANCES}
+ Set Suite Variable @{NET1_VM_IPS}
+ Set Suite Variable ${NET1_DHCP_IP}
+ Set Suite Variable @{NET2_VM_IPS}
+ Should Not Contain ${NET1_VM_IPS} None
+ Should Not Contain ${NET2_VM_IPS} None
+ Should Not Contain ${NET1_DHCP_IP} None
+ Should Not Contain ${NET2_DHCP_IP} None
[Teardown] BuiltIn.Run Keywords OpenStackOperations.Show Debugs @{NET_1_VM_INSTANCES}
... AND OpenStackOperations.Get Test Teardown Debugs
[Documentation] Add an additional security group to the VMs - this is done to test a different logic put in place for ports with multiple SGs
OpenStackOperations.Security Group Create Without Default Security Rules additional-sg
#TODO Remove this after the Newton jobs are removed, Openstack CLI with Newton lacks support to configure rule with remote_ip_prefix
- OpenStackOperations.Neutron Security Group Rule Create Legacy Cli additional-sg direction=ingress protocol=icmp remote_ip_prefix=@{NET1_DHCP_IP}[0]/32
+ OpenStackOperations.Neutron Security Group Rule Create Legacy Cli additional-sg direction=ingress protocol=icmp remote_ip_prefix=${NET1_DHCP_IP}/32
OpenStackOperations.Neutron Security Group Show additional-sg
: FOR ${vm} IN @{NET_1_VM_INSTANCES}
\ OpenStackOperations.Add Security Group To VM ${vm} additional-sg
OpenStackOperations.Ping From DHCP Should Not Succeed @{NETWORKS_NAME}[0] @{NET1_VM_IPS}[1]
Add The Rules To Additional Security Group Again
- OpenStackOperations.Neutron Security Group Rule Create Legacy Cli additional-sg direction=ingress protocol=icmp remote_ip_prefix=@{NET1_DHCP_IP}[0]/32
+ OpenStackOperations.Neutron Security Group Rule Create Legacy Cli additional-sg direction=ingress protocol=icmp remote_ip_prefix=${NET1_DHCP_IP}/32
Ping From DHCP To Vm Instance1 After Rules Are Added Again
[Documentation] Check reachability of vm instances by pinging to them from DHCP.
${PREFIX} http://${ODL_SYSTEM_IP}:${PORT} # Deprecated. FIXME: Name is to generic. Eradicate.
${PROTOCOL_LOG_LEVEL} ${DEFAULT_PROTOCOL_LOG_LEVEL} # Some suites temporarily override org.opendaylight.protocol Karaf log level to this value.
${PWD} ${ODL_RESTCONF_PASSWORD} # Deprecated. FIXME: Eradicate.
+${REGEX_IPV4} [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
+${REGEX_NAMESERVER} nameserver [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
+${REGEX_OBTAINED} [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3} obtained
${REGISTER_TENANT_URI} /restconf/operations/nemo-intent:register-user # FIXME: Move to a separate Nemo-related Resource and add description.
${RESTCONFPORT} 8181 # Primary port for ODL RESTCONF, although 8080 should also work.
${RESTCONFPORT_TLS} 8443 # Port for ODL RESTCONF Secure (TLS) operations