X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=csit%2Flibraries%2FOpenStackOperations.robot;h=4f23c8a25cede25bfe600c20e8dcd3ea6225edcf;hb=94651ca9711d8eb316721775561e815830bc6c7e;hp=6b87944d67e2c39d76f66c4bb1717c6f29b810bd;hpb=b66ff9f85a176986e646c99c2cd2aa2e2497d820;p=integration%2Ftest.git diff --git a/csit/libraries/OpenStackOperations.robot b/csit/libraries/OpenStackOperations.robot index 6b87944d67..4f23c8a25c 100644 --- a/csit/libraries/OpenStackOperations.robot +++ b/csit/libraries/OpenStackOperations.robot @@ -43,6 +43,17 @@ Create Network ${output} = OpenStack CLI openstack network create ${network_name} ${additional_args} [Return] ${output} +Create Multiple Networks + [Arguments] @{name_of_networks} + [Documentation] Create required number of networks and return a list of the resulting network ids + ${net_list_ids} = BuiltIn.Create List @{EMPTY} + FOR ${net} IN @{name_of_networks} + ${output} = OpenStackOperations.Create Network ${net} + ${net_id} = Get Regexp Matches ${output} ${REGEX_UUID} + Collections.Append To List ${net_list_ids} ${net_id} + END + [Return] @{net_list_ids} + Update Network [Arguments] ${network_name} ${additional_args}=${EMPTY} [Documentation] Update Network with neutron request. @@ -75,6 +86,22 @@ Create SubNet [Documentation] Create SubNet for the Network with neutron request. ${output} = OpenStack CLI openstack subnet create --network ${network_name} --subnet-range ${range_ip} ${subnet_name} ${additional_args} +Create Multiple Subnets + [Arguments] ${network_names} ${subnet_names} ${subnet_cidr} + [Documentation] Create required number of subnets for previously created networks and return subnet id + ${number_of_networks} = BuiltIn.Get Length ${network_names} + @{subnet_id_list} = BuiltIn.Create List @{EMPTY} + FOR ${index} IN RANGE ${number_of_networks} + OpenStackOperations.Create SubNet ${network_names[${index}]} ${subnet_names[${index}]} ${subnet_cidr[${index}]} + END + ${sub_list} = OpenStackOperations.List Subnets + FOR ${index} IN RANGE ${number_of_networks} + BuiltIn.Should Contain ${sub_list} ${subnet_names[${index}]} + ${subnet_id} = OpenStackOperations.Get Subnet Id ${subnet_names[${index}]} + Collections.Append To List ${subnet_id_list} ${subnet_id} + END + [Return] @{subnet_id_list} + Update SubNet [Arguments] ${subnet_name} ${additional_args}=${EMPTY} [Documentation] Update subnet with openstack subnet set request. @@ -134,19 +161,26 @@ Create And Associate Floating IPs [Arguments] ${external_net} @{vm_list} [Documentation] Create and associate floating IPs to VMs with nova request ${ip_list} = BuiltIn.Create List @{EMPTY} - : FOR ${vm} IN @{vm_list} - \ ${output} = OpenStack CLI openstack floating ip create ${external_net} - \ @{ip} = String.Get Regexp Matches ${output} [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3} - \ ${ip_length} = BuiltIn.Get Length ${ip} - \ BuiltIn.Run Keyword If ${ip_length}>0 Collections.Append To List ${ip_list} @{ip}[0] - \ ... ELSE Collections.Append To List ${ip_list} None - \ ${output} = OpenStack CLI openstack server add floating ip ${vm} @{ip}[0] + FOR ${vm} IN @{vm_list} + ${output} = OpenStack CLI openstack floating ip create ${external_net} + @{ip} = String.Get Regexp Matches ${output} [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3} + ${ip_length} = BuiltIn.Get Length ${ip} + BuiltIn.Run Keyword If ${ip_length}>0 Collections.Append To List ${ip_list} @{ip}[0] + ... ELSE Collections.Append To List ${ip_list} None + ${vm_ip} = OpenStack CLI openstack server show ${vm} | grep "addresses" | awk '{print $4}' | cut -d"=" -f 2 + ${port_id} = OpenStack CLI openstack port list | grep "ip_address='${vm_ip}'" | awk '{print $2}' | cut -d"=" -f 2 + ${output} = BuiltIn.Run Keyword If '${OPENSTACK_BRANCH}' == 'stable/rocky' OpenStack CLI openstack floating ip set --port ${port_id} @{ip}[0] + ... ELSE OpenStack CLI openstack server add floating ip ${vm} @{ip}[0] + END [Return] ${ip_list} Remove Floating Ip From Vm [Arguments] ${vm_name} ${fip} [Documentation] Remove the Floating IP From VM Instance - ${output} = OpenStack CLI openstack server remove floating ip ${vm_name} ${fip} + ${vm_ip} = OpenStack CLI openstack server show ${vm_name} | grep "addresses" | awk '{print $4}' | cut -d"=" -f 2 + ${port_id} = OpenStack CLI openstack port list | grep "ip_address='${vm_ip}'" | awk '{print $2}' | cut -d"=" -f 2 + ${output} = BuiltIn.Run Keyword If '${OPENSTACK_BRANCH}' == 'stable/rocky' OpenStack CLI openstack floating ip unset --port ${port_id} ${fip} + ... ELSE OpenStack CLI openstack server remove floating ip ${vm_name} ${fip} Delete Floating IP [Arguments] ${fip} @@ -203,6 +237,13 @@ Get Router Id ${router_id} = Collections.Get from List ${splitted_output} 0 [Return] ${router_id} +Get VMs OVS Port Number + [Arguments] ${ip_address} ${portname} + [Documentation] Get the port number for given portname + ${subportid} = OpenStackOperations.Get Sub Port Id ${portname} + ${vm_port_number} = OVSDB.Get Port Number ${subportid} ${ip_address} + [Return] ${vm_port_number} + Add New Image From Url [Arguments] ${image_url} ${image_name} [Documentation] To add new qcow2 images for testing. @@ -238,8 +279,9 @@ Create Vm Instances .. ${max}=1 ${image} BuiltIn.Set Variable If "${image}"=="${EMPTY}" ${CIRROS_${OPENSTACK_BRANCH}} ${image} ${net_id} = OpenStackOperations.Get Net Id ${net_name} - : FOR ${vm} IN @{vm_instance_names} - \ ${output} = OpenStack CLI openstack server create --image ${image} --flavor ${flavor} --nic net-id=${net_id} ${vm} --security-group ${sg} --min ${min} --max ${max} + FOR ${vm} IN @{vm_instance_names} + ${output} = OpenStack CLI openstack server create --image ${image} --flavor ${flavor} --nic net-id=${net_id} ${vm} --security-group ${sg} --min ${min} --max ${max} + END Create Vm Instance On Compute Node [Arguments] ${net_name} ${vm_name} ${node_hostname} ${image}=${EMPTY} ${flavor}=m1.nano ${sg}=default @@ -345,9 +387,10 @@ Check If Instance Is Ready For Ssh Login Using PublicKey BuiltIn.Should Contain ${output} ${vm_ip} Check If Instance Is Ready For Ssh Login Using Password - [Arguments] ${net_name} ${vm_ip} ${user}=cirros ${console}=cirros + [Arguments] ${net_name} ${vm_ip} ${user}=cirros ${password}=cubswin:) ${console}=cirros [Documentation] Ensure the VM is reachable from ssh as tests would require. This keyword will use password authentication - ${output} = Execute Command on VM Instance ${net_name} ${vm_ip} ifconfig console=${console} + ${output} = Execute Command on VM Instance ${net_name} ${vm_ip} ifconfig ${user} ${password} + ... console=${console} BuiltIn.Should Contain ${output} ${vm_ip} Get VM IPs @@ -359,22 +402,34 @@ Get VM IPs ... TODO: there is a potential issue for a caller that passes in VMs belonging to different networks that ... may have different dhcp server addresses. Not sure what TODO about that, but noting it here for reference. @{vm_ips} BuiltIn.Create List @{EMPTY} - : FOR ${vm} IN @{vms} - \ OpenStackOperations.Poll VM Is ACTIVE ${vm} - \ ${status} ${ips_and_console_log} BuiltIn.Run Keyword And Ignore Error BuiltIn.Wait Until Keyword Succeeds 180s 15s - \ ... OpenStackOperations.Get VM IP true ${vm} - \ # If there is trouble with Get VM IP, the status will be FAIL and the return value will be a string of what went - \ # wrong. We need to handle both the PASS and FAIL cases. In the FAIL case we know we wont have access to the - \ # console log, as it would not be returned; so we need to grab it again to log it. We also can append 'None' to - \ # the vm ip list if status is FAIL. - \ BuiltIn.Run Keyword If "${status}" == "PASS" BuiltIn.Log ${ips_and_console_log[2]} - \ BuiltIn.Run Keyword If "${status}" == "PASS" Collections.Append To List ${vm_ips} ${ips_and_console_log[0]} - \ BuiltIn.Run Keyword If "${status}" == "FAIL" Collections.Append To List ${vm_ips} None - \ ${vm_console_output} = BuiltIn.Run Keyword If "${status}" == "FAIL" OpenStack CLI openstack console log show ${vm} - \ BuiltIn.Run Keyword If "${status}" == "FAIL" BuiltIn.Log ${vm_console_output} + FOR ${vm} IN @{vms} + OpenStackOperations.Poll VM Is ACTIVE ${vm} + ${status} ${ips_and_console_log} BuiltIn.Run Keyword And Ignore Error BuiltIn.Wait Until Keyword Succeeds 180s 15s + ... OpenStackOperations.Get VM IP true ${vm} + # If there is trouble with Get VM IP, the status will be FAIL and the return value will be a string of what went + # wrong. We need to handle both the PASS and FAIL cases. In the FAIL case we know we wont have access to the + # console log, as it would not be returned; so we need to grab it again to log it. We also can append 'None' to + # the vm ip list if status is FAIL. + BuiltIn.Run Keyword If "${status}" == "PASS" BuiltIn.Log ${ips_and_console_log[2]} + BuiltIn.Run Keyword If "${status}" == "PASS" Collections.Append To List ${vm_ips} ${ips_and_console_log[0]} + BuiltIn.Run Keyword If "${status}" == "FAIL" Collections.Append To List ${vm_ips} None + ${vm_console_output} = BuiltIn.Run Keyword If "${status}" == "FAIL" OpenStack CLI openstack console log show ${vm} + BuiltIn.Run Keyword If "${status}" == "FAIL" BuiltIn.Log ${vm_console_output} + END OpenStackOperations.Copy DHCP Files From Control Node [Return] @{vm_ips} ${ips_and_console_log[1]} +Get All VM IP Addresses + [Arguments] ${conn_id} ${vm_name} + [Documentation] Show information of a given two port VM and grep for two ip address. VM name should be sent as arguments. + SSHLibrary.Switch Connection ${conn_id} + ${cmd} = BuiltIn.Set Variable openstack server show ${vm_name} + ${output} = OpenStackOperations.OpenStack CLI ${cmd} + BuiltIn.Log ${output} + ${address_output} = OpenStackOperations.OpenStack CLI ${cmd} | grep "addresses" | awk '{print $4$5}' + @{vm_ips} = String.Get Regexp Matches ${address_output} ${REGEX_IPV4} + [Return] @{vm_ips} + Get Subnet Gateway Ip [Arguments] ${subnet_name} [Documentation] Show information of a subnet and grep for subnet gateway ip address @@ -392,25 +447,27 @@ Collect VM IPv6 SLAAC Addresses ... Returns an empty list if no IPv6 addresses found or if SSH connection fails. ... Otherwise, returns a list of IPv6 addresses. ${ipv6_list} = BuiltIn.Create List @{EMPTY} - : FOR ${vm} IN @{vm_list} - \ ${output} = OpenStack CLI openstack server show ${vm} -f shell - \ ${pattern} = String.Replace String ${subnet} ::/64 (:[a-f0-9]{,4}){,4} - \ @{vm_ipv6} = String.Get Regexp Matches ${output} ${pattern} - \ ${vm_ip_length} = BuiltIn.Get Length ${vm_ipv6}[0] - \ ${ipv6_data_from_vm} = BuiltIn.Run Keyword If ${vm_ip_length}>0 OpenStackOperations.Execute Command on VM Instance ${network} ${vm_ipv6[0]} - \ ... ip -6 a - \ @{ipv6} = String.Get Regexp Matches ${ipv6_data_from_vm} ${pattern} - \ ${ipv6_addr_list_length} BuiltIn.Get Length @{ipv6} - \ BuiltIn.Run Keyword If ${ipv6_addr_list_length}>0 Collections.Append To List ${ipv6_list} ${ipv6[0]} - \ ... ELSE Collections.Append To List ${ipv6_list} None + FOR ${vm} IN @{vm_list} + ${output} = OpenStack CLI openstack server show ${vm} -f shell + ${pattern} = String.Replace String ${subnet} ::/64 (:[a-f0-9]{,4}){,4} + @{vm_ipv6} = String.Get Regexp Matches ${output} ${pattern} + ${vm_ip_length} = BuiltIn.Get Length ${vm_ipv6}[0] + ${ipv6_data_from_vm} = BuiltIn.Run Keyword If ${vm_ip_length}>0 OpenStackOperations.Execute Command on VM Instance ${network} ${vm_ipv6[0]} + ... ip -6 a + @{ipv6} = String.Get Regexp Matches ${ipv6_data_from_vm} ${pattern} + ${ipv6_addr_list_length} BuiltIn.Get Length @{ipv6} + BuiltIn.Run Keyword If ${ipv6_addr_list_length}>0 Collections.Append To List ${ipv6_list} ${ipv6[0]} + ... ELSE Collections.Append To List ${ipv6_list} None + END [Return] ${ipv6_list} View Vm Console [Arguments] ${vm_instance_names} [Documentation] View Console log of the created vm instances using nova show. - : FOR ${vm} IN @{vm_instance_names} - \ ${output} = OpenStack CLI openstack server show ${vm} - \ ${output} = OpenStack CLI openstack console log show ${vm} + FOR ${vm} IN @{vm_instance_names} + ${output} = OpenStack CLI openstack server show ${vm} + ${output} = OpenStack CLI openstack console log show ${vm} + END Ping Vm From DHCP Namespace [Arguments] ${net_name} ${vm_ip} @@ -459,11 +516,13 @@ Exit From Vm Console BuiltIn.Run Keyword If ${rcode} DevstackUtils.Write Commands Until Prompt exit Check Ping - [Arguments] ${ip_address} ${ttl}=64 + [Arguments] ${ip_address} ${ttl}=64 ${ping_tries}=3 [Documentation] Run Ping command on the IP available as argument ${ethertype} = String.Get Regexp Matches ${ip_address} ${IP_REGEX} - ${output} = BuiltIn.Run Keyword If ${ethertype} Utils.Write Commands Until Expected Prompt ping -t ${ttl} -c 3 ${ip_address} ${OS_SYSTEM_PROMPT} - ... ELSE Utils.Write Commands Until Expected Prompt ping6 -t ${ttl} -c 3 ${ip_address} ${OS_SYSTEM_PROMPT} + ${ping} = BuiltIn.Set Variable If ${ethertype} ping ping6 + ${cmd} = BuiltIn.Set Variable rc=0; for count in `seq 1 ${ping_tries}`; do ${ping} -W1 -t${ttl} -c1 ${ip_address}; rc=$?; if [ $rc -eq 0 ]; then break; fi; done; echo ping_rc=$rc + ${output} = Utils.Write Commands Until Expected Regexp ${cmd} ping_rc=\\d+ 120 + BuiltIn.Log output: ${output} BuiltIn.Should Contain ${output} 64 bytes Check No Ping @@ -511,7 +570,7 @@ Copy File To VM Instance With PublicKey Auth Test Operations From Vm Instance [Arguments] ${net_name} ${src_ip} ${dest_ips} ${user}=cirros ${password}=cubswin:) ${ttl}=64 - ... ${ping_should_succeed}=True ${check_metadata}=True ${console}=cirros + ... ${ping_should_succeed}=True ${check_metadata}=True ${console}=cirros ${ping_tries}=3 [Documentation] Login to the vm instance using ssh in the network. OpenStackOperations.Get ControlNode Connection ${net_id} = OpenStackOperations.Get Net Id ${net_name} @@ -523,11 +582,12 @@ Test Operations From Vm Instance BuiltIn.Run Keyword If ${rcode} Utils.Write Commands Until Expected Prompt route -A inet6 ${OS_SYSTEM_PROMPT} BuiltIn.Run Keyword If ${rcode} Utils.Write Commands Until Expected Prompt arp -an ${OS_SYSTEM_PROMPT} BuiltIn.Run Keyword If ${rcode} Utils.Write Commands Until Expected Prompt ip -f inet6 neigh show ${OS_SYSTEM_PROMPT} - : FOR ${dest_ip} IN @{dest_ips} - \ ${string_empty} = BuiltIn.Run Keyword And Return Status Should Be Empty ${dest_ip} - \ BuiltIn.Run Keyword If ${string_empty} Continue For Loop - \ BuiltIn.Run Keyword If ${rcode} and "${ping_should_succeed}" == "True" OpenStackOperations.Check Ping ${dest_ip} ttl=${ttl} - \ ... ELSE OpenStackOperations.Check No Ping ${dest_ip} ttl=${ttl} + FOR ${dest_ip} IN @{dest_ips} + ${string_empty} = BuiltIn.Run Keyword And Return Status Should Be Empty ${dest_ip} + BuiltIn.Run Keyword If ${string_empty} Continue For Loop + BuiltIn.Run Keyword If ${rcode} and "${ping_should_succeed}" == "True" OpenStackOperations.Check Ping ${dest_ip} ttl=${ttl} ping_tries=${ping_tries} + ... ELSE OpenStackOperations.Check No Ping ${dest_ip} ttl=${ttl} + END ${ethertype} = String.Get Regexp Matches ${src_ip} ${IP_REGEX} BuiltIn.Run Keyword If ${rcode} and "${check_metadata}" and ${ethertype} == "True" OpenStackOperations.Check Metadata Access [Teardown] Exit From Vm Console ${console} @@ -553,8 +613,9 @@ Ping Other Instances [Arguments] ${list_of_external_dst_ips} ${console}=cirros [Documentation] Check reachability with other network's instances. ${rcode} = BuiltIn.Run Keyword And Return Status OpenStackOperations.Check If Console Is VmInstance ${console} - : FOR ${dest_ip} IN @{list_of_external_dst_ips} - \ OpenStackOperations.Check Ping ${dest_ip} + FOR ${dest_ip} IN @{list_of_external_dst_ips} + OpenStackOperations.Check Ping ${dest_ip} + END Create Router [Arguments] ${router_name} @@ -616,10 +677,11 @@ Get DumpFlows And Ovsconfig Utils.Write Commands Until Expected Prompt arp -an ${DEFAULT_LINUX_PROMPT_STRICT} ${nslist} = Utils.Write Commands Until Expected Prompt ip netns list | awk '{print $1}' ${DEFAULT_LINUX_PROMPT_STRICT} @{lines} Split To Lines ${nslist} end=-1 - : FOR ${line} IN @{lines} - \ Utils.Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o link ${DEFAULT_LINUX_PROMPT_STRICT} - \ Utils.Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o addr ${DEFAULT_LINUX_PROMPT_STRICT} - \ Utils.Write Commands Until Expected Prompt sudo ip netns exec ${line} ip route ${DEFAULT_LINUX_PROMPT_STRICT} + FOR ${line} IN @{lines} + Utils.Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o link ${DEFAULT_LINUX_PROMPT_STRICT} + Utils.Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o addr ${DEFAULT_LINUX_PROMPT_STRICT} + Utils.Write Commands Until Expected Prompt sudo ip netns exec ${line} ip route ${DEFAULT_LINUX_PROMPT_STRICT} + END Utils.Write Commands Until Expected Prompt sudo ovs-vsctl show ${DEFAULT_LINUX_PROMPT_STRICT} Utils.Write Commands Until Expected Prompt sudo ovs-vsctl list Open_vSwitch ${DEFAULT_LINUX_PROMPT_STRICT} Utils.Write Commands Until Expected Prompt sudo ovs-ofctl show ${INTEGRATION_BRIDGE} -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT} @@ -633,8 +695,9 @@ Get ControlNode Connection Get OvsDebugInfo [Documentation] Get the OvsConfig and Flow entries from all Openstack nodes - : FOR ${conn_id} IN @{OS_ALL_CONN_IDS} - \ OpenStackOperations.Get DumpFlows And Ovsconfig ${conn_id} + FOR ${conn_id} IN @{OS_ALL_CONN_IDS} + OpenStackOperations.Get DumpFlows And Ovsconfig ${conn_id} + END Get Test Teardown Debugs [Arguments] ${test_name}=${SUITE_NAME}.${TEST_NAME} ${fail}=${FAIL_ON_EXCEPTIONS} @@ -642,8 +705,9 @@ Get Test Teardown Debugs OpenStackOperations.Get OvsDebugInfo BuiltIn.Run Keyword And Ignore Error DataModels.Get Model Dump ${HA_PROXY_IP} ${netvirt_data_models} KarafKeywords.Fail If Exceptions Found During Test ${test_name} fail=${fail} - : FOR ${i} IN RANGE ${NUM_ODL_SYSTEM} - \ BuiltIn.Run Keyword And Ignore Error Issue_Command_On_Karaf_Console trace:transactions ${ODL_SYSTEM_${i+1}_IP} + FOR ${i} IN RANGE ${NUM_ODL_SYSTEM} + BuiltIn.Run Keyword And Ignore Error Issue_Command_On_Karaf_Console trace:transactions ${ODL_SYSTEM_${i+1}_IP} + END Get Suite Debugs Get Test Teardown Debugs test_name=${SUITE_NAME} fail=False @@ -657,9 +721,10 @@ Show Debugs [Documentation] Run these commands for debugging, it can list state of VM instances and ip information in control node OpenStackOperations.Get ControlNode Connection ${output} = DevstackUtils.Write Commands Until Prompt And Log sudo ip netns list - : FOR ${index} IN @{vm_indices} - \ ${rc} ${output} = OperatingSystem.Run And Return Rc And Output nova show ${index} - \ BuiltIn.Log ${output} + FOR ${index} IN @{vm_indices} + ${rc} ${output} = OperatingSystem.Run And Return Rc And Output nova show ${index} + BuiltIn.Log ${output} + END OpenStackOperations.List Nova VMs OpenStackOperations.List Routers OpenStackOperations.List Networks @@ -716,6 +781,7 @@ Neutron Security Group Rule Create ${protocol} BuiltIn.Run Keyword If ${Kwargs} Collections.Pop From Dictionary ${Kwargs} protocol default=${None} ${remote_group_id} BuiltIn.Run Keyword If ${Kwargs} Collections.Pop From Dictionary ${Kwargs} remote_group_id default=${None} ${remote_ip_prefix} BuiltIn.Run Keyword If ${Kwargs} Collections.Pop From Dictionary ${Kwargs} remote_ip_prefix default=${None} + ${remote_ip} BuiltIn.Run Keyword If ${Kwargs} Collections.Pop From Dictionary ${Kwargs} remote_ip default=${None} ${cmd} = BuiltIn.Set Variable openstack security group rule create ${Security_group_name} ${cmd} = BuiltIn.Run Keyword If '${description}'!='None' BuiltIn.Catenate ${cmd} --description ${description} ... ELSE BuiltIn.Catenate ${cmd} @@ -733,6 +799,8 @@ Neutron Security Group Rule Create ... ELSE BuiltIn.Catenate ${cmd} ${cmd} = BuiltIn.Run Keyword If '${remote_ip_prefix}'!='None' BuiltIn.Catenate ${cmd} --src-ip ${remote_ip_prefix} ... ELSE BuiltIn.Catenate ${cmd} + ${cmd} = BuiltIn.Run Keyword If '${remote_ip}'!='None' BuiltIn.Catenate ${cmd} --remote-ip ${remote_ip} + ... ELSE BuiltIn.Catenate ${cmd} ${output} = OpenStack CLI ${cmd} ${rule_id} = BuiltIn.Should Match Regexp ${output} ${REGEX_UUID} [Return] ${output} ${rule_id} @@ -748,8 +816,9 @@ Delete All Security Group Rules [Documentation] Delete all security rules from a specified security group ${sg_rules_output} = OpenStack CLI openstack security group rule list ${sg_name} -cID -fvalue @{sg_rules} = String.Split String ${sg_rules_output} \n - : FOR ${rule} IN @{sg_rules} - \ ${output} = OpenStack CLI openstack security group rule delete ${rule} + FOR ${rule} IN @{sg_rules} + ${output} = OpenStack CLI openstack security group rule delete ${rule} + END Create Allow All SecurityGroup [Arguments] ${sg_name} ${ether_type}=IPv4 ${dual}=False @@ -785,9 +854,10 @@ Get Ports MacAddr [Arguments] ${ports} [Documentation] Retrieve the port MacAddr for the given list of port name and return the MAC address list. ${macs} BuiltIn.Create List - : FOR ${port} IN @{ports} - \ ${mac} = OpenStackOperations.Get Port Mac ${port} - \ Collections.Append To List ${macs} ${mac} + FOR ${port} IN @{ports} + ${mac} = OpenStackOperations.Get Port Mac ${port} + Collections.Append To List ${macs} ${mac} + END [Return] ${macs} Get Port Ip @@ -1021,33 +1091,40 @@ Wait For Routes To Propogate [Arguments] ${networks} ${subnets} [Documentation] Check propagated routes OpenStackOperations.Get ControlNode Connection - : FOR ${INDEX} IN RANGE 0 1 - \ ${net_id} = OpenStackOperations.Get Net Id @{networks}[${INDEX}] - \ ${is_ipv6} = String.Get Regexp Matches @{subnets}[${INDEX}] ${IP6_REGEX} - \ ${length} = BuiltIn.Get Length ${is_ipv6} - \ ${cmd} = BuiltIn.Set Variable If ${length} == 0 ip route ip -6 route - \ ${output} = Utils.Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ${cmd} ${DEFAULT_LINUX_PROMPT_STRICT} - \ BuiltIn.Should Contain ${output} @{subnets}[${INDEX}] + FOR ${INDEX} IN RANGE 0 1 + ${net_id} = OpenStackOperations.Get Net Id @{networks}[${INDEX}] + ${is_ipv6} = String.Get Regexp Matches @{subnets}[${INDEX}] ${IP6_REGEX} + ${length} = BuiltIn.Get Length ${is_ipv6} + ${cmd} = BuiltIn.Set Variable If ${length} == 0 ip route ip -6 route + ${output} = Utils.Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ${cmd} ${DEFAULT_LINUX_PROMPT_STRICT} + BuiltIn.Should Contain ${output} @{subnets}[${INDEX}] + END Neutron Cleanup [Arguments] ${vms}=@{EMPTY} ${networks}=@{EMPTY} ${subnets}=@{EMPTY} ${ports}=@{EMPTY} ${sgs}=@{EMPTY} - : FOR ${vm} IN @{vms} - \ BuiltIn.Run Keyword And Ignore Error Delete Vm Instance ${vm} - : FOR ${port} IN @{ports} - \ BuiltIn.Run Keyword And Ignore Error Delete Port ${port} - : FOR ${subnet} IN @{subnets} - \ BuiltIn.Run Keyword And Ignore Error Delete SubNet ${subnet} - : FOR ${network} IN @{networks} - \ BuiltIn.Run Keyword And Ignore Error Delete Network ${network} - : FOR ${sg} IN @{sgs} - \ BuiltIn.Run Keyword And Ignore Error Delete SecurityGroup ${sg} + FOR ${vm} IN @{vms} + BuiltIn.Run Keyword And Ignore Error Delete Vm Instance ${vm} + END + FOR ${port} IN @{ports} + BuiltIn.Run Keyword And Ignore Error Delete Port ${port} + END + FOR ${subnet} IN @{subnets} + BuiltIn.Run Keyword And Ignore Error Delete SubNet ${subnet} + END + FOR ${network} IN @{networks} + BuiltIn.Run Keyword And Ignore Error Delete Network ${network} + END + FOR ${sg} IN @{sgs} + BuiltIn.Run Keyword And Ignore Error Delete SecurityGroup ${sg} + END OpenStack List All [Documentation] Get a list of different OpenStack resources that might be in use. @{modules} = BuiltIn.Create List server port network subnet security group ... security group rule floating ip router - : FOR ${module} IN @{modules} - \ ${output} = OpenStack CLI openstack ${module} list + FOR ${module} IN @{modules} + ${output} = OpenStack CLI openstack ${module} list + END OpenStack CLI Get List [Arguments] ${cmd} @@ -1078,35 +1155,42 @@ OpenStack Cleanup All [Documentation] Cleanup all Openstack resources with best effort. The keyword will query for all resources ... in use and then attempt to delete them. Errors are ignored to allow the cleanup to continue. @{fips} = OpenStack CLI Get List openstack floating ip list -f json - : FOR ${fip} IN @{fips} - \ BuiltIn.Run Keyword And Ignore Error Delete Floating IP ${fip['ID']} + FOR ${fip} IN @{fips} + BuiltIn.Run Keyword And Ignore Error Delete Floating IP ${fip['ID']} + END @{vms} = OpenStack CLI Get List openstack server list -f json - : FOR ${vm} IN @{vms} - \ OpenStack CLI openstack server show ${vm['ID']} - \ BuiltIn.Run Keyword And Ignore Error Delete Vm Instance ${vm['ID']} + FOR ${vm} IN @{vms} + OpenStack CLI openstack server show ${vm['ID']} + BuiltIn.Run Keyword And Ignore Error Delete Vm Instance ${vm['ID']} + END @{routers} = OpenStack CLI Get List openstack router list -f json - : FOR ${router} IN @{routers} - \ BuiltIn.Run Keyword And Ignore Error Cleanup Router ${router['ID']} + FOR ${router} IN @{routers} + BuiltIn.Run Keyword And Ignore Error Cleanup Router ${router['ID']} + END @{ports} = OpenStack CLI Get List openstack port list -f json - : FOR ${port} IN @{ports} - \ BuiltIn.Run Keyword And Ignore Error Delete Port ${port['ID']} + FOR ${port} IN @{ports} + BuiltIn.Run Keyword And Ignore Error Delete Port ${port['ID']} + END @{networks} = OpenStack CLI Get List openstack network list -f json - : FOR ${network} IN @{networks} - \ BuiltIn.Run Keyword And Ignore Error Delete Subnet ${network['Subnets']} - \ BuiltIn.Run Keyword And Ignore Error Delete Network ${network['ID']} + FOR ${network} IN @{networks} + BuiltIn.Run Keyword And Ignore Error Delete Subnet ${network['Subnets']} + BuiltIn.Run Keyword And Ignore Error Delete Network ${network['ID']} + END @{security_groups} = OpenStack CLI Get List openstack security group list -f json - : FOR ${security_group} IN @{security_groups} - \ BuiltIn.Run Keyword If "${security_group['Name']}" != "default" BuiltIn.Run Keyword And Ignore Error Delete SecurityGroup ${security_group['ID']} + FOR ${security_group} IN @{security_groups} + BuiltIn.Run Keyword If "${security_group['Name']}" != "default" BuiltIn.Run Keyword And Ignore Error Delete SecurityGroup ${security_group['ID']} + END OpenStack List All Cleanup Router [Arguments] ${id} [Documentation] Delete a router, but first remove any interfaces or gateways so that the delete will be successful. @{ports} = OpenStack CLI Get List openstack port list --router ${id} -f json --long - : FOR ${port} IN @{ports} - \ ${subnet_id} = OpenStackOperations.Get Match ${port['Fixed IP Addresses']} ${REGEX_UUID} 0 - \ BuiltIn.Run Keyword If "${port['Device Owner']}" == "network:router_gateway" BuiltIn.Run Keyword And Ignore Error Remove Gateway ${id} - \ BuiltIn.Run Keyword If "${port['Device Owner']}" == "network:router_interface" BuiltIn.Run Keyword And Ignore Error Remove Interface ${id} ${subnet_id} + FOR ${port} IN @{ports} + ${subnet_id} = OpenStackOperations.Get Match ${port['Fixed IP Addresses']} ${REGEX_UUID} 0 + BuiltIn.Run Keyword If "${port['Device Owner']}" == "network:router_gateway" BuiltIn.Run Keyword And Ignore Error Remove Gateway ${id} + BuiltIn.Run Keyword If "${port['Device Owner']}" == "network:router_interface" BuiltIn.Run Keyword And Ignore Error Remove Interface ${id} ${subnet_id} + END BuiltIn.Run Keyword And Ignore Error Delete Router ${id} OpenStack Suite Setup @@ -1132,18 +1216,20 @@ OpenStack Suite Teardown OpenStack Cleanup All OpenStackOperations.Stop Packet Capture On Nodes ${tcpdump_port_6653_conn_ids} SSHLibrary.Close All Connections - : FOR ${i} IN RANGE ${NUM_ODL_SYSTEM} - \ KarafKeywords.Issue Command On Karaf Console threads --list | wc -l ${ODL_SYSTEM_${i+1}_IP} + FOR ${i} IN RANGE ${NUM_ODL_SYSTEM} + KarafKeywords.Issue Command On Karaf Console threads --list | wc -l ${ODL_SYSTEM_${i+1}_IP} + END Validate Deployment [Documentation] Validate the deployment. Examples to validate are verifying default table ... flows are installed and that the tunnel mesh has been built correctly. Write To Validate File ----------------------------------------\n${SUITE_NAME}\n - : FOR ${keyword} IN @{VALIDATION_KEYWORDS} - \ ${status} = Builtin.Run Keyword And Return Status ${keyword} - \ BuiltIn.Run Keyword If "${status}" == "FAIL" or "${status}" == "False" BuiltIn.Run Keywords Write To Validate File Failed: ${keyword} - \ ... AND BuiltIn.Fail - \ ... ELSE Write To Validate File Passed: ${keyword} + FOR ${keyword} IN @{VALIDATION_KEYWORDS} + ${status} = Builtin.Run Keyword And Return Status ${keyword} + BuiltIn.Run Keyword If "${status}" == "FAIL" or "${status}" == "False" BuiltIn.Run Keywords Write To Validate File Failed: ${keyword} + ... AND BuiltIn.Fail + ... ELSE Write To Validate File Passed: ${keyword} + END Write To Validate File [Arguments] ${msg} @@ -1163,20 +1249,23 @@ Copy DHCP Files From Control Node Is Feature Installed [Arguments] ${features}=none - : FOR ${feature} IN @{features} - \ ${status} ${output} BuiltIn.Run Keyword And Ignore Error BuiltIn.Should Contain ${CONTROLLERFEATURES} ${feature} - \ Return From Keyword If "${status}" == "PASS" True + FOR ${feature} IN @{features} + ${status} ${output} BuiltIn.Run Keyword And Ignore Error BuiltIn.Should Contain ${CONTROLLERFEATURES} ${feature} + Return From Keyword If "${status}" == "PASS" True + END [Return] False Add OVS Logging On All OpenStack Nodes [Documentation] Add higher levels of OVS logging to all the OpenStack nodes - : FOR ${conn_id} IN @{OS_ALL_CONN_IDS} - \ OVSDB.Add OVS Logging ${conn_id} + FOR ${conn_id} IN @{OS_ALL_CONN_IDS} + OVSDB.Add OVS Logging ${conn_id} + END Reset OVS Logging On All OpenStack Nodes [Documentation] Reset the OVS logging to all the OpenStack nodes - : FOR ${conn_id} IN @{OS_ALL_CONN_IDS} - \ OVSDB.Reset OVS Logging ${conn_id} + FOR ${conn_id} IN @{OS_ALL_CONN_IDS} + OVSDB.Reset OVS Logging ${conn_id} + END Start Packet Capture On Nodes [Arguments] ${tag} ${filter} @{ips} @@ -1239,7 +1328,13 @@ Verify Services Wait Until Keyword Succeeds 60 2 ClusterManagement.Check Status Of Services Is OPERATIONAL @{NETVIRT_DIAG_SERVICES} Verify Expected Default Tunnels - [Documentation] Verify if the default tunnels are created + [Documentation] Verify if the default tunnels are created. + ... SFC jobs currently fail this validation because it uses of-tunnels. + ... This validation will be blocked for NEtvirt SFC jobs until support for of-tunnels + ... added to odltools. + ${check_feature_list} = BuiltIn.Create List odl-netvirt-sfc + ${is_sfc_enabled} = OpenStackOperations.Is Feature Installed features=${check_feature_list} + BuiltIn.Return From Keyword If ${is_sfc_enabled} == ${True} ${True} BuiltIn.Return From Keyword If ${OS_NODE_CNT} == ${1} ${True} ${output} = ODLTools.Analyze Tunnels test_name=${SUITE_NAME}.Suite Setup BuiltIn.Should Contain ${output} All tunnels are up @@ -1250,10 +1345,11 @@ Verify Expected Default Tables On Nodes ${resp} = RequestsLibrary.Get Request session ${CONFIG_NODES_API} Utils.Log Content ${resp.content} ${failed_node_list} = BuiltIn.Create List - : FOR ${node_ip} IN @{node_ips} - \ ${failed_table_list} = Verify Expected Default Tables ${node_ip} - \ ${failed_table_list_size} = BuiltIn.Get Length ${failed_table_list} - \ BuiltIn.Run Keyword If ${failed_table_list_size} > 0 Collections.Append To List ${failed_node_list} ${node_ip} + FOR ${node_ip} IN @{node_ips} + ${failed_table_list} = Verify Expected Default Tables ${node_ip} + ${failed_table_list_size} = BuiltIn.Get Length ${failed_table_list} + BuiltIn.Run Keyword If ${failed_table_list_size} > 0 Collections.Append To List ${failed_node_list} ${node_ip} + END Builtin.Should Be Empty ${failed_node_list} Verify Expected Default Tables @@ -1262,9 +1358,10 @@ Verify Expected Default Tables ${flow_dump} = Utils.Run Command On Remote System ${ovs_ip} sudo ovs-ofctl dump-flows ${INTEGRATION_BRIDGE} -OOpenFlow13 BuiltIn.Log ${flow_dump} ${failed_table_list} = BuiltIn.Create List - : FOR ${table} IN @{DEFAULT_FLOW_TABLES} - \ ${rc} = Builtin.Run Keyword And Return Status Builtin.Should Not Match Regexp ${flow_dump} .*table=${table}.*priority=0 - \ BuiltIn.Run Keyword If ${rc} Collections.Append To List ${failed_table_list} ${table} + FOR ${table} IN @{DEFAULT_FLOW_TABLES} + ${rc} = Builtin.Run Keyword And Return Status Builtin.Should Not Match Regexp ${flow_dump} .*table=${table}.*priority=0 + BuiltIn.Run Keyword If ${rc} Collections.Append To List ${failed_table_list} ${table} + END [Return] ${failed_table_list} Get Project Id @@ -1278,3 +1375,28 @@ Set Instance Quota For Project [Documentation] Set quota for the created instances using the specific project id. ${output} = OpenStack CLI openstack quota set --instances ${num_instances} ${project_id} [Return] ${output} + +Create Bgpvpn + [Arguments] ${vpnname} ${additional_args}=${EMPTY} + [Documentation] Create Bgpvpn with neutron request. + ${output} = OpenStack CLI openstack bgpvpn create --name ${vpnname} ${additional_args} + +Get BgpVpn Id + [Arguments] ${vpnName} + [Documentation] Retrieve the bgpvpn id for the given bgpvpn name + ${output} = OpenStack CLI openstack bgpvpn show ${vpnName} | grep " ID" | awk '{print $4}' + ${splitted_output} = String.Split String ${output} ${EMPTY} + ${vpn_id} = Collections.Get from List ${splitted_output} 0 + [Return] ${vpn_id} + +Configure_IP_On_Sub_Interface + [Arguments] ${network_name} ${ip} ${vm_ip} ${mask} ${sub_interface_state}=${EMPTY} ${interface}=eth0 + ... ${sub_interface_number}=1 + [Documentation] Keyword for configuring specified IP on specified interface and the corresponding specified sub interface + OpenStackOperations.Execute Command on VM Instance ${network_name} ${vm_ip} sudo ifconfig ${interface}:${sub_interface_number} ${ip} netmask ${mask} ${sub_interface_state} + +Verify_IP_Configured_On_Sub_Interface + [Arguments] ${network_name} ${ip} ${vm_ip} ${interface}=eth0 ${sub_interface_number}=1 + [Documentation] Keyword for verifying specified IP on specified interface and the corresponding specified sub interface + ${resp} = OpenStackOperations.Execute Command on VM Instance ${network_name} ${vm_ip} sudo ifconfig ${interface}:${sub_interface_number} + BuiltIn.Should Contain ${resp} ${ip}