Remove variables and scripts for netvirt
[integration/test.git] / csit / libraries / SFC / DockerSfc.robot
1 *** Settings ***
2 Library     SSHLibrary
3
4
5 *** Variables ***
6 ${INTEGRATION_BRIDGE}                   br-int
7
8
9 *** Keywords ***
10 Docker Ovs Start
11     [Documentation]    Run the docker-ovs.sh script with specific input arguments. Run ./docker-ovs.sh --help for more info.
12     [Arguments]    ${nodes}    ${guests}    ${tunnel}    ${odl_ip}    ${log_file}=myFile2.log
13     ${result}    SSHLibrary.Execute Command
14     ...    ./docker-ovs.sh spawn --nodes=${nodes} --guests=${guests} --tun=${tunnel} --odl=${odl_ip} > >(tee ${log_file}) 2> >(tee ${log_file})
15     ...    return_stderr=True
16     ...    return_stdout=True
17     ...    return_rc=True
18     log    ${result}
19     Should be equal as integers    ${result[2]}    0
20
21 Docker Ovs Clean
22     [Documentation]    Run the docker-ovs.sh script with --clean option to clean up all containers deployment. Run ./docker-ovs.sh --help for more info.
23     [Arguments]    ${log_file}=myFile3.log
24     ${result}    SSHLibrary.Execute Command
25     ...    ./docker-ovs.sh clean > >(tee ${log_file}) 2> >(tee ${log_file})
26     ...    return_stderr=True
27     ...    return_stdout=True
28     ...    return_rc=True
29     log    ${result}
30     Should be equal as integers    ${result[2]}    0
31
32 Get Docker Ids
33     [Documentation]    Execute command docker ps and retrieve the existing containers ids
34     ${output}    ${rc}    SSHLibrary.Execute Command
35     ...    sudo docker ps -q -a
36     ...    return_stdout=True
37     ...    return_stderr=False
38     ...    return_rc=True
39     Should Be Equal As Numbers    ${rc}    0
40     RETURN    ${output}
41
42 Get Docker Ids Formatted
43     [Documentation]    Execute command docker ps with --format argument and retrieve the existing containers names
44     [Arguments]    ${format}
45     ${output}    ${rc}    SSHLibrary.Execute Command
46     ...    sudo docker ps -a --format ${format}
47     ...    return_stdout=True
48     ...    return_stderr=False
49     ...    return_rc=True
50     Should Be Equal As Numbers    ${rc}    0
51     RETURN    ${output}
52
53 Get Docker Names As List
54     [Documentation]    Returns a list with the names of all running containers inside the tools system
55     ${docker_ps}    DockerSfc.Get Docker Ids Formatted    "{{.Names}}" -f status=running
56     ${docker_name_list}    Split String    ${docker_ps}    \n
57     RETURN    ${docker_name_list}
58
59 Get Docker IP
60     [Documentation]    Obtain the IP address from a given container
61     [Arguments]    ${docker_name}
62     ${output}    ${rc}    SSHLibrary.Execute Command
63     ...    sudo docker inspect -f '{{.NetworkSettings.IPAddress }}' ${docker_name}
64     ...    return_stdout=True
65     ...    return_stderr=False
66     ...    return_rc=True
67     Should Be Equal As Numbers    ${rc}    0
68     RETURN    ${output}
69
70 Docker Exec
71     [Documentation]    Execute a command into a docker container.
72     [Arguments]    ${docker_name}    ${command}    ${return_contains}=${EMPTY}    ${result_code}=0
73     ${output}    ${rc}    SSHLibrary.Execute Command
74     ...    sudo docker exec ${docker_name} ${command}
75     ...    return_stdout=True
76     ...    return_stderr=False
77     ...    return_rc=True
78     IF    '${return_contains}'!='${EMPTY}'
79         Should Contain    ${output}    ${return_contains}
80     END
81     Should Be Equal As Numbers    ${rc}    ${result_code}
82     RETURN    ${output}
83
84 Multiple Docker Exec
85     [Documentation]    Execute a command in a list of dockers and return all the outputs in a list
86     [Arguments]    ${docker_name_list}    ${command}    ${return_contains}=${EMPTY}    ${result_code}=0
87     @{list_output}    Create List
88     FOR    ${docker_id}    IN    @{docker_name_list}
89         ${exec_output}    Docker Exec    ${docker_id}    ${command}    ${return_contains}    ${result_code}
90         Append To List    ${list_output}    ${exec_output}
91     END
92     RETURN    ${list_output}
93
94 Get Flows In Docker Containers
95     ${docker_list}    DockerSfc.Get Docker Names As List
96     ${docker_flows}    DockerSfc.Multiple Docker Exec
97     ...    ${docker_list}
98     ...    ovs-ofctl dump-flows -OOpenflow13 ${INTEGRATION_BRIDGE}
99     ...    OFPST_FLOW
100     RETURN    ${docker_flows}
101
102 Get Docker Bridge Subnet
103     [Documentation]    Obtain the subnet used by docker bridge using the docker inspect tool
104     ${output}    ${rc}    SSHLibrary.Execute Command
105     ...    sudo docker network inspect bridge --format {{.IPAM.Config}} | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}[\/][0-9]{1,2}"
106     ...    return_stdout=True
107     ...    return_stderr=False
108     ...    return_rc=True
109     Should Be Equal As Numbers    ${rc}    0
110     RETURN    ${output}