adding tempest test cases to existing openstack related jobs
[integration/test.git] / csit / libraries / OpenStackOperations.robot
index e867f2b4d4f6558fb08d11bd168068b1ffc45f7f..0539840f3941e416c9fbdba8ab8bc422fad2f73a 100644 (file)
@@ -20,6 +20,15 @@ Create Network
     Log    ${output}
     Should Contain    ${output}    Created a new network
 
+List Networks
+    [Documentation]    List networks and return output with neutron client.
+    ${devstack_conn_id}=       Get ControlNode Connection
+    Switch Connection    ${devstack_conn_id}
+    ${output}=    Write Commands Until Prompt    neutron net-list    30s
+    Close Connection
+    Log    ${output}
+    [Return]    ${output}
+
 Delete Network
     [Arguments]    ${network_name}
     [Documentation]    Delete Network with neutron request.
@@ -88,10 +97,12 @@ Delete Vm Instance
     Close Connection
 
 Get Net Id
-    [Arguments]    ${network_name}     ${connection_id}
+    [Arguments]    ${network_name}
     [Documentation]    Retrieve the net id for the given network name to create specific vm instance
-    Switch Connection    ${connection_id}
+    ${devstack_conn_id}=       Get ControlNode Connection
+    Switch Connection    ${devstack_conn_id}
     ${output}=    Write Commands Until Prompt    neutron net-list | grep "${network_name}" | get_field 1       30s
+    Close Connection
     Log    ${output}
     ${splitted_output}=    Split String    ${output}    ${EMPTY}
     ${net_id}=    Get from List    ${splitted_output}    0
@@ -103,7 +114,7 @@ Create Vm Instances
     [Documentation]    Create X Vm Instance with the net id of the Netowrk.
     ${devstack_conn_id}=       Get ControlNode Connection
     Switch Connection    ${devstack_conn_id}
-    ${net_id}=    Get Net Id    ${net_name}    ${devstack_conn_id}
+    ${net_id}=    Get Net Id    ${net_name}
     : FOR    ${VmElement}    IN    @{vm_instance_names}
     \    ${output}=    Write Commands Until Prompt    nova boot --image ${image} --flavor ${flavor} --nic net-id=${net_id} ${VmElement}    30s
     \    Log    ${output}
@@ -131,7 +142,7 @@ Ping Vm From DHCP Namespace
     Log    ${vm_ip}
     ${devstack_conn_id}=       Get ControlNode Connection
     Switch Connection    ${devstack_conn_id}
-    ${net_id}=    Get Net Id    ${net_name}     ${devstack_conn_id}
+    ${net_id}=    Get Net Id    ${net_name}
     Log    ${net_id}
     ${output}=    Write Commands Until Prompt    sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip}    20s
     Log    ${output}
@@ -144,7 +155,7 @@ Ping From DHCP Should Not Succeed
     Log    ${vm_ip}
     ${devstack_conn_id}=       Get ControlNode Connection
     Switch Connection    ${devstack_conn_id}
-    ${net_id}=    Get Net Id    ${net_name}     ${devstack_conn_id}
+    ${net_id}=    Get Net Id    ${net_name}
     Log    ${net_id}
     ${output}=    Write Commands Until Prompt    sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip}    20s
     Close Connection
@@ -198,7 +209,7 @@ Test Operations From Vm Instance
     [Documentation]    Login to the vm instance using ssh in the network.
     ${devstack_conn_id}=       Get ControlNode Connection
     Switch Connection    ${devstack_conn_id}
-    ${net_id}=    Get Net Id    ${net_name}     ${devstack_conn_id}
+    ${net_id}=    Get Net Id    ${net_name}
     ${output}=    Write Commands Until Expected Prompt    sudo ip netns exec qdhcp-${net_id} ssh ${user}@${src_ip} -o ConnectTimeout=10 -o StrictHostKeyChecking=no    d:
     Log    ${output}
     ${output}=    Write Commands Until Expected Prompt    ${password}    ${OS_SYSTEM_PROMPT}
@@ -299,4 +310,4 @@ Show Debugs
     : FOR    ${index}    IN    @{vm_indices}
     \    ${output}=    Write Commands Until Prompt    nova show ${index}     30s
     \    Log    ${output}
-    Close Connection
+    Close Connection
\ No newline at end of file