Disable stale marking feature test
[integration/test.git] / csit / libraries / Genius.robot
1 *** Settings ***
2 Documentation     This suite is a common keywordis file for genius project.
3 Library           OperatingSystem
4 Library           RequestsLibrary
5 Library           SSHLibrary
6 Resource          ../variables/Variables.robot
7
8 *** Variables ***
9
10 *** Keywords ***
11 Create Vteps
12     [Arguments]    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}    ${vlan}    ${gateway-ip}
13     [Documentation]    This keyword creates VTEPs between ${TOOLS_SYSTEM_IP} and ${TOOLS_SYSTEM_2_IP}
14     ${body}    OperatingSystem.Get File    ${genius_config_dir}/Itm_creation_no_vlan.json
15     ${substr}    Should Match Regexp    ${TOOLS_SYSTEM_IP}    [0-9]\{1,3}\.[0-9]\{1,3}\.[0-9]\{1,3}\.
16     ${subnet}    Catenate    ${substr}0
17     Log    ${subnet}
18     Set Global Variable    ${subnet}
19     ${vlan}=    Set Variable    ${vlan}
20     ${gateway-ip}=    Set Variable    ${gateway-ip}
21     ${body}    Set Json    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}    ${vlan}    ${gateway-ip}    ${subnet}
22     ${vtep_body}    Set Variable    ${body}
23     Set Global Variable    ${vtep_body}
24     ${resp}    RequestsLibrary.Post Request    session    ${CONFIG_API}/itm:transport-zones/    data=${body}
25     Log    ${resp.status_code}
26     should be equal as strings    ${resp.status_code}    204
27
28 Set Json
29     [Arguments]    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}    ${vlan}    ${gateway-ip}    ${subnet}
30     [Documentation]    Sets Json with the values passed for it.
31     ${body}    OperatingSystem.Get File    ${genius_config_dir}/Itm_creation_no_vlan.json
32     ${body}    replace string    ${body}    1.1.1.1    ${subnet}
33     ${body}    replace string    ${body}    "dpn-id": 101    "dpn-id": ${Dpn_id_1}
34     ${body}    replace string    ${body}    "dpn-id": 102    "dpn-id": ${Dpn_id_2}
35     ${body}    replace string    ${body}    "ip-address": "2.2.2.2"    "ip-address": "${TOOLS_SYSTEM_IP}"
36     ${body}    replace string    ${body}    "ip-address": "3.3.3.3"    "ip-address": "${TOOLS_SYSTEM_2_IP}"
37     ${body}    replace string    ${body}    "vlan-id": 0    "vlan-id": ${vlan}
38     ${body}    replace string    ${body}    "gateway-ip": "0.0.0.0"    "gateway-ip": "${gateway-ip}"
39     Log    ${body}
40     [Return]    ${body}    # returns complete json that has been updated
41
42 Get Dpn Ids
43     [Arguments]    ${connection_id}
44     [Documentation]    This keyword gets the DPN id of the switch after configuring bridges on it.It returns the captured DPN id.
45     Switch connection    ${connection_id}
46     ${cmd}    set Variable    sudo ovs-vsctl show | grep Bridge | awk -F "\\"" '{print $2}'
47     ${Bridgename1}    Execute command    ${cmd}
48     log    ${Bridgename1}
49     ${output1}    Execute command    sudo ovs-ofctl show -O Openflow13 ${Bridgename1} | head -1 | awk -F "dpid:" '{ print $2 }'
50     log    ${output1}
51     # "echo \$\(\(16\#${output1}\)\) command below converts ovs dpnid (i.e., output1) from hexadecimal to decimal."
52     ${Dpn_id}    Execute command    echo \$\(\(16\#${output1}\)\)
53     log    ${Dpn_id}
54     [Return]    ${Dpn_id}
55
56 Delete All Sessions
57     [Documentation]    This will delete vtep.
58     ${resp}    RequestsLibrary.Delete Request    session    ${CONFIG_API}/itm:transport-zones/    data=${vtep_body}
59     Log    ${resp.status_code}
60     Should Be Equal As Strings    ${resp.status_code}    200
61     Log    "Before disconnecting CSS with controller"
62     ${output}=    Issue Command On Karaf Console    ${TEP_SHOW}
63     Log    ${output}
64     ${output}=    Issue Command On Karaf Console    ${TEP_SHOW_STATE}
65     Log    ${output}