5 Library RequestsLibrary
10 Variables ../variables/Variables.py
11 Resource ./CompareStream.robot
12 Resource ./Utils.robot
13 Resource ./MininetKeywords.robot
16 ${vlan_topo} --custom vlan_vtn_test.py --topo vlantopo
17 ${vtn_coordinator_nexus_path} https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/org/opendaylight/vtn/distribution.vtn-coordinator
18 ${vtn_dist} distribution.vtn-coordinator
22 [Documentation] Download the VTN Coordinator from Controller VM
23 Log Download the VTN Coordinator bz2 file
24 SSHLibrary.Open_Connection ${ODL_SYSTEM_IP}
25 SSHLibrary.Login_With_Public_Key ${ODL_SYSTEM_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
26 ${VTNC_FILENAME}= Catenate SEPARATOR=/ ${WORKSPACE} vtn_coordinator.tar.bz2
27 SSHLibrary.Get_File ${WORKSPACE}/${BUNDLEFOLDER}/externalapps/*vtn-coordinator*-bin.tar.bz2 ${VTNC_FILENAME}
28 SSHLibrary.Close_Connection
29 SSHLibrary.Open_Connection ${TOOLS_SYSTEM_IP}
30 SSHLibrary.Login_With_Public_Key ${TOOLS_SYSTEM_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
31 SSHLibrary.Put_File ${VTNC_FILENAME} /tmp
32 SSHLibrary.Close_Connection
35 [Documentation] Download and startup the VTN Coordinator.
36 Log Start the VTN Coordinator
38 ${vtnc_conn_id}= SSHLibrary.Open Connection ${ODL_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=30s
39 Set Suite Variable ${vtnc_conn_id}
40 SSHLibrary.Login_With_Public_Key ${ODL_SYSTEM_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
41 SSHLibrary.Execute Command sudo mkdir -p /usr/local/vtn
42 SSHLibrary.Execute Command sudo chown jenkins /usr/local/vtn
43 SSHLibrary.Execute Command sudo yum install -q -y https://download.postgresql.org/pub/repos/yum/9.3/redhat/rhel-7-x86_64/pgdg-centos93-9.3-3.noarch.rpm
44 SSHLibrary.Execute Command sudo yum install -q -y postgresql93-libs postgresql93 postgresql93-server postgresql93-contrib postgresql93-odbc
45 CompareStream.Run_Keyword_If_At_Least_Else boron Download VtnCo Distribution
46 ... ELSE SSHLibrary.Execute Command tar -C/ -jxvf ${WORKSPACE}/${BUNDLEFOLDER}/externalapps/${vtn_dist}*-bin.tar.bz2
47 SSHLibrary.Execute Command /usr/local/vtn/sbin/db_setup
48 SSHLibrary.Execute Command /usr/local/vtn/bin/vtn_start
49 SSHLibrary.Execute Command /usr/local/vtn/bin/unc_dmctl status
50 SSHLibrary.Execute Command /usr/local/vtn/sbin/db_setup
51 SSHLibrary.Execute Command sed -i 's/odcdrv_ping_interval = 30/odcdrv_ping_interval = 10/g' /usr/local/vtn/modules/odcdriver.conf
52 SSHLibrary.Execute Command sed -i 's/physical_attributes_read_interval = 40/physical_attributes_read_interval = 15/g' /usr/local/vtn/modules/vtndrvintf.conf
53 SSHLibrary.Execute Command /usr/local/vtn/bin/vtn_start
54 SSHLibrary.Execute Command /usr/local/vtn/bin/unc_dmctl status
55 SSHLibrary.Execute Command /usr/local/vtn/bin/drvodc_control loglevel trace
56 SSHLibrary.Execute Command /usr/local/vtn/bin/lgcnw_control loglevel trace
57 SSHLibrary.Execute Command exit
59 Download VtnCo Distribution
60 # TODO: https://trello.com/c/fDiIUFMv/431-remove-hardcoded-versions-of-vtn-coordinator-in-libraries-vtncokeywords-robot
61 SSHLibrary.Execute Command wget "${vtn_coordinator_nexus_path}/maven-metadata.xml"
62 CompareStream.Run_Keyword_If_At_Least_Boron SSHLibrary.Get_file maven-metadata.xml
63 ${boron_version}= XML.Get Element Text maven-metadata.xml xpath=.//versions/version[1]
64 ${boron_version_val}= SSHLibrary.Execute Command echo ${boron_version} | awk -F"-" '{print $1}'
65 ${carbon_version}= XML.Get Element Text maven-metadata.xml xpath=.//versions/version[2]
66 ${carbon_version_val}= SSHLibrary.Execute Command echo ${carbon_version} | awk -F"-" '{print $1}'
67 ${nitrogen_version}= XML.Get Element Text maven-metadata.xml xpath=.//versions/version[3]
68 ${nitrogen_version_val}= SSHLibrary.Execute Command echo ${carbon_version} | awk -F"-" '{print $1}'
69 SSHLibrary.Execute Command sudo mv maven-metadata.xml old-maven-metadata.xml
70 CompareStream.Run_Keyword_If_Equals boron SSHLibrary.Execute Command wget "${vtn_coordinator_nexus_path}/${boron_version}/maven-metadata.xml"
71 CompareStream.Run_Keyword_If_Equals carbon SSHLibrary.Execute Command wget "${vtn_coordinator_nexus_path}/${carbon_version}/maven-metadata.xml"
72 CompareStream.Run_Keyword_If_Equals nitrogen SSHLibrary.Execute Command wget "${vtn_coordinator_nexus_path}/${nitrogen_version}/maven-metadata.xml"
73 CompareStream.Run_Keyword_If_At_Least_Boron SSHLibrary.Get_file maven-metadata.xml
74 ${value}= XML.Get Element Text maven-metadata.xml xpath=.//snapshotVersion[1]/value
75 CompareStream.Run_Keyword_If_Equals boron SSHLibrary.Execute Command wget '${vtn_coordinator_nexus_path}/${boron_version}/${vtn_dist}-${value}-bin.tar.bz2'
76 CompareStream.Run_Keyword_If_Equals carbon SSHLibrary.Execute Command wget '${vtn_coordinator_nexus_path}/${carbon_version}/${vtn_dist}-${value}-bin.tar.bz2'
77 CompareStream.Run_Keyword_If_Equals nitrogen SSHLibrary.Execute Command wget '${vtn_coordinator_nexus_path}/${nitrogen_version}/${vtn_dist}-${value}-bin.tar.bz2'
78 SSHLibrary.Execute Command tar -C/ -jxvf ${vtn_dist}*-bin.tar.bz2
81 [Documentation] Exit the Launch Test
82 Log Stop the Launch Test
85 [Documentation] Start the VTNCo Test
86 Create Session session http://${ODL_SYSTEM_IP}:8083 headers=${VTNC_HEADERS}
89 [Documentation] Exit the VtnCo Test
92 Get Coordinator Version
93 [Documentation] Get API version for testing
94 ${resp} RequestsLibrary.Get Request session ${VTNWEBAPI}/api_version
95 Should Be Equal As Strings ${resp.status_code} 200
98 [Arguments] ${ctrlname} ${ctrlip}
99 [Documentation] Create a controller
100 ${controllerinfo} Create Dictionary controller_id=${ctrlname} type=odc ipaddr=${ctrlip} version=1.0
101 ${controllercreate} Create Dictionary controller=${controllerinfo}
102 ${controllercreate_json}= json.dumps ${controllercreate}
103 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${CTRLS_CREATE} data=${controllercreate_json}
104 Should Be Equal As Strings ${resp.status_code} 201
107 [Arguments] ${ctrlname}
108 [Documentation] Delete a Controller
109 ${resp} RequestsLibrary.Delete Request session ${VTNWEBAPI}/${CTRLS}/${ctrlname}.json
110 Should Be Equal As Strings ${resp.status_code} 204
113 [Arguments] ${ctrlname} ${ctrlip} ${desc}
114 [Documentation] Update controller
115 ${controllerinfo} Create Dictionary description=${desc} ipaddr=${ctrlip} version=1.0
116 ${controllerupdate} Create Dictionary controller=${controllerinfo}
117 ${controllerupdate_json}= json.dumps ${controllerupdate}
118 ${resp} RequestsLibrary.Put Request session ${VTNWEBAPI}/${CTRLS}/${ctrlname}.json data=${controllerupdate_json}
119 Should Be Equal As Strings ${resp.status_code} 204
122 [Arguments] ${ctrlname}
123 [Documentation] Trigger Manual Audit
124 ${auditinfo} Create Dictionary force=false real-network_audit=false
125 ${auditupdate} Create Dictionary audit=${auditinfo}
126 ${auditupdate_json}= json.dumps ${auditupdate}
127 ${resp} RequestsLibrary.Put Request session ${VTNWEBAPI}/${CTRLS}/${ctrlname}/audit.json data=${auditupdate_json}
128 Should Be Equal As Strings ${resp.status_code} 204
130 Check Controller Status
131 [Arguments] ${ctrlname} ${stat}
132 [Documentation] Get controller status
133 ${resp} RequestsLibrary.Get Request session ${VTNWEBAPI}/${CTRLS}/${ctrlname}.json
134 ${contents} To JSON ${resp.content}
135 ${controllerblock} Get From Dictionary ${contents} controller
136 ${status} Get From Dictionary ${controllerblock} operstatus
137 Should Be Equal As Strings ${status} ${stat}
140 [Arguments] ${vtnname} ${vtndescription}
141 [Documentation] Create VTN in Coordinator
142 ${vtninfo} Create Dictionary vtn_name=${vtnname} description=${vtndescription}
143 ${vtncreate} Create Dictionary vtn=${vtninfo}
144 ${vtncreate_json}= json.dumps ${vtncreate}
145 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS_CREATE} data=${vtncreate_json}
146 Should Be Equal As Strings ${resp.status_code} 201
149 [Arguments] ${vtnname}
150 [Documentation] Delete a VTN Created
151 ${resp} RequestsLibrary.Delete Request session ${VTNWEBAPI}/${VTNS}/${vtnname}.json
152 Should Be Equal As Strings ${resp.status_code} 204
155 [Arguments] ${vtnname} ${vbrname} ${ctrlname}
156 [Documentation] Create VBR for VTN in Coordinator
157 ${vbrinfo} Create Dictionary vbr_name=${vbrname} controller_id=${ctrlname} domain_id=(DEFAULT)
158 ${vbrcreate} Create Dictionary vbridge=${vbrinfo}
159 ${vbrcreate_json}= json.dumps ${vbrcreate}
160 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS_CREATE} data=${vbrcreate_json}
161 Run Keyword If '${vbrname}' == 'Vbr_audit' Should Be Equal As Strings ${resp.status_code} 202
162 ... ELSE Should Be Equal As Strings ${resp.status_code} 201
165 [Arguments] ${vtnname} ${vbrname} ${vbrifname} ${ifdescription} ${retcode}
166 [Documentation] Create VBR Interface in VBR
167 ${vbrifinfo} Create Dictionary if_name=${vbrifname} description=${ifdescription}
168 ${vbrifcreate} Create Dictionary interface=${vbrifinfo}
169 ${vbrifcreate_json}= json.dumps ${vbrifcreate}
170 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${VBRIFS_CREATE} data=${vbrifcreate_json}
171 Should Be Equal As Strings ${resp.status_code} ${retcode}
173 Define Portmap for VBRIF
174 [Arguments] ${vtnname} ${vbrname} ${vbrifname} ${logical_port_id}
175 [Documentation] Map Interface to a logical port
176 ${logical_port_info} Create Dictionary logical_port_id=${logical_port_id}
177 ${portmapdefine} Create Dictionary portmap=${logical_port_info}
178 ${portmapdefine_json}= json.dumps ${portmapdefine}
179 ${resp} RequestsLibrary.Put Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${VBRIFS}/${vbrifname}/${PORTMAP_CREATE} data=${portmapdefine_json}
180 Should Be Equal As Strings ${resp.status_code} 204
183 [Arguments] ${flowlistname} ${ipversion}
184 [Documentation] Create FLOWLIST in Coordinator
185 ${flowlistinfo} Create Dictionary fl_name=${flowlistname} ip_version=${ipversion}
186 ${flowlistcreate} Create Dictionary flowlist=${flowlistinfo}
187 ${flowlistcreate_json}= json.dumps ${flowlistcreate}
188 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${FLOWLISTS_CREATE} data=${flowlistcreate_json}
189 Should Be Equal As Strings ${resp.status_code} 201
192 [Arguments] ${flowlistname}
193 [Documentation] Create Flowlistentry for Coordinator
194 ${flowlistentryinfo} Create Dictionary seqnum=233 macethertype=0x800 ipdstaddr=10.0.0.1 ipdstaddrprefix=32 ipsrcaddr=10.0.0.3
195 ... ipsrcaddrprefix=32 ipproto=1
196 ${flowlistentrycreate} Create Dictionary flowlistentry=${flowlistentryinfo}
197 ${flowlistentrycreate_json}= json.dumps ${flowlistentrycreate}
198 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${FLOWLISTS}/${flowlistname}/${FLOWLISTENTRIES_CREATE} data=${flowlistentrycreate_json}
199 Should Be Equal As Strings ${resp.status_code} 201
201 Create FLOWLISTENTRY_ANY in FLOWLIST
202 [Arguments] ${flowlistname}
203 [Documentation] Create Flowlistentry_any for Coordinator
204 ${flowlistentryinfo} Create Dictionary seqnum=1
205 ${flowlistentrycreate} Create Dictionary flowlistentry=${flowlistentryinfo}
206 ${flowlistentrycreate_json}= json.dumps ${flowlistentrycreate}
207 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${FLOWLISTS}/${flowlistname}/${FLOWLISTENTRIES_CREATE} data=${flowlistentrycreate_json}
208 Should Be Equal As Strings ${resp.status_code} 201
210 Create VBRIF in FLOWFILTER
211 [Arguments] ${vtnname} ${vbrname} ${vbrifname} ${ff_type}
212 [Documentation] create vbridge interface flowfilter
213 ${flowfilters_info} Create Dictionary ff_type=${ff_type}
214 ${flowfiltersdefine} Create Dictionary flowfilter=${flowfilters_info}
215 ${flowfiltersdefine_json}= json.dumps ${flowfiltersdefine}
216 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${VBRIFS}/${vbrifname}/${FLOWFILTERS_CREATE} data=${flowfiltersdefine_json}
217 Should Be Equal As Strings ${resp.status_code} 201
219 Create FLOWFILTERENTRY DROP In VBRIFFLOWFILTER
220 [Arguments] ${vtnname} ${vbrname} ${vbrifname} ${actiontype}
221 [Documentation] create domonstration with pass actiontype
222 ${flowfilterentryinfo} Create Dictionary seqnum=233 fl_name=Flowlist1 action_type=${actiontype} priority=3 dscp=55
223 ${flowfilterentrycreate} Create Dictionary flowfilterentry=${flowfilterentryinfo}
224 ${flowfilterentrycreate_json}= json.dumps ${flowfilterentrycreate}
225 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${VBRIFS}/${vbrifname}/${FLOWFILTERS}/${FLOWFILTERENTRIES_CREATE} data=${flowfilterentrycreate_json}
226 Should Be Equal As Strings ${resp.status_code} 201
228 Create FLOWFILTERENTRY PASS In VBRIFFLOWFILTER
229 [Arguments] ${vtnname} ${vbrname} ${vbrifname} ${actiontype} ${seqnum}
230 [Documentation] create domonstration with pass actiontype
231 ${flowfilterentryinfo} Create Dictionary fl_name=Flowlist1 action_type=${actiontype} priority=3 dscp=55
232 ${flowfilterentrycreate} Create Dictionary flowfilterentry=${flowfilterentryinfo}
233 ${flowfilterentrycreate_json}= json.dumps ${flowfilterentrycreate}
234 ${resp} RequestsLibrary.Put Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${VBRIFS}/${vbrifname}/${FLOWFILTERS}/${FLOWFILTERS_UPDATE}/${seqnum} data=${flowfilterentrycreate_json}
235 Should Be Equal As Strings ${resp.status_code} 204
237 Create FLOWFILTER in VBR
238 [Arguments] ${vtnname} ${vbrname} ${ff_type}
239 [Documentation] create vtn flowfilter
240 ${flowfilters_info} Create Dictionary ff_type=${ff_type}
241 ${flowfiltersdefine} Create Dictionary flowfilter=${flowfilters_info}
242 ${flowfiltersdefine_json}= json.dumps ${flowfiltersdefine}
243 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${FLOWFILTERS_CREATE} data=${flowfiltersdefine_json}
244 Should Be Equal As Strings ${resp.status_code} 201
246 Create FLOWFILTERENTRY PASS in VBRFLOWFILTER
247 [Arguments] ${vtnname} ${vbrname} ${actiontype}
248 [Documentation] create domonstration with pass actiontype
249 ${flowfilterentryinfo} Create Dictionary seqnum=233 fl_name=Flowlist1 action_type=${actiontype} priority=3 dscp=55
250 ${flowfilterentryinfo_1} Create Dictionary vnode_name=${vbrname} fl_name=Flowlist1 direction=in
251 ${flowfilterentrycreate} Create Dictionary flowfilterentry=${flowfilterentryinfo}
252 ${flowfilterentrycreate_json}= json.dumps ${flowfilterentrycreate}
253 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${FLOWFILTERS}/${FLOWFILTERENTRIES_CREATE} data=${flowfilterentrycreate_json}
254 Should Be Equal As Strings ${resp.status_code} 201
256 Create FLOWFILTER in VTN
257 [Arguments] ${vtnname} ${ff_type}
258 [Documentation] create vtn flowfilter
259 ${flowfilters_info} Create Dictionary ff_type=${ff_type}
260 ${flowfiltersdefine} Create Dictionary flowfilter=${flowfilters_info}
261 ${flowfiltersdefine_json}= json.dumps ${flowfiltersdefine}
262 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${FLOWFILTERS_CREATE} data=${flowfiltersdefine_json}
263 Should Be Equal As Strings ${resp.status_code} 201
265 Create FLOWFILTERENTRY PASS in VTNFLOWFILTER
266 [Arguments] ${vtnname} ${actiontype}
267 [Documentation] create domonstration with pass actiontype
268 ${flowfilterentryinfo} Create Dictionary seqnum=233 fl_name=Flowlist1 action_type=${actiontype} priority=3 dscp=55
269 ${flowfilterentrycreate} Create Dictionary flowfilterentry=${flowfilterentryinfo}
270 ${flowfilterentrycreate_json}= json.dumps ${flowfilterentrycreate}
271 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${FLOWFILTERS}/${FLOWFILTERENTRIES_CREATE} data=${flowfilterentrycreate_json}
272 Should Be Equal As Strings ${resp.status_code} 201
274 Create VLANMAP in VBRIDGE
275 [Arguments] ${vtnname} ${vbrname} ${vlanid}
276 [Documentation] Create VLANMAP for VBRIDGE in Coordinator
277 ${vlaninfo} Create Dictionary vlan_id=${vlanid}
278 ${vlancreate} Create Dictionary vlanmap=${vlaninfo}
279 ${vlancreate_json}= json.dumps ${vlancreate}
280 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${VLANMAP_CREATE } data=${vlancreate_json}
281 Should Be Equal As Strings ${resp.status_code} 201
284 [Documentation] This will start mininet with custom topology on both the Virtual Machines
285 Install Package On Ubuntu System vlan
286 MininetKeywords.Start Mininet Single Controller ${TOOLS_SYSTEM_IP} ${ODL_SYSTEM_IP} ${vlan_topo} ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
289 [Arguments] ${flowlistname}
290 [Documentation] Delete a Flowlist
291 ${resp} RequestsLibrary.Delete Request session ${VTNWEBAPI}/${FLOWLISTS}/${flowlistname}.json
292 Should Be Equal As Strings ${resp.status_code} 204
295 [Arguments] ${host1} ${host2}
296 [Documentation] Ping hosts to check connectivity
297 Write ${host1} ping -c 1 ${host2}
298 ${result} Read Until mininet>
299 Should Contain ${result} 64 bytes
302 [Arguments] ${ctrlname} ${switch_id}
303 [Documentation] Get switch
304 ${resp} RequestsLibrary.Get Request session ${VTNWEBAPI}/${CTRLS}/${ctrlname}/${SW}/${switch_id}.json
305 ${contents} To JSON ${resp.content}
306 ${switchblock} Get From Dictionary ${contents} switch
307 ${status} Get From Dictionary ${switchblock} switch_id
308 Should Be Equal As Strings ${status} ${switch_id}
311 [Arguments] ${ctrlname} ${switch_id}
312 [Documentation] Get switch
313 ${resp} RequestsLibrary.Get Request session ${VTNWEBAPI}/${CTRLS}/${ctrlname}/${SW}/${switch_id}/${PORTS}
314 Should Be Equal As Strings ${resp.status_code} 200