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