3 Resource ../../variables/netvirt/Variables.robot
8 [Documentation] Run the docker-ovs.sh script with specific input arguments. Run ./docker-ovs.sh --help for more info.
9 [Arguments] ${nodes} ${guests} ${tunnel} ${odl_ip} ${log_file}=myFile2.log
10 ${result} SSHLibrary.Execute Command
11 ... ./docker-ovs.sh spawn --nodes=${nodes} --guests=${guests} --tun=${tunnel} --odl=${odl_ip} > >(tee ${log_file}) 2> >(tee ${log_file})
12 ... return_stderr=True
13 ... return_stdout=True
16 Should be equal as integers ${result[2]} 0
19 [Documentation] Run the docker-ovs.sh script with --clean option to clean up all containers deployment. Run ./docker-ovs.sh --help for more info.
20 [Arguments] ${log_file}=myFile3.log
21 ${result} SSHLibrary.Execute Command
22 ... ./docker-ovs.sh clean > >(tee ${log_file}) 2> >(tee ${log_file})
23 ... return_stderr=True
24 ... return_stdout=True
27 Should be equal as integers ${result[2]} 0
30 [Documentation] Execute command docker ps and retrieve the existing containers ids
31 ${output} ${rc} SSHLibrary.Execute Command
32 ... sudo docker ps -q -a
33 ... return_stdout=True
34 ... return_stderr=False
36 Should Be Equal As Numbers ${rc} 0
39 Get Docker Ids Formatted
40 [Documentation] Execute command docker ps with --format argument and retrieve the existing containers names
42 ${output} ${rc} SSHLibrary.Execute Command
43 ... sudo docker ps -a --format ${format}
44 ... return_stdout=True
45 ... return_stderr=False
47 Should Be Equal As Numbers ${rc} 0
50 Get Docker Names As List
51 [Documentation] Returns a list with the names of all running containers inside the tools system
52 ${docker_ps} DockerSfc.Get Docker Ids Formatted "{{.Names}}" -f status=running
53 ${docker_name_list} Split String ${docker_ps} \n
54 RETURN ${docker_name_list}
57 [Documentation] Obtain the IP address from a given container
58 [Arguments] ${docker_name}
59 ${output} ${rc} SSHLibrary.Execute Command
60 ... sudo docker inspect -f '{{.NetworkSettings.IPAddress }}' ${docker_name}
61 ... return_stdout=True
62 ... return_stderr=False
64 Should Be Equal As Numbers ${rc} 0
68 [Documentation] Execute a command into a docker container.
69 [Arguments] ${docker_name} ${command} ${return_contains}=${EMPTY} ${result_code}=0
70 ${output} ${rc} SSHLibrary.Execute Command
71 ... sudo docker exec ${docker_name} ${command}
72 ... return_stdout=True
73 ... return_stderr=False
75 IF '${return_contains}'!='${EMPTY}'
76 Should Contain ${output} ${return_contains}
78 Should Be Equal As Numbers ${rc} ${result_code}
82 [Documentation] Execute a command in a list of dockers and return all the outputs in a list
83 [Arguments] ${docker_name_list} ${command} ${return_contains}=${EMPTY} ${result_code}=0
84 @{list_output} Create List
85 FOR ${docker_id} IN @{docker_name_list}
86 ${exec_output} Docker Exec ${docker_id} ${command} ${return_contains} ${result_code}
87 Append To List ${list_output} ${exec_output}
91 Get Flows In Docker Containers
92 ${docker_list} DockerSfc.Get Docker Names As List
93 ${docker_flows} DockerSfc.Multiple Docker Exec
95 ... ovs-ofctl dump-flows -OOpenflow13 ${INTEGRATION_BRIDGE}
97 RETURN ${docker_flows}
99 Get Docker Bridge Subnet
100 [Documentation] Obtain the subnet used by docker bridge using the docker inspect tool
101 ${output} ${rc} SSHLibrary.Execute Command
102 ... sudo docker network inspect bridge --format {{.IPAM.Config}} | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}[\/][0-9]{1,2}"
103 ... return_stdout=True
104 ... return_stderr=False
106 Should Be Equal As Numbers ${rc} 0