Test cases for L3VPN creation,association and deletion are added
[integration/test.git] / csit / libraries / OpenStackOperations.robot
index 88a18795940012daa290a36e0311fa6ab08bb867..5a62acfc68dea149715ef5e98a599a0a0d0965c2 100644 (file)
@@ -84,7 +84,16 @@ Delete Port
     ${output}=    Write Commands Until Prompt    neutron -v port-delete ${port_name}    30s
     Close Connection
     Log    ${output}
-    Should Contain    ${output}    Deleted a new port
+    Should Contain    ${output}    Deleted port: ${port_name}
+
+List Ports
+    [Documentation]    List ports and return output with neutron client.
+    ${devstack_conn_id}=    Get ControlNode Connection
+    Switch Connection    ${devstack_conn_id}
+    ${output}=    Write Commands Until Prompt    neutron port-list    30s
+    Close Connection
+    Log    ${output}
+    [Return]    ${output}
 
 Verify Gateway Ips
     [Documentation]    Verifies the Gateway Ips with dump flow.
@@ -148,18 +157,32 @@ Get Port Id
     [Arguments]    ${port_name}    ${devstack_conn_id}
     [Documentation]    Retrieve the port id for the given port name to attach specific vm instance to a particular port
     Switch Connection    ${devstack_conn_id}
-    ${port_id}=    Write Commands Until Prompt    neutron port-list | grep "${port_name}" | awk '{print $2}'    30s
+    ${output}=    Write Commands Until Prompt    neutron port-list | grep "${port_name}" | awk '{print $2}'    30s
+    Log    ${output}
+    ${splitted_output}=    Split String    ${output}    ${EMPTY}
+    ${port_id}=    Get from List    ${splitted_output}    0
     Log    ${port_id}
     [Return]    ${port_id}
 
+Get Router Id
+    [Arguments]    ${router1}    ${devstack_conn_id}
+    [Documentation]    Retrieve the net id for the given network name to create specific vm instance
+    Switch Connection    ${devstack_conn_id}
+    ${output}=    Write Commands Until Prompt    neutron router-list | grep "${router1}" | get_field 1    30s
+    Log    ${output}
+    ${splitted_output}=    Split String    ${output}    ${EMPTY}
+    ${router_id}=    Get from List    ${splitted_output}    0
+    Log    ${router_id}
+    [Return]    ${router_id}
+
 Create Vm Instances
-    [Arguments]    ${net_name}    ${vm_instance_names}    ${image}=cirros-0.3.4-x86_64-uec    ${flavor}=m1.nano
+    [Arguments]    ${net_name}    ${vm_instance_names}    ${image}=cirros-0.3.4-x86_64-uec    ${flavor}=m1.nano    ${sg}=default
     [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}
     : FOR    ${VmElement}    IN    @{vm_instance_names}
-    \    ${output}=    Write Commands Until Prompt    nova boot --image ${image} --flavor ${flavor} --nic net-id=${net_id} ${VmElement}    30s
+    \    ${output}=    Write Commands Until Prompt    nova boot --image ${image} --flavor ${flavor} --nic net-id=${net_id} ${VmElement} --security-groups ${sg}    30s
     \    Log    ${output}
     \    Wait Until Keyword Succeeds    25s    5s    Verify VM Is ACTIVE    ${VmElement}
 
@@ -271,6 +294,7 @@ Test Operations From Vm Instance
     ${rcode}=    Run Keyword And Return Status    Check If Console Is VmInstance
     Run Keyword If    ${rcode}    Write Commands Until Expected Prompt    ifconfig    ${OS_SYSTEM_PROMPT}
     Run Keyword If    ${rcode}    Write Commands Until Expected Prompt    route    ${OS_SYSTEM_PROMPT}
+    Run Keyword If    ${rcode}    Write Commands Until Expected Prompt    arp -an    ${OS_SYSTEM_PROMPT}
     ${dest_vm}=    Get From List    ${list_of_local_dst_ips}    0
     Log    ${dest_vm}
     Run Keyword If    ${rcode}    Check Ping    ${dest_vm}
@@ -340,8 +364,22 @@ Get DumpFlows And Ovsconfig
     SSHLibrary.Open Connection    ${openstack_node_ip}    prompt=${DEFAULT_LINUX_PROMPT}
     Utils.Flexible SSH Login    ${OS_USER}    ${DEVSTACK_SYSTEM_PASSWORD}
     SSHLibrary.Set Client Configuration    timeout=${default_devstack_prompt_timeout}
+    Write Commands Until Expected Prompt    ip -o link    ]>
+    Write Commands Until Expected Prompt    ip -o addr    ]>
+    Write Commands Until Expected Prompt    ip route    ]>
+    Write Commands Until Expected Prompt    arp -an    ]>
+    ${nslist}=    Write Commands Until Expected Prompt    ip netns list | awk '{print $1}'    ]>
+    @{lines}    Split To Lines    ${nslist}
+    : FOR    ${line}    IN    @{lines}
+    \    Write Commands Until Expected Prompt    sudo ip netns exec ${line} ip -o link    ]>
+    \    Write Commands Until Expected Prompt    sudo ip netns exec ${line} ip -o addr    ]>
+    \    Write Commands Until Expected Prompt    sudo ip netns exec ${line} ip route    ]>
     Write Commands Until Expected Prompt    sudo ovs-vsctl show    ]>
+    Write Commands Until Expected Prompt    sudo ovs-vsctl list Open_vSwitch    ]>
+    Write Commands Until Expected Prompt    sudo ovs-ofctl show br-int -OOpenFlow13    ]>
     Write Commands Until Expected Prompt    sudo ovs-ofctl dump-flows br-int -OOpenFlow13    ]>
+    Write Commands Until Expected Prompt    sudo ovs-ofctl dump-groups br-int -OOpenFlow13    ]>
+    Write Commands Until Expected Prompt    sudo ovs-ofctl dump-group-stats br-int -OOpenFlow13    ]>
 
 Get ControlNode Connection
     ${control_conn_id}=    SSHLibrary.Open Connection    ${OS_CONTROL_NODE_IP}    prompt=${DEFAULT_LINUX_PROMPT_STRICT}
@@ -359,9 +397,28 @@ Get OvsDebugInfo
 Show Debugs
     [Arguments]    ${vm_indices}
     [Documentation]    Run these commands for debugging, it can list state of VM instances and ip information in control node
+    ${devstack_conn_id}=    Get ControlNode Connection
+    Switch Connection    ${devstack_conn_id}
     ${output}=    Write Commands Until Prompt    sudo ip netns list
     Log    ${output}
     : FOR    ${index}    IN    @{vm_indices}
     \    ${output}=    Write Commands Until Prompt    nova show ${index}    30s
     \    Log    ${output}
     Close Connection
+    List Networks
+    List Subnets
+    List Ports
+
+Create Security Group
+    [Arguments]    ${sg_name}    ${desc}
+    ${devstack_conn_id}=    Get ControlNode Connection
+    Switch Connection    ${devstack_conn_id}
+    ${output}=    Write Commands Until Prompt    nova secgroup-create ${sg_name} ${desc}    40s
+    Close Connection
+
+Create Security Rule
+    [Arguments]    ${direction}    ${protocol}    ${min_port}    ${max_port}    ${remote_ip}    ${sg_name}
+    ${devstack_conn_id}=    Get ControlNode Connection
+    Switch Connection    ${devstack_conn_id}
+    ${output}=    Write Commands Until Prompt    neutron security-group-rule-create --direction ${direction} --protocol ${protocol} --port-range-min ${min_port} --port-range-max ${max_port} --remote-ip-prefix ${remote_ip} ${sg_name}
+    Close Connection