2 Documentation This suite is a common keywords file for genius project.
4 Library OperatingSystem
5 Library RequestsLibrary
9 Resource KarafKeywords.robot
11 Resource ../variables/Variables.robot
18 [Documentation] Create Rest Session to http://${ODL_SYSTEM_IP}:${RESTCONFPORT}
20 Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS} timeout=5
23 [Documentation] Delete all sessions
28 [Documentation] Initial setup for Genius test suites
29 Run_Keyword_If_At_Least_Oxygen Check Service Status ACTIVE OPERATIONAL
31 ${conn_id_1}= Open Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=30s
32 Set Global Variable ${conn_id_1}
33 KarafKeywords.Setup_Karaf_Keywords
34 ${karaf_debug_enabled} BuiltIn.Get_Variable_Value ${KARAF_DEBUG} ${False}
35 BuiltIn.run_keyword_if ${karaf_debug_enabled} KarafKeywords.Execute_Controller_Karaf_Command_On_Background log:set DEBUG org.opendaylight.genius
36 Login With Public Key ${TOOLS_SYSTEM_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
38 Execute Command sudo ovs-vsctl add-br BR1
39 Execute Command sudo ovs-vsctl set bridge BR1 protocols=OpenFlow13
40 Execute Command sudo ovs-vsctl set-controller BR1 tcp:${ODL_SYSTEM_IP}:6633
41 Execute Command sudo ifconfig BR1 up
42 Execute Command sudo ovs-vsctl add-port BR1 tap8ed70586-6c -- set Interface tap8ed70586-6c type=tap
43 Execute Command sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:6640
44 ${output_1} Execute Command sudo ovs-vsctl show
46 ${check} Wait Until Keyword Succeeds 30 10 check establishment ${conn_id_1} 6633
48 ${check_2} Wait Until Keyword Succeeds 30 10 check establishment ${conn_id_1} 6640
50 Log >>>>>Switch 2 configuration <<<<<
51 ${conn_id_2}= Open Connection ${TOOLS_SYSTEM_2_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=30s
52 Set Global Variable ${conn_id_2}
53 Login With Public Key ${TOOLS_SYSTEM_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
55 Execute Command sudo ovs-vsctl add-br BR2
56 Execute Command sudo ovs-vsctl set bridge BR2 protocols=OpenFlow13
57 Execute Command sudo ovs-vsctl set-controller BR2 tcp:${ODL_SYSTEM_IP}:6633
58 Execute Command sudo ifconfig BR2 up
59 Execute Command sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:6640
60 ${output_2} Execute Command sudo ovs-vsctl show
65 Switch Connection ${conn_id_1}
67 Execute Command sudo ovs-vsctl del-br BR1
68 Execute Command sudo ovs-vsctl del-manager
71 Switch Connection ${conn_id_2}
73 Execute Command sudo ovs-vsctl del-br BR2
74 Execute Command sudo ovs-vsctl del-manager
79 [Arguments] ${conn_id} ${port}
80 Switch Connection ${conn_id}
81 ${check_establishment} Execute Command netstat -anp | grep ${port}
82 Should contain ${check_establishment} ESTABLISHED
83 [Return] ${check_establishment}
86 [Arguments] ${system_ready_state} ${service_state}
87 [Documentation] Issues the karaf shell command showSvcStatus to verify the ready and service states are the same as the arguments passed
88 ${service_status_output} Issue_Command_On_Karaf_Console showSvcStatus ${ODL_SYSTEM_IP} 8101
89 Should Contain ${service_status_output} ${system_ready_state}
90 @{split} Split To Lines ${service_status_output} 3 7
91 : FOR ${var} IN @{split}
92 \ Should Contain ${var} ${service_state}
95 [Arguments] ${TOOLS_SYSTEM_IP} ${TOOLS_SYSTEM_2_IP} ${vlan} ${gateway-ip}
96 [Documentation] This keyword creates VTEPs between ${TOOLS_SYSTEM_IP} and ${TOOLS_SYSTEM_2_IP}
97 ${body} OperatingSystem.Get File ${genius_config_dir}/Itm_creation_no_vlan.json
98 ${substr} Should Match Regexp ${TOOLS_SYSTEM_IP} [0-9]\{1,3}\.[0-9]\{1,3}\.[0-9]\{1,3}\.
99 ${subnet} Catenate ${substr}0
101 Set Global Variable ${subnet}
102 ${vlan}= Set Variable ${vlan}
103 ${gateway-ip}= Set Variable ${gateway-ip}
104 ${body} Set Json ${TOOLS_SYSTEM_IP} ${TOOLS_SYSTEM_2_IP} ${vlan} ${gateway-ip} ${subnet}
105 ${vtep_body} Set Variable ${body}
106 Set Global Variable ${vtep_body}
107 ${resp} RequestsLibrary.Post Request session ${CONFIG_API}/itm:transport-zones/ data=${body}
108 Log ${resp.status_code}
109 should be equal as strings ${resp.status_code} 204
112 [Arguments] ${TOOLS_SYSTEM_IP} ${TOOLS_SYSTEM_2_IP} ${vlan} ${gateway-ip} ${subnet}
113 [Documentation] Sets Json with the values passed for it.
114 ${body} OperatingSystem.Get File ${genius_config_dir}/Itm_creation_no_vlan.json
115 ${body} replace string ${body} 1.1.1.1 ${subnet}
116 ${body} replace string ${body} "dpn-id": 101 "dpn-id": ${Dpn_id_1}
117 ${body} replace string ${body} "dpn-id": 102 "dpn-id": ${Dpn_id_2}
118 ${body} replace string ${body} "ip-address": "2.2.2.2" "ip-address": "${TOOLS_SYSTEM_IP}"
119 ${body} replace string ${body} "ip-address": "3.3.3.3" "ip-address": "${TOOLS_SYSTEM_2_IP}"
120 ${body} replace string ${body} "vlan-id": 0 "vlan-id": ${vlan}
121 ${body} replace string ${body} "gateway-ip": "0.0.0.0" "gateway-ip": "${gateway-ip}"
123 [Return] ${body} # returns complete json that has been updated
126 [Arguments] ${connection_id}
127 [Documentation] This keyword gets the DPN id of the switch after configuring bridges on it.It returns the captured DPN id.
128 Switch connection ${connection_id}
129 ${cmd} set Variable sudo ovs-vsctl show | grep Bridge | awk -F "\\"" '{print $2}'
130 ${Bridgename1} Execute command ${cmd}
132 ${output1} Execute command sudo ovs-ofctl show -O Openflow13 ${Bridgename1} | head -1 | awk -F "dpid:" '{ print $2 }'
134 # "echo \$\(\(16\#${output1}\)\) command below converts ovs dpnid (i.e., output1) from hexadecimal to decimal."
135 ${Dpn_id} Execute command echo \$\(\(16\#${output1}\)\)
140 [Documentation] Run at end of BFD suite
145 [Documentation] This will delete vtep.
146 ${resp} RequestsLibrary.Delete Request session ${CONFIG_API}/itm:transport-zones/ data=${vtep_body}
147 Log ${resp.status_code}
148 Should Be Equal As Strings ${resp.status_code} 200
149 Log "Before disconnecting CSS with controller"
150 ${output}= Issue Command On Karaf Console ${TEP_SHOW}
152 ${output}= Issue Command On Karaf Console ${TEP_SHOW_STATE}
156 [Arguments] ${data_models}
157 OVSDB.Get DumpFlows And Ovsconfig ${conn_id_1} BR1
158 OVSDB.Get DumpFlows And Ovsconfig ${conn_id_2} BR2
159 BuiltIn.Run Keyword And Ignore Error DataModels.Get Model Dump ${ODL_SYSTEM_IP} ${data_models}