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