+ [Arguments] ${networks} ${subnets}
+ 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}]
+ 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}
+ 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
+ END
+
+OpenStack CLI Get List
+ [Documentation] Return a json list from the output of an OpenStack command.
+ [Arguments] ${cmd}
+ @{list} = BuiltIn.Create List
+ ${json} = OpenStack CLI ${cmd}
+ @{list} = RequestsLibrary.To Json ${json}
+ BuiltIn.Log ${list}
+ RETURN @{list}
+
+OpenStack CLI
+ [Documentation] Run the given OpenStack ${cmd} and log the output.
+ [Arguments] ${cmd}
+ ${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
+ [Documentation] Run the given OpenStack ${cmd} and do not log the output.
+ [Arguments] ${cmd}
+ ${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} = 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']}
+ 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']}
+ 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']}
+ 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']}
+ 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']}
+ END
+ @{security_groups} = OpenStack CLI Get List openstack security group list -f json
+ FOR ${security_group} IN @{security_groups}
+ IF "${security_group['Name']}" != "default"
+ BuiltIn.Run Keyword And Ignore Error Delete SecurityGroup ${security_group['ID']}
+ END
+ END
+ OpenStack List All
+
+Cleanup Router
+ [Documentation] Delete a router, but first remove any interfaces or gateways so that the delete will be successful.
+ [Arguments] ${id}
+ @{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
+ IF "${port['Device Owner']}" == "network:router_gateway"
+ BuiltIn.Run Keyword And Ignore Error Remove Gateway ${id}
+ END
+ IF "${port['Device Owner']}" == "network:router_interface"
+ BuiltIn.Run Keyword And Ignore Error Remove Interface ${id} ${subnet_id}
+ END
+ END
+ BuiltIn.Run Keyword And Ignore Error Delete Router ${id}
+
+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
+ @{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}
+ IF "${PRE_CLEAN_OPENSTACK_ALL}"=="True" OpenStack Cleanup All
+ OpenStackOperations.Add OVS Logging On All OpenStack Nodes
+ Validate Deployment
+
+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}
+ 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}
+ 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
+ END
+
+Write To Validate File
+ [Documentation] Write the given ${msg} to ${VALIDATION_FILE}. Create the file if not present.
+ [Arguments] ${msg}
+ ${status} = BuiltIn.Run Keyword And Return Status OperatingSystem.File Should Exist ${VALIDATION_FILE}
+ IF "${status}" == "False"
+ OperatingSystem.Create File ${VALIDATION_FILE}
+ END
+ OperatingSystem.Append To File ${VALIDATION_FILE} ${msg}\n
+
+Copy DHCP Files From Control Node
+ [Documentation] Copy the current DHCP files to the robot vm. The keyword must be called
+ ... after the subnet(s) are created and before the subnet(s) are deleted.
+ ${suite_} = BuiltIn.Evaluate """${SUITE_NAME}""".replace(" ","_").replace("/","_").replace(".","_")
+ ${dstdir} = BuiltIn.Set Variable /tmp/qdhcp/${suite_}
+ OperatingSystem.Create Directory ${dstdir}
+ OpenStackOperations.Get ControlNode Connection
+ BuiltIn.Run Keyword And Ignore Error
+ ... SSHLibrary.Get Directory
+ ... /opt/stack/data/neutron/dhcp
+ ... ${dstdir}
+ ... recursive=True
+
+Is Feature Installed
+ [Arguments] ${features}=none
+ FOR ${feature} IN @{features}
+ ${status} ${output} = BuiltIn.Run Keyword And Ignore Error
+ ... BuiltIn.Should Contain
+ ... ${CONTROLLERFEATURES}
+ ... ${feature}
+ IF "${status}" == "PASS" RETURN 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}
+ 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}
+ END
+
+Start Packet Capture On Nodes
+ [Documentation] Wrapper keyword around the TcpDump packet capture that is catered to the Openstack setup.
+ ... The caller must pass the three arguments with a variable number of ips at the end,
+ ... but ${EMPTY} can be used for the tag and filter.
+ [Arguments] ${tag} ${filter} @{ips}
+ ${suite_} = BuiltIn.Evaluate """${SUITE_NAME}""".replace(" ","_").replace("/","_").replace(".","_")
+ ${tag_} = BuiltIn.Catenate SEPARATOR=__ ${tag} ${suite_}
+ @{conn_ids} = Tcpdump.Start Packet Capture on Nodes tag=${tag_} filter=${filter} ips=${ips}
+ RETURN @{conn_ids}
+
+Stop Packet Capture On Nodes
+ [Arguments] ${conn_ids}=@{EMPTY}
+ Tcpdump.Stop Packet Capture on Nodes ${conn_ids}
+
+Server Live Migrate
+ [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
+ [Arguments] ${vm_instance_name}
+ ${output} = OpenStackOperations.OpenStack CLI nova live-migration ${vm_instance_name}
+
+Get Hypervisor Host Of Vm
+ [Documentation] Show server with neutron request.
+ [Arguments] ${vm_name}
+ ${output} = OpenStackOperations.OpenStack CLI
+ ... openstack server show -f value -c OS-EXT-SRV-ATTR:host ${vm_name}
+ RETURN ${output}
+
+Check If Migration Is Complete
+ [Documentation] Show server and verify if task_state is not migrating
+ [Arguments] ${vm_name}
+ ${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
+ [Documentation] Use crudini to modify any parameter in any Openstack configuration File
+ [Arguments] ${conn_id} ${file_name} ${section} ${key} ${value}
+ 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
+ [Documentation] Restart the Openstack Service
+ [Arguments] ${conn_id} ${service_name}
+ 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
+ [Documentation] Returns network segmentation id for the given network name.
+ [Arguments] ${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 Services
+ [Documentation] Verify if the services are operational
+ Wait Until Keyword Succeeds
+ ... 60
+ ... 2
+ ... ClusterManagement.Check Status Of Services Is OPERATIONAL
+ ... @{DIAG_SERVICES}
+
+Verify Expected Default Tables On Nodes
+ [Documentation] Verify if Default Table Entries are programmed on all Nodes
+ [Arguments] ${node_ips}=@{OS_ALL_IPS}
+ ${resp} = RequestsLibrary.Get Request session ${RFC8040_CONFIG_NODES_API}
+ Utils.Log Content ${resp.text}
+ ${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}
+ IF ${failed_table_list_size} > 0
+ Collections.Append To List ${failed_node_list} ${node_ip}
+ END
+ END
+ Builtin.Should Be Empty ${failed_node_list}
+
+Verify Expected Default Tables
+ [Documentation] Verify if Default Table Entries are programmed on specific Node
+ [Arguments] ${ovs_ip}
+ ${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
+ IF ${rc}
+ Collections.Append To List ${failed_table_list} ${table}
+ END
+ END
+ RETURN ${failed_table_list}
+
+Get Project Id
+ [Documentation] Returns project ID for the given project name.
+ [Arguments] ${project_name}
+ ${project_id} = OpenStack CLI openstack project show ${project_name} -f value -c id
+ RETURN ${project_id}
+
+Set Instance Quota For Project
+ [Documentation] Set quota for the created instances using the specific project id.
+ [Arguments] ${num_instances} ${project_id}
+ ${output} = OpenStack CLI openstack quota set --instances ${num_instances} ${project_id}
+ RETURN ${output}
+
+Create Bgpvpn
+ [Documentation] Create Bgpvpn with neutron request.
+ [Arguments] ${vpnname} ${additional_args}=${EMPTY}
+ ${output} = OpenStack CLI openstack bgpvpn create --name ${vpnname} ${additional_args}
+
+Get BgpVpn Id
+ [Documentation] Retrieve the bgpvpn id for the given bgpvpn name
+ [Arguments] ${vpnName}
+ ${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
+ [Documentation] Keyword for configuring specified IP on specified interface and the corresponding specified sub interface
+ [Arguments] ${network_name} ${ip} ${vm_ip} ${mask} ${sub_interface_state}=${EMPTY} ${interface}=eth0
+ ... ${sub_interface_number}=1
+ 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
+ [Documentation] Keyword for verifying specified IP on specified interface and the corresponding specified sub interface
+ [Arguments] ${network_name} ${ip} ${vm_ip} ${interface}=eth0 ${sub_interface_number}=1
+ ${resp} = OpenStackOperations.Execute Command on VM Instance
+ ... ${network_name}
+ ... ${vm_ip}
+ ... sudo ifconfig ${interface}:${sub_interface_number}
+ BuiltIn.Should Contain ${resp} ${ip}