${router_id} = Collections.Get from List ${splitted_output} 0
[Return] ${router_id}
+Add New Image From Url
+ [Arguments] ${image_url} ${image_name}
+ [Documentation] To add new qcow2 images for testing.
+ ${rc} ${output} = OperatingSystem.Run And Return Rc And Output wget ${image_url} -O /tmp/new_image.qcow2
+ BuiltIn.Log ${output}
+ BuiltIn.Should Be True '${rc}' == '0'
+ ${output} = OpenStack CLI openstack image create ${image_name} --file /tmp/new_image.qcow2 --disk-format qcow2 --container-format bare --public
+
+Create Flavor
+ [Arguments] ${flavor_name} ${ram_in_mb} ${disk_in_gb} ${ncpu}=1
+ [Documentation] To create new flavors for instance deployment and testing
+ ${output} = OpenStack CLI openstack flavor create ${flavor_name} --ram ${ram_in_mb} --disk ${disk_in_gb} --vcpus ${ncpu}
+
+Create Keypair
+ [Arguments] ${keyname} ${public_key_file}
+ [Documentation] To add keypairs to Openstack that can be used when ssh to instances using publickey authentication
+ ${output} = OpenStack CLI openstack keypair create ${keyname} --public-key ${public_key_file}
+
+Generate And Add Keypair
+ [Arguments] ${keyname} ${keyfilename}
+ [Documentation] To generate keypair using ssh-keygen and add them to Openstack
+ ${result} = Process.Run Process ssh-keygen -b 2048 -t rsa -f ${JENKINS_WORKSPACE}/${keyfilename} -q -N "" shell=True
+ BuiltIn.Log ${result.stdout}
+ BuiltIn.Log ${result.stderr}
+ BuiltIn.Should Be True '${result.rc}' == '0'
+ OpenStackOperations.Create Keypair ${keyname} ${JENKINS_WORKSPACE}/${keyfilename}.pub
+ OpenStackOperations.Get ControlNode Connection
+ SSHLibrary.Put_File ${JENKINS_WORKSPACE}/${keyfilename} /tmp
+
Create Vm Instances
[Arguments] ${net_name} ${vm_instance_names} ${image}=${EMPTY} ${flavor}=m1.nano ${sg}=default ${min}=1
- ... ${max}=1
[Documentation] Create X Vm Instance with the net id of the Netowrk.
+ .. ${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}
[Arguments] ${port_name} ${vm_instance_name} ${image}=${EMPTY} ${flavor}=m1.nano ${sg}=default
[Documentation] Create One VM instance using given ${port_name} and for given ${compute_node}
${image} = BuiltIn.Set Variable If "${image}"=="${EMPTY}" ${CIRROS_${OPENSTACK_BRANCH}} ${image}
- ${port_id} = OpenStackOperations.Get Port Id ${port_name}
- ${output} = OpenStack CLI openstack server create --image ${image} --flavor ${flavor} --nic port-id=${port_id} ${vm_instance_name} --security-group ${sg}
+ ${output} = OpenStack CLI openstack server create --image ${image} --flavor ${flavor} --port ${port_name} --security-group ${sg} ${vm_instance_name}
-Create Vm Instance With Ports
- [Arguments] ${port_name} ${port2_name} ${vm_instance_name} ${image}=${EMPTY} ${flavor}=m1.nano ${sg}=default
- [Documentation] Create One VM instance using given ${port_name} and for given ${compute_node}
+Create Vm Instance With Ports And Key On Compute Node
+ [Arguments] ${port1_name} ${port2_name} ${vm_instance_name} ${node_hostname} ${image}=${EMPTY} ${flavor}=m1.nano
+ ... ${sg}=default ${keyname}=${EMPTY}
+ [Documentation] Create One VM instance using given ${port1_name} and ${port2_name} with keyname for ssh and also on a specific compute node
${image} BuiltIn.Set Variable If "${image}"=="${EMPTY}" ${CIRROS_${OPENSTACK_BRANCH}} ${image}
- ${port_id} = OpenStackOperations.Get Port Id ${port_name}
- ${port2_id} = OpenStackOperations.Get Port Id ${port2_name}
- ${output} = OpenStack CLI openstack server create --image ${image} --flavor ${flavor} --nic port-id=${port_id} --nic port-id=${port2_id} ${vm_instance_name} --security-group ${sg}
+ ${output} = OpenStack CLI openstack server create --image ${image} --flavor ${flavor} --port ${port1_name} --port ${port2_name} ${vm_instance_name} --security-group ${sg} --availability-zone nova:${node_hostname} --key-name ${keyname}
Create Vm Instance With Port On Compute Node
[Arguments] ${port_name} ${vm_instance_name} ${node_hostname} ${image}=${EMPTY} ${flavor}=m1.nano ${sg}=default
[Documentation] Create One VM instance using given ${port_name} and for given ${node_hostname}
${image} = BuiltIn.Set Variable If "${image}"=="${EMPTY}" ${CIRROS_${OPENSTACK_BRANCH}} ${image}
- ${port_id} = OpenStackOperations.Get Port Id ${port_name}
- ${output} = OpenStack CLI openstack server create --image ${image} --flavor ${flavor} --nic port-id=${port_id} --security-group ${sg} --availability-zone nova:${node_hostname} ${vm_instance_name}
+ ${output} = OpenStack CLI openstack server create --image ${image} --flavor ${flavor} --port ${port_name} --security-group ${sg} --availability-zone nova:${node_hostname} ${vm_instance_name}
+
+Remove Security Group From Vm Instance
+ [Arguments] ${vm_instance_name} ${security_group}
+ [Documentation] Delete the Security Group from the VM Instance.
+ ${output} = OpenStack CLI openstack server remove security group ${vm_instance_name} ${security_group}
Create Vm Instance With Ports On Compute Node
[Arguments] ${port1_name} ${port2_name} ${vm_instance_name} ${node_hostname} ${image}=${EMPTY} ${flavor}=m1.nano
... ${sg}=default
- [Documentation] Create One VM instance using given ${port1_name}, ${port2_name} and for given ${node_hostname}
+ [Documentation] Create One VM instance using given ${port1_name}, ${port2_name} and for given ${node_hostname} with no keys (cirros like)
${image} = BuiltIn.Set Variable If "${image}"=="${EMPTY}" ${CIRROS_${OPENSTACK_BRANCH}} ${image}
${port1_id} = OpenStackOperations.Get Port Id ${port1_name}
${port2_id} = OpenStackOperations.Get Port Id ${port2_name}
BuiltIn.Run Keyword If '${fail_on_none}' == 'true' BuiltIn.Should Not Contain ${dhcp_ip} None
[Return] ${vm_ip} ${dhcp_ip} ${vm_console_output}
+Verify If Instance Is Arpingable From DHCP Namespace
+ [Arguments] ${net_name} ${mac} ${ip}
+ [Documentation] Get the Port IP and check the arp -a from DHCP NS to ensure that the VM's have been assigned IP's
+ OpenStackOperations.Get ControlNode Connection
+ ${net_id} = OpenStackOperations.Get Net Id ${net_name}
+ ${output} = Utils.Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} arping ${ip} -c3 ${DEFAULT_LINUX_PROMPT_STRICT} timeout=60s
+ ${mac_uppercase} = String.Convert To Upper Case ${mac}
+ BuiltIn.Should Contain ${output} [${mac_uppercase}]
+
+Check If Instance Is Ready For Ssh Login Using PublicKey
+ [Arguments] ${net_name} ${vm_ip} ${user}=centos ${idfile}=/tmp/odlkey
+ [Documentation] Ensure the VM is reachable from ssh as tests would require. This keyword will use publickey authentication
+ ${output} = Execute Command on VM Instance with PublicKey Auth ${net_name} ${vm_ip} ifconfig user=${user} idfile=${idfile}
+ BuiltIn.Should Contain ${output} ${vm_ip}
+
+Check If Instance Is Ready For Ssh Login Using Password
+ [Arguments] ${net_name} ${vm_ip} ${user}=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
+ BuiltIn.Should Contain ${output} ${vm_ip}
+
Get VM IPs
[Arguments] @{vms}
[Documentation] Get the instance IP addresses and nameserver address for the list of given vms.
OpenStackOperations.Copy DHCP Files From Control Node
[Return] @{vm_ips} ${ips_and_console_log[1]}
-Get Two Port 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
${output} = DevstackUtils.Write Commands Until Prompt And Log exit
Check If Console Is VmInstance
- [Arguments] ${console}=cirros
[Documentation] Check if the session has been able to login to the VM instance
${output} = Utils.Write Commands Until Expected Prompt id ${OS_SYSTEM_PROMPT}
- BuiltIn.Should Contain ${output} ${console}
+ BuiltIn.Should Not Contain ${output} jenkins
Exit From Vm Console
[Documentation] Check if the session has been able to login to the VM instance and exit the instance
- ${rcode} = BuiltIn.Run Keyword And Return Status OpenStackOperations.Check If Console Is VmInstance cirros
+ ${rcode} = BuiltIn.Run Keyword And Return Status OpenStackOperations.Check If Console Is VmInstance
BuiltIn.Run Keyword If ${rcode} DevstackUtils.Write Commands Until Prompt exit
Check Ping
BuiltIn.Should Contain ${output} 200
Execute Command on VM Instance
- [Arguments] ${net_name} ${vm_ip} ${cmd} ${user}=cirros ${password}=cubswin:)
+ [Arguments] ${net_name} ${vm_ip} ${cmd} ${user}=cirros ${password}=cubswin:) ${cmd_timeout}=30s
[Documentation] Login to the vm instance using ssh in the network, executes a command inside the VM and returns the ouput.
OpenStackOperations.Get ControlNode Connection
${net_id} = OpenStackOperations.Get Net Id ${net_name}
- ${output} = Utils.Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ssh ${user}@${vm_ip} -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null password: timeout=60s
- ${output} = Utils.Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT} timeout=60s
+ ${output} = Utils.Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ssh ${user}@${vm_ip} -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o PreferredAuthentications=password password:
+ ${output} = Utils.Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
${rcode} = BuiltIn.Run Keyword And Return Status OpenStackOperations.Check If Console Is VmInstance
- ${output} = BuiltIn.Run Keyword If ${rcode} Utils.Write Commands Until Expected Prompt ${cmd} ${OS_SYSTEM_PROMPT} timeout=60s
+ ${output} = BuiltIn.Run Keyword If ${rcode} Utils.Write Commands Until Expected Prompt ${cmd} ${OS_SYSTEM_PROMPT} timeout=${cmd_timeout}
[Teardown] Exit From Vm Console
[Return] ${output}
+Execute Command on VM Instance With PublicKey Auth
+ [Arguments] ${net_name} ${vm_ip} ${cmd} ${user}=centos ${idfile}=/tmp/odlkey
+ [Documentation] Login to the vm instance using ssh publickey in the network, executes a command inside the VM and returns the ouput.
+ OpenStackOperations.Get ControlNode Connection
+ ${net_id} = OpenStackOperations.Get Net Id ${net_name}
+ ${output} = Utils.Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ssh -i ${idfile} ${user}@${vm_ip} -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o PreferredAuthentications=publickey prompt=${OS_SYSTEM_PROMPT} timeout=60s
+ ${rcode} = BuiltIn.Run Keyword And Return Status OpenStackOperations.Check If Console Is VmInstance
+ ${output} = BuiltIn.Run Keyword If ${rcode} Utils.Write Commands Until Expected Prompt ${cmd} ${OS_SYSTEM_PROMPT}
+ [Teardown] Exit From Vm Console
+ [Return] ${output}
+
+Copy File To VM Instance With PublicKey Auth
+ [Arguments] ${net_name} ${vm_ip} ${file_to_copy} ${user}=centos ${idfile}=/tmp/odlkey
+ [Documentation] Login to the vm instance using ssh publickey in the network, executes a command inside the VM and returns the ouput.
+ OpenStackOperations.Get ControlNode Connection
+ ${net_id} = OpenStackOperations.Get Net Id ${net_name}
+ ${rc} = SSHLibrary.Execute Command sudo ip netns exec qdhcp-${net_id} scp -i ${idfile} -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o PreferredAuthentications=publickey ${file_to_copy} ${user}@${vm_ip}:/tmp/ return_stdout=False return_rc=True
+ BuiltIn.Should Be True '${rc}' == '0'
+
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
${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 default=${None}
- ${cmd} = BuiltIn.Set Variable openstack security group rule create
+ ${remote_ip_prefix} BuiltIn.Run Keyword If ${Kwargs} Collections.Pop From Dictionary ${Kwargs} remote_ip_prefix 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}
${cmd} = BuiltIn.Run Keyword If '${direction}'!='None' BuiltIn.Catenate ${cmd} --${direction}
... ELSE BuiltIn.Catenate ${cmd}
${cmd} = BuiltIn.Run Keyword If '${remote_group_id}'!='None' BuiltIn.Catenate ${cmd} --remote-group ${remote_group_id}
... ELSE BuiltIn.Catenate ${cmd}
- ${cmd} = BuiltIn.Run Keyword If '${remote_ip_prefix}'!='None' BuiltIn.Catenate ${cmd} --remote-ip ${remote_ip_prefix} ${Security_group_name}
+ ${cmd} = BuiltIn.Run Keyword If '${remote_ip_prefix}'!='None' BuiltIn.Catenate ${cmd} --src-ip ${remote_ip_prefix}
... ELSE BuiltIn.Catenate ${cmd}
${output} = OpenStack CLI ${cmd}
${rule_id} = BuiltIn.Should Match Regexp ${output} ${REGEX_UUID}
${output} = OpenStack CLI openstack server remove security group ${vm} ${sg}
Create SFC Flow Classifier
- [Arguments] ${name} ${src_ip} ${dest_ip} ${protocol} ${dest_port} ${neutron_src_port}
+ [Arguments] ${name} ${src_ip} ${dest_ip} ${protocol} ${neutron_src_port} ${args}=${EMPTY}
[Documentation] Create a flow classifier for SFC
- ${output} = OpenStack CLI openstack sfc flow classifier create --ethertype IPv4 --source-ip-prefix ${src_ip}/32 --destination-ip-prefix ${dest_ip}/32 --protocol ${protocol} --destination-port ${dest_port}:${dest_port} --logical-source-port ${neutron_src_port} ${name}
+ ${output} = OpenStack CLI openstack sfc flow classifier create --ethertype IPv4 --source-ip-prefix ${src_ip}/32 --destination-ip-prefix ${dest_ip}/32 --protocol ${protocol} --logical-source-port ${neutron_src_port} ${args} ${name}
BuiltIn.Should Contain ${output} ${name}
[Return] ${output}
Delete SFC Flow Classifier
[Arguments] ${name}
[Documentation] Delete a SFC flow classifier
- OpenStackOperations.Get ControlNode Connection
${output} = OpenStack CLI openstack sfc flow classifier delete ${name}
[Return] ${output}
Create SFC Port Pair
[Arguments] ${name} ${port_in} ${port_out}
[Documentation] Creates a neutron port pair for SFC
- OpenStackOperations.Get ControlNode Connection
${output} = OpenStack CLI openstack sfc port pair create --ingress=${port_in} --egress=${port_out} ${name}
BuiltIn.Should Contain ${output} ${name}
[Return] ${output}
[Return] ${output}
Create SFC Port Chain
- [Arguments] ${name} ${pg1} ${pg2} ${fc}
+ [Arguments] ${name} ${args}=${EMPTY}
[Documentation] Creates a port pair chain with two port groups and a singel classifier.
- ${output} = OpenStack CLI openstack sfc port chain create --port-pair-group ${pg1} --port-pair-group ${pg2} --flow-classifier ${fc} ${name}
+ ${output} = OpenStack CLI openstack sfc port chain create ${name} ${args}
BuiltIn.Should Contain ${output} ${name}
[Return] ${output}
+Update SFC Port Chain With A New Flow Classifier
+ [Arguments] ${name} ${fc}
+ [Documentation] Adds a Flow Classifier to a Port Chain
+ ${output} = OpenStack CLI openstack sfc port chain set ${name} --flow-classifier ${fc}
+ [Return] ${output}
+
+Update SFC Port Chain Removing A Flow Classifier
+ [Arguments] ${name} ${fc}
+ [Documentation] Adds a Flow Classifier to a Port Chain
+ ${output} = OpenStack CLI openstack sfc port chain unset ${name} --flow-classifier ${fc}
+ [Return] ${output}
+
Delete SFC Port Chain
[Arguments] ${name}
[Documentation] Delete a SFC port chain