X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=csit%2Flibraries%2FOpenStackOperations.robot;h=b43ee7aeaeb3f990f376a6525a7f9cc837defe9c;hb=09a995a3a18ba1e05da0a5fe74d5a358d06da31e;hp=cc6003c0012730f9c1ae831540be858d65c39a39;hpb=5127b9d620eb3fec11fd3d82191af08b9ed8603e;p=integration%2Ftest.git diff --git a/csit/libraries/OpenStackOperations.robot b/csit/libraries/OpenStackOperations.robot index cc6003c001..b43ee7aeae 100644 --- a/csit/libraries/OpenStackOperations.robot +++ b/csit/libraries/OpenStackOperations.robot @@ -1,13 +1,16 @@ *** Settings *** Documentation Openstack library. This library is useful for tests to create network, subnet, router and vm instances Library Collections +Library Process Library OperatingSystem Library RequestsLibrary Library SSHLibrary Library String Resource DataModels.robot Resource DevstackUtils.robot +Resource KarafKeywords.robot Resource L2GatewayOperations.robot +Resource ODLTools.robot Resource OVSDB.robot Resource SetupUtils.robot Resource SSHKeywords.robot @@ -32,17 +35,14 @@ Get Tenant ID From Network Create Network [Arguments] ${network_name} ${additional_args}=${EMPTY} ${verbose}=TRUE - [Documentation] Create Network with neutron request. + [Documentation] Create Network with openstack request. ${output} = OpenStack CLI openstack network create ${network_name} ${additional_args} [Return] ${output} Update Network [Arguments] ${network_name} ${additional_args}=${EMPTY} [Documentation] Update Network with neutron request. - ${cmd} = BuiltIn.Set Variable If '${OPENSTACK_BRANCH}'=='stable/newton' neutron -v net-update ${network_name} ${additional_args} openstack network set ${network_name} ${additional_args} - ${rc} ${output} = OperatingSystem.Run And Return Rc And Output ${cmd} - BuiltIn.Log ${output} - BuiltIn.Should Be True '${rc}' == '0' + ${output} = OpenStack CLI openstack network set ${network_name} ${additional_args} [Return] ${output} Show Network @@ -73,11 +73,14 @@ Create SubNet Update SubNet [Arguments] ${subnet_name} ${additional_args}=${EMPTY} - [Documentation] Update subnet with neutron request. - ${cmd} = BuiltIn.Set Variable If '${OPENSTACK_BRANCH}'=='stable/newton' neutron -v subnet-update ${subnet_name} ${additional_args} openstack subnet set ${subnet_name} ${additional_args} - ${rc} ${output} = OperatingSystem.Run And Return Rc And Output ${cmd} - BuiltIn.Log ${output} - BuiltIn.Should Be True '${rc}' == '0' + [Documentation] Update subnet with openstack subnet set request. + ${output} = OpenStack CLI openstack subnet set ${subnet_name} ${additional_args} + [Return] ${output} + +Unset SubNet + [Arguments] ${subnet_name} ${additional_args}=${EMPTY} + [Documentation] Update subnet with openstack subnet unset request + ${output} = OpenStack CLI openstack subnet unset ${subnet_name} ${additional_args} [Return] ${output} Show SubNet @@ -92,13 +95,9 @@ Create Port # if allowed_address_pairs is not empty we need to create the arguments to pass to the port create command. They are # in a different format with the neutron vs openstack cli. ${address_pair_length} = BuiltIn.Get Length ${allowed_address_pairs} - ${allowed_pairs_argv} = BuiltIn.Set Variable If '${OPENSTACK_BRANCH}'=='stable/newton' and '${address_pair_length}'=='2' --allowed-address-pairs type=dict list=true ip_address=@{allowed_address_pairs}[0] ip_address=@{allowed_address_pairs}[1] - ${allowed_pairs_argv} = BuiltIn.Set Variable If '${OPENSTACK_BRANCH}'!='stable/newton' and '${address_pair_length}'=='2' --allowed-address ip-address=@{allowed_address_pairs}[0] --allowed-address ip-address=@{allowed_address_pairs}[1] ${allowed_pairs_argv} - ${allowed_pairs_argv} = BuiltIn.Set Variable If '${address_pair_length}'=='0' ${EMPTY} ${allowed_pairs_argv} - ${cmd} = BuiltIn.Set Variable If '${OPENSTACK_BRANCH}'=='stable/newton' neutron -v port-create ${network_name} --name ${port_name} --security-group ${sg} ${additional_args} ${allowed_pairs_argv} openstack port create --network ${network_name} ${port_name} --security-group ${sg} ${additional_args} ${allowed_pairs_argv} - ${rc} ${output} = OperatingSystem.Run And Return Rc And Output ${cmd} - BuiltIn.Log ${output} - BuiltIn.Should Be True '${rc}' == '0' + ${allowed_pairs_argv} = BuiltIn.Set Variable ${EMPTY} + ${allowed_pairs_argv} = BuiltIn.Set Variable If '${address_pair_length}'=='2' --allowed-address ip-address=@{allowed_address_pairs}[0] --allowed-address ip-address=@{allowed_address_pairs}[1] ${allowed_pairs_argv} + ${output} = OpenStack CLI openstack port create --network ${network_name} ${port_name} --security-group ${sg} ${additional_args} ${allowed_pairs_argv} Update Port [Arguments] ${port_name} ${additional_args}=${EMPTY} @@ -140,6 +139,11 @@ Create And Associate Floating IPs \ ${output} = OpenStack CLI openstack server add floating ip ${vm} @{ip}[0] [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} + Delete Floating IP [Arguments] ${fip} [Documentation] Delete floating ip with neutron request. @@ -179,6 +183,14 @@ Get Port Id ${port_id} = Collections.Get from List ${splitted_output} 0 [Return] ${port_id} +Get Sub Port Id + [Arguments] ${portname} + [Documentation] Retrieve the first 10 chars of the UUID for the given port name + ${port_id} = OpenStackOperations.Get Port Id ${portname} + ${output} = String.Get Regexp Matches ${port_id} \\w{8}-\\w{2} + ${subport_id} = Collections.Get from List ${output} 0 + [Return] ${subport_id} + Get Router Id [Arguments] ${router1} [Documentation] Retrieve the router id for the given router name @@ -297,6 +309,15 @@ Get VM IPs OpenStackOperations.Copy DHCP Files From Control Node [Return] @{vm_ips} ${ips_and_console_log[1]} +Get Subnet Gateway Ip + [Arguments] ${subnet_name} + [Documentation] Show information of a subnet and grep for subnet gateway ip address + ${output} = OpenStackOperations.OpenStack CLI openstack subnet show ${subnet_name} | grep gateway_ip | awk '{print $4}' + ${splitted_output} = String.Split String ${output} ${EMPTY} + ${matches} = Collections.Get Matches ${splitted_output} regexp=(\\d\.)+ + ${subnet_gateway_ip} = String.Strip String ${matches[0]} characters=',' + [Return] ${subnet_gateway_ip} + Collect VM IPv6 SLAAC Addresses [Arguments] ${fail_on_none} ${vm_list} ${network} ${subnet} [Documentation] For each VM parse output of "openstack server show" to get its IPv6 address from Neutron DB. @@ -469,10 +490,8 @@ Show Router Interface [Return] ${output} Add Router Gateway - [Arguments] ${router_name} ${external_network_name} - ${cmd} = BuiltIn.Set Variable If '${OPENSTACK_BRANCH}'=='stable/newton' neutron -v router-gateway-set ${router_name} ${external_network_name} openstack router set ${router_name} --external-gateway ${external_network_name} - ${rc} ${output} = OperatingSystem.Run And Return Rc And Output ${cmd} - BuiltIn.Should Be True '${rc}' == '0' + [Arguments] ${router_name} ${external_network_name} ${additional_args}=${EMPTY} + ${output} = OpenStack CLI openstack router set ${router_name} --external-gateway ${external_network_name} ${additional_args} Remove Interface [Arguments] ${router_name} ${interface_name} @@ -482,7 +501,7 @@ Remove Interface Remove Gateway [Arguments] ${router_name} [Documentation] Remove external gateway from the router. - BuiltIn.Log openstack router unset ${router_name} --external-gateway + ${output} = OpenStack CLI openstack router unset ${router_name} --external-gateway Update Router [Arguments] ${router_name} ${cmd} @@ -490,9 +509,10 @@ Update Router ${output} = OpenStack CLI openstack router set ${router_name} ${cmd} Show Router - [Arguments] ${router_name} ${options} + [Arguments] ${router_name} ${additional_args}=${EMPTY} [Documentation] Show information of a given router. Router name and optional fields should be sent as arguments. - ${output} = OpenStack CLI openstack router show ${router_name} + ${output} = OpenStack CLI openstack router show ${router_name} ${additional_args} + [Return] ${output} Delete Router [Arguments] ${router_name} @@ -515,31 +535,10 @@ Get DumpFlows And Ovsconfig \ Utils.Write Commands Until Expected Prompt sudo ip netns exec ${line} ip route ${DEFAULT_LINUX_PROMPT_STRICT} 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 br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT} - Utils.Write Commands Until Expected Prompt sudo ovs-ofctl dump-flows br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT} - Utils.Write Commands Until Expected Prompt sudo ovs-ofctl dump-groups br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT} - Utils.Write Commands Until Expected Prompt sudo ovs-ofctl dump-group-stats br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT} - -Get Karaf Log Type From Test Start - [Arguments] ${ip} ${test_name} ${type} ${user}=${ODL_SYSTEM_USER} ${password}=${ODL_SYSTEM_PASSWORD} ${prompt}=${ODL_SYSTEM_PROMPT} - ... ${log_file}=${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log - ${cmd} = BuiltIn.Set Variable sed '1,/ROBOT MESSAGE: Starting test ${test_name}/d' ${log_file} | grep '${type}' - ${output} = Utils.Run Command On Controller ${ip} ${cmd} ${user} ${password} ${prompt} - [Return] ${output} - -Get Karaf Log Types From Test Start - [Arguments] ${ip} ${test_name} ${types} ${user}=${ODL_SYSTEM_USER} ${password}=${ODL_SYSTEM_PASSWORD} ${prompt}=${ODL_SYSTEM_PROMPT} - ... ${log_file}=${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log - : FOR ${type} IN @{types} - \ OpenStackOperations.Get Karaf Log Type From Test Start ${ip} ${test_name} ${type} ${user} ${password} - \ ... ${prompt} ${log_file} - -Get Karaf Log Events From Test Start - [Arguments] ${test_name} ${user}=${ODL_SYSTEM_USER} ${password}=${ODL_SYSTEM_PASSWORD} ${prompt}=${ODL_SYSTEM_PROMPT} - ${log_types} = BuiltIn.Create List ERROR WARN Exception - BuiltIn.Run Keyword If 0 < ${NUM_ODL_SYSTEM} OpenStackOperations.Get Karaf Log Types From Test Start ${ODL_SYSTEM_IP} ${test_name} ${log_types} - BuiltIn.Run Keyword If 1 < ${NUM_ODL_SYSTEM} OpenStackOperations.Get Karaf Log Types From Test Start ${ODL_SYSTEM_2_IP} ${test_name} ${log_types} - BuiltIn.Run Keyword If 2 < ${NUM_ODL_SYSTEM} OpenStackOperations.Get Karaf Log Types From Test Start ${ODL_SYSTEM_3_IP} ${test_name} ${log_types} + Utils.Write Commands Until Expected Prompt sudo ovs-ofctl show ${INTEGRATION_BRIDGE} -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT} + Utils.Write Commands Until Expected Prompt sudo ovs-ofctl dump-flows ${INTEGRATION_BRIDGE} -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT} + Utils.Write Commands Until Expected Prompt sudo ovs-ofctl dump-groups ${INTEGRATION_BRIDGE} -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT} + Utils.Write Commands Until Expected Prompt sudo ovs-ofctl dump-group-stats ${INTEGRATION_BRIDGE} -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT} Get ControlNode Connection SSHLibrary.Switch Connection ${OS_CNTL_CONN_ID} @@ -547,15 +546,18 @@ Get ControlNode Connection Get OvsDebugInfo [Documentation] Get the OvsConfig and Flow entries from all Openstack nodes - BuiltIn.Run Keyword If 0 < ${NUM_OS_SYSTEM} OpenStackOperations.Get DumpFlows And Ovsconfig ${OS_CNTL_CONN_ID} - BuiltIn.Run Keyword If 1 < ${NUM_OS_SYSTEM} OpenStackOperations.Get DumpFlows And Ovsconfig ${OS_CMP1_CONN_ID} - BuiltIn.Run Keyword If 2 < ${NUM_OS_SYSTEM} OpenStackOperations.Get DumpFlows And Ovsconfig ${OS_CMP2_CONN_ID} + : FOR ${conn_id} IN @{OS_ALL_CONN_IDS} + \ OpenStackOperations.Get DumpFlows And Ovsconfig ${conn_id} Get Test Teardown Debugs - [Arguments] ${test_name}=${TEST_NAME} + [Arguments] ${test_name}=${SUITE_NAME}.${TEST_NAME} ${fail}=${FAIL_ON_EXCEPTIONS} + ODLTools.Get All test_name=${test_name} OpenStackOperations.Get OvsDebugInfo BuiltIn.Run Keyword And Ignore Error DataModels.Get Model Dump ${HA_PROXY_IP} ${netvirt_data_models} - OpenStackOperations.Get Karaf Log Events From Test Start ${test_name} + KarafKeywords.Fail If Exceptions Found During Test ${test_name} fail=${fail} + +Get Suite Debugs + Get Test Teardown Debugs test_name=${SUITE_NAME} fail=False Get Test Teardown Debugs For SFC [Arguments] ${test_name}=${TEST_NAME} @@ -642,45 +644,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} - ${rc} ${output} = OperatingSystem.Run And Return Rc And Output ${cmd} + ${output} = OpenStack CLI ${cmd} ${rule_id} = BuiltIn.Should Match Regexp ${output} ${REGEX_UUID} - BuiltIn.Log ${rule_id} - BuiltIn.Should Be True '${rc}' == '0' - [Return] ${output} ${rule_id} - -Neutron Security Group Rule Create Legacy Cli - [Arguments] ${Security_group_name} &{Kwargs} - [Documentation] Creates neutron security rule with neutron request with or without optional params, here security group name is mandatory args, rule with optional params can be created by passing the optional args values ex: direction=${INGRESS_EGRESS}, Then these optional params are BuiltIn.Catenated with mandatory args, example of usage: "OpenStack Neutron Security Group Rule Create ${SGP_SSH} direction=${RULE_PARAMS[0]} ethertype=${RULE_PARAMS[1]} ..." - BuiltIn.Run Keyword If ${Kwargs} BuiltIn.Log ${Kwargs} - ${description} BuiltIn.Run Keyword If ${Kwargs} Collections.Pop From Dictionary ${Kwargs} description default=${None} - ${direction} BuiltIn.Run Keyword If ${Kwargs} Collections.Pop From Dictionary ${Kwargs} direction default=${None} - ${ethertype} BuiltIn.Run Keyword If ${Kwargs} Collections.Pop From Dictionary ${Kwargs} ethertype default=${None} - ${port_range_max} BuiltIn.Run Keyword If ${Kwargs} Collections.Pop From Dictionary ${Kwargs} port_range_max default=${None} - ${port_range_min} BuiltIn.Run Keyword If ${Kwargs} Collections.Pop From Dictionary ${Kwargs} port_range_min default=${None} - ${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} - ${cmd} = BuiltIn.Set Variable neutron security-group-rule-create ${Security_group_name} - ${cmd} = BuiltIn.Run Keyword If '${description}'!='None' BuiltIn.Catenate ${cmd} --description ${description} - ... ELSE BuiltIn.Catenate ${cmd} - ${cmd} = BuiltIn.Run Keyword If '${direction}'!='None' BuiltIn.Catenate ${cmd} --direction ${direction} - ... ELSE BuiltIn.Catenate ${cmd} - ${cmd} = BuiltIn.Run Keyword If '${ethertype}'!='None' BuiltIn.Catenate ${cmd} --ethertype ${ethertype} - ... ELSE BuiltIn.Catenate ${cmd} - ${cmd} = BuiltIn.Run Keyword If '${port_range_max}'!='None' BuiltIn.Catenate ${cmd} --port_range_max ${port_range_max} - ... ELSE BuiltIn.Catenate ${cmd} - ${cmd} = BuiltIn.Run Keyword If '${port_range_min}'!='None' BuiltIn.Catenate ${cmd} --port_range_min ${port_range_min} - ... ELSE BuiltIn.Catenate ${cmd} - ${cmd} = BuiltIn.Run Keyword If '${protocol}'!='None' BuiltIn.Catenate ${cmd} --protocol ${protocol} - ... ELSE BuiltIn.Catenate ${cmd} - ${cmd} = BuiltIn.Run Keyword If '${remote_group_id}'!='None' BuiltIn.Catenate ${cmd} --remote_group_id ${remote_group_id} - ... ELSE BuiltIn.Catenate ${cmd} - ${cmd} = BuiltIn.Run Keyword If '${remote_ip_prefix}'!='None' BuiltIn.Catenate ${cmd} --remote_ip_prefix ${remote_ip_prefix} - ... ELSE BuiltIn.Catenate ${cmd} - ${rc} ${output} = OperatingSystem.Run And Return Rc And Output ${cmd} - ${rule_id} = BuiltIn.Should Match Regexp ${output} ${REGEX_UUID} - BuiltIn.Log ${rule_id} - BuiltIn.Should Be True '${rc}' == '0' [Return] ${output} ${rule_id} Security Group Create Without Default Security Rules @@ -742,6 +707,14 @@ Get Port Mac ${port_mac} = Collections.Get from List ${splitted_output} 0 [Return] ${port_mac} +Get Port Mac Address From Ip + [Arguments] ${ip} + [Documentation] Retrieve the mac address for a port that matches any given ip. + ${output} = OpenStack CLI openstack port list | grep -w ${ip} | awk '{print $5}' + ${splitted_output} = String.Split String ${output} ${EMPTY} + ${mac_addr} = Collections.Get from List ${splitted_output} 0 + [Return] ${mac_addr} + Create L2Gateway [Arguments] ${bridge_name} ${intf_name} ${gw_name} [Documentation] Keyword to create an L2 Gateway ${gw_name} for bridge ${bridge_name} connected to interface ${intf_name} (Using Neutron CLI). @@ -749,6 +722,13 @@ Create L2Gateway BuiltIn.Log ${l2gw_output} [Return] ${l2gw_output} +Update L2Gateway + [Arguments] ${bridge_name} ${gw_name} ${intf_name_1} ${intf_name_2} + [Documentation] Keyword to add {intf_name_list} to an existing L2 Gateway ${gw_name} (Using Neutron CLI). + ${rc} ${l2gw_output}= Run And Return Rc And Output ${L2GW_UPDATE} name=${bridge_name},interface_names="${intf_name_1};${intf_name_2}" ${gw_name} + Log ${l2gw_output} + [Return] ${l2gw_output} + Create L2Gateway Connection [Arguments] ${gw_name} ${net_name} [Documentation] Keyword would create a new L2 Gateway Connection for ${gw_name} to ${net_name} (Using Neutron CLI). @@ -822,6 +802,14 @@ Update Port Rest BuiltIn.Should Be Equal As Strings ${resp.status_code} 200 [Return] ${resp.content} +Get Neutron Network Rest + [Arguments] ${net_id} + [Documentation] Keyword to get the specific network details in Neutron (Using REST). + ${resp} = RequestsLibrary.Get Request session ${NETWORK_URL}/network/${net_id} + BuiltIn.Log ${resp.content} + BuiltIn.Should Be Equal As Strings ${resp.status_code} 200 + [Return] ${resp.content} + Create And Configure Security Group [Arguments] ${sg-name} [Documentation] Create Security Group with given name, and default allow rules for TCP/UDP/ICMP protocols. @@ -929,7 +917,7 @@ Wait For Routes To Propogate \ ${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} ]> + \ ${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}] Neutron Cleanup @@ -948,8 +936,7 @@ Neutron Cleanup 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 - BuiltIn.Run Keyword If "${ODL_ENABLE_L3_FWD}"=="yes" Collections.Append To List ${modules} floating ip router + ... security group rule floating ip router : FOR ${module} IN @{modules} \ ${output} = OpenStack CLI openstack ${module} list @@ -965,30 +952,29 @@ OpenStack CLI Get List OpenStack CLI [Arguments] ${cmd} [Documentation] Run the given OpenStack ${cmd} and log the output. - ${rc} ${output} = OperatingSystem.Run And Return Rc And Output ${cmd} - BuiltIn.Log ${output} - BuiltIn.Should Be True '${rc}' == '0' - [Return] ${output} + ${result} = Process.Run Process ${cmd} shell=True + BuiltIn.Log ${result.stdout} + BuiltIn.Log ${result.stderr} + BuiltIn.Should Be True '${result.rc}' == '0' + [Return] ${result.stdout} OpenStack CLI With No Log [Arguments] ${cmd} [Documentation] Run the given OpenStack ${cmd} and do not log the output. - ${rc} ${output} = OperatingSystem.Run And Return Rc And Output ${cmd} - BuiltIn.Should Be True '${rc}' == '0' - [Return] ${output} + ${result} = Process.Run Process ${cmd} shell=True + BuiltIn.Should Be True '${result.rc}' == '0' + [Return] ${result.stdout} 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} = BuiltIn.Run Keyword If "${ODL_ENABLE_L3_FWD}"=="yes" OpenStack CLI Get List openstack floating ip list -f json - ... ELSE BuiltIn.Create List @{EMPTY} + @{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']} @{vms} = OpenStack CLI Get List openstack server list -f json : FOR ${vm} IN @{vms} \ BuiltIn.Run Keyword And Ignore Error Delete Vm Instance ${vm['ID']} - @{routers} = BuiltIn.Run Keyword If "${ODL_ENABLE_L3_FWD}"=="yes" OpenStack CLI Get List openstack router list -f json - ... ELSE BuiltIn.Create List @{EMPTY} + @{routers} = OpenStack CLI Get List openstack router list -f json : FOR ${router} IN @{routers} \ BuiltIn.Run Keyword And Ignore Error Cleanup Router ${router['ID']} @{ports} = OpenStack CLI Get List openstack port list -f json @@ -1016,20 +1002,29 @@ Cleanup Router OpenStack Suite Setup [Documentation] Wrapper teardown keyword that can be used in any suite running in an openstack environement SetupUtils.Setup_Utils_For_Setup_And_Teardown - @{tcpdump_port_6653_conn_ids} = OpenStackOperations.Start Packet Capture On Nodes tcpdump_port_6653 port 6653 ${OS_CONTROL_NODE_IP} ${OS_COMPUTE_1_IP} ${OS_COMPUTE_2_IP} + @{loggers} = BuiltIn.Create List org.apache.karaf.shell.support.ShellUtil org.apache.sshd.server.session.ServerSessionImpl + Setuputils.Setup_Logging_For_Debug_Purposes_On_List_Or_All OFF ${loggers} + DevstackUtils.Devstack Suite Setup + @{tcpdump_port_6653_conn_ids} = OpenStackOperations.Start Packet Capture On Nodes tcpdump_port_6653 port 6653 @{OS_ALL_IPS} BuiltIn.Set Suite Variable @{tcpdump_port_6653_conn_ids} BuiltIn.Run Keyword If "${PRE_CLEAN_OPENSTACK_ALL}"=="True" OpenStack Cleanup All - DevstackUtils.Devstack Suite Setup OpenStackOperations.Add OVS Logging On All OpenStack Nodes + Run_Keyword_If_At_Least_Oxygen Wait Until Keyword Succeeds 60 2 ClusterManagement.Check Status Of Services Is OPERATIONAL @{NETVIRT_DIAG_SERVICES} + Verify Expected Default Tables On Nodes OpenStack Suite Teardown [Documentation] Wrapper teardown keyword that can be used in any suite running in an openstack environement ... to clean up all openstack resources. For example, all instances, networks, ports, etc will be listed and ... and deleted. As other global cleanup tasks are needed, they can be added here and the suites will all ... benefit automatically. + # TODO: followup patch will add the list of vms to pass to Show Debugs + # OpenStackOperations.Show Debugs @{NET_1_VMS} @{NET_2_VMS} + OpenStackOperations.Get Suite Debugs 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} Copy DHCP Files From Control Node [Documentation] Copy the current DHCP files to the robot vm. The keyword must be called @@ -1049,15 +1044,13 @@ Is Feature Installed Add OVS Logging On All OpenStack Nodes [Documentation] Add higher levels of OVS logging to all the OpenStack nodes - BuiltIn.Run Keyword If 0 < ${NUM_OS_SYSTEM} OVSDB.Add OVS Logging ${OS_CNTL_CONN_ID} - BuiltIn.Run Keyword If 1 < ${NUM_OS_SYSTEM} OVSDB.Add OVS Logging ${OS_CMP1_CONN_ID} - BuiltIn.Run Keyword If 2 < ${NUM_OS_SYSTEM} OVSDB.Add OVS Logging ${OS_CMP2_CONN_ID} + : FOR ${conn_id} IN @{OS_ALL_CONN_IDS} + \ OVSDB.Add OVS Logging ${conn_id} Reset OVS Logging On All OpenStack Nodes [Documentation] Reset the OVS logging to all the OpenStack nodes - BuiltIn.Run Keyword If 0 < ${NUM_OS_SYSTEM} OVSDB.Reset OVS Logging ${OS_CNTL_CONN_ID} - BuiltIn.Run Keyword If 1 < ${NUM_OS_SYSTEM} OVSDB.Reset OVS Logging ${OS_CMP1_CONN_ID} - BuiltIn.Run Keyword If 2 < ${NUM_OS_SYSTEM} OVSDB.Reset OVS Logging ${OS_CMP2_CONN_ID} + : FOR ${conn_id} IN @{OS_ALL_CONN_IDS} + \ OVSDB.Reset OVS Logging ${conn_id} Start Packet Capture On Nodes [Arguments] ${tag} ${filter} @{ips} @@ -1072,3 +1065,80 @@ Start Packet Capture On Nodes Stop Packet Capture On Nodes [Arguments] ${conn_ids}=@{EMPTY} Tcpdump.Stop Packet Capture on Nodes ${conn_ids} + +Server Live Migrate + [Arguments] ${vm_instance_name} + [Documentation] Keyword for live migration of VM instance + ... additional_agrs is to select particular migration(live/shared-migration/block-migration) + ... if the additional_agrs is not given default migration(shared-migration) will happen + ${output} = OpenStackOperations.OpenStack CLI nova live-migration ${vm_instance_name} + +Get Hypervisor Host Of Vm + [Arguments] ${vm_name} + [Documentation] Show server with neutron request. + ${output} = OpenStackOperations.OpenStack CLI openstack server show -f value -c OS-EXT-SRV-ATTR:host ${vm_name} + [Return] ${output} + +Check If Migration Is Complete + [Arguments] ${vm_name} + [Documentation] Show server and verify if task_state is not migrating + ${output} = OpenStackOperations.OpenStack CLI openstack server show ${vm_name} | grep "OS-EXT-STS:task_state" + BuiltIn.Should Not Contain ${output} migrating + +Modify OpenStack Configuration File + [Arguments] ${conn_id} ${file_name} ${section} ${key} ${value} + [Documentation] Use crudini to modify any parameter in any Openstack configuration File + SSHLibrary.Switch Connection ${conn_id} + ${output} ${rc} = SSHLibrary.Execute Command sudo crudini --verbose --set --inplace ${file_name} ${section} ${key} ${value} return_rc=True return_stdout=True + BuiltIn.Log ${output} + BuiltIn.Should Be True '${rc}' == '0' + +Restart DevStack Service + [Arguments] ${conn_id} ${service_name} + [Documentation] Restart the Openstack Service + SSHLibrary.Switch Connection ${conn_id} + ${output} ${rc} = SSHLibrary.Execute Command sudo systemctl restart devstack@${service_name}.service return_rc=True return_stdout=True + BuiltIn.Log ${output} + BuiltIn.Should Be True '${rc}' == '0' + +Get Network Segmentation Id + [Arguments] ${network_name} + [Documentation] Returns network segmentation id for the given network name. + ${output} = OpenStack CLI openstack network show ${network_name} | grep segmentation_id | awk '{print $4}' + @{list} = String.Split String ${output} + [Return] @{list}[0] + +Verify Expected Default Tables On Nodes + [Arguments] ${node_ips}=@{OS_ALL_IPS} + [Documentation] Verify if Default Table Entries are programmed on all 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} + Builtin.Should Be Empty ${failed_node_list} + +Verify Expected Default Tables + [Arguments] ${ovs_ip} + [Documentation] Verify if Default Table Entries are programmed on specific Node + ${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} + [Return] ${failed_table_list} + +Get Project Id + [Arguments] ${project_name} + [Documentation] Returns project ID for the given project name. + ${project_id} = OpenStack CLI openstack project show ${project_name} -f value -c id + [Return] ${project_id} + +Set Instance Quota For Project + [Arguments] ${num_instances} ${project_id} + [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}