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 Download VtnCo Distribution
46 SSHLibrary.Execute Command /usr/local/vtn/sbin/db_setup
47 SSHLibrary.Execute Command /usr/local/vtn/bin/vtn_start
48 SSHLibrary.Execute Command /usr/local/vtn/bin/unc_dmctl status
49 SSHLibrary.Execute Command /usr/local/vtn/sbin/db_setup
50 SSHLibrary.Execute Command sed -i 's/odcdrv_ping_interval = 30/odcdrv_ping_interval = 10/g' /usr/local/vtn/modules/odcdriver.conf
51 SSHLibrary.Execute Command sed -i 's/physical_attributes_read_interval = 40/physical_attributes_read_interval = 15/g' /usr/local/vtn/modules/vtndrvintf.conf
52 SSHLibrary.Execute Command /usr/local/vtn/bin/vtn_start
53 SSHLibrary.Execute Command /usr/local/vtn/bin/unc_dmctl status
54 SSHLibrary.Execute Command /usr/local/vtn/bin/drvodc_control loglevel trace
55 SSHLibrary.Execute Command /usr/local/vtn/bin/lgcnw_control loglevel trace
56 SSHLibrary.Execute Command exit
58 Download VtnCo Distribution
59 # TODO: https://trello.com/c/fDiIUFMv/431-remove-hardcoded-versions-of-vtn-coordinator-in-libraries-vtncokeywords-robot
60 SSHLibrary.Execute Command wget "${vtn_coordinator_nexus_path}/maven-metadata.xml"
61 SSHLibrary.Get_file maven-metadata.xml
62 ${carbon_version}= XML.Get Element Text maven-metadata.xml xpath=.//versions/version[1]
63 ${carbon_version_val}= SSHLibrary.Execute Command echo ${carbon_version} | awk -F"-" '{print $1}'
64 ${nitrogen_version}= XML.Get Element Text maven-metadata.xml xpath=.//versions/version[2]
65 ${nitrogen_version_val}= SSHLibrary.Execute Command echo ${nitrogen_version} | awk -F"-" '{print $1}'
66 ${oxygen_version}= XML.Get Element Text maven-metadata.xml xpath=.//versions/version[3]
67 ${oxygen_version_val}= SSHLibrary.Execute Command echo ${oxygen_version} | awk -F"-" '{print $1}'
68 SSHLibrary.Execute Command sudo mv maven-metadata.xml old-maven-metadata.xml
69 CompareStream.Run_Keyword_If_Equals carbon SSHLibrary.Execute Command wget "${vtn_coordinator_nexus_path}/${carbon_version}/maven-metadata.xml"
70 CompareStream.Run_Keyword_If_Equals nitrogen SSHLibrary.Execute Command wget "${vtn_coordinator_nexus_path}/${nitrogen_version}/maven-metadata.xml"
71 CompareStream.Run_Keyword_If_Equals oxygen SSHLibrary.Execute Command wget "${vtn_coordinator_nexus_path}/${oxygen_version}/maven-metadata.xml"
72 SSHLibrary.Get_file maven-metadata.xml
73 ${value}= XML.Get Element Text maven-metadata.xml xpath=.//snapshotVersion[1]/value
74 CompareStream.Run_Keyword_If_Equals carbon SSHLibrary.Execute Command wget '${vtn_coordinator_nexus_path}/${carbon_version}/${vtn_dist}-${value}-bin.tar.bz2'
75 CompareStream.Run_Keyword_If_Equals nitrogen SSHLibrary.Execute Command wget '${vtn_coordinator_nexus_path}/${nitrogen_version}/${vtn_dist}-${value}-bin.tar.bz2'
76 CompareStream.Run_Keyword_If_Equals oxygen SSHLibrary.Execute Command wget '${vtn_coordinator_nexus_path}/${oxygen_version}/${vtn_dist}-${value}-bin.tar.bz2'
77 SSHLibrary.Execute Command tar -C/ -jxvf ${vtn_dist}*-bin.tar.bz2
80 [Documentation] Exit the Launch Test
81 Log Stop the Launch Test
84 [Documentation] Start the VTNCo Test
85 Create Session session http://${ODL_SYSTEM_IP}:8083 headers=${VTNC_HEADERS}
88 [Documentation] Exit the VtnCo Test
91 Get Coordinator Version
92 [Documentation] Get API version for testing
93 ${resp} RequestsLibrary.Get Request session ${VTNWEBAPI}/api_version
94 Should Be Equal As Strings ${resp.status_code} 200
97 [Arguments] ${ctrlname} ${ctrlip}
98 [Documentation] Create a controller
99 ${controllerinfo} Create Dictionary controller_id=${ctrlname} type=odc ipaddr=${ctrlip} version=1.0
100 ${controllercreate} Create Dictionary controller=${controllerinfo}
101 ${controllercreate_json}= json.dumps ${controllercreate}
102 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${CTRLS_CREATE} data=${controllercreate_json}
103 Should Be Equal As Strings ${resp.status_code} 201
106 [Arguments] ${ctrlname}
107 [Documentation] Delete a Controller
108 ${resp} RequestsLibrary.Delete Request session ${VTNWEBAPI}/${CTRLS}/${ctrlname}.json
109 Should Be Equal As Strings ${resp.status_code} 204
112 [Arguments] ${ctrlname} ${ctrlip} ${desc}
113 [Documentation] Update controller
114 ${controllerinfo} Create Dictionary description=${desc} ipaddr=${ctrlip} version=1.0
115 ${controllerupdate} Create Dictionary controller=${controllerinfo}
116 ${controllerupdate_json}= json.dumps ${controllerupdate}
117 ${resp} RequestsLibrary.Put Request session ${VTNWEBAPI}/${CTRLS}/${ctrlname}.json data=${controllerupdate_json}
118 Should Be Equal As Strings ${resp.status_code} 204
121 [Arguments] ${ctrlname}
122 [Documentation] Trigger Manual Audit
123 ${auditinfo} Create Dictionary force=false real-network_audit=false
124 ${auditupdate} Create Dictionary audit=${auditinfo}
125 ${auditupdate_json}= json.dumps ${auditupdate}
126 ${resp} RequestsLibrary.Put Request session ${VTNWEBAPI}/${CTRLS}/${ctrlname}/audit.json data=${auditupdate_json}
127 Should Be Equal As Strings ${resp.status_code} 204
129 Check Controller Status
130 [Arguments] ${ctrlname} ${stat}
131 [Documentation] Get controller status
132 ${resp} RequestsLibrary.Get Request session ${VTNWEBAPI}/${CTRLS}/${ctrlname}.json
133 ${contents} To JSON ${resp.content}
134 ${controllerblock} Get From Dictionary ${contents} controller
135 ${status} Get From Dictionary ${controllerblock} operstatus
136 Should Be Equal As Strings ${status} ${stat}
139 [Arguments] ${vtnname} ${vtndescription}
140 [Documentation] Create VTN in Coordinator
141 ${vtninfo} Create Dictionary vtn_name=${vtnname} description=${vtndescription}
142 ${vtncreate} Create Dictionary vtn=${vtninfo}
143 ${vtncreate_json}= json.dumps ${vtncreate}
144 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS_CREATE} data=${vtncreate_json}
145 Should Be Equal As Strings ${resp.status_code} 201
148 [Arguments] ${vtnname}
149 [Documentation] Delete a VTN Created
150 ${resp} RequestsLibrary.Delete Request session ${VTNWEBAPI}/${VTNS}/${vtnname}.json
151 Should Be Equal As Strings ${resp.status_code} 204
154 [Arguments] ${vtnname} ${vbrname} ${ctrlname}
155 [Documentation] Create VBR for VTN in Coordinator
156 ${vbrinfo} Create Dictionary vbr_name=${vbrname} controller_id=${ctrlname} domain_id=(DEFAULT)
157 ${vbrcreate} Create Dictionary vbridge=${vbrinfo}
158 ${vbrcreate_json}= json.dumps ${vbrcreate}
159 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS_CREATE} data=${vbrcreate_json}
160 Run Keyword If '${vbrname}' == 'Vbr_audit' Should Be Equal As Strings ${resp.status_code} 202
161 ... ELSE Should Be Equal As Strings ${resp.status_code} 201
164 [Arguments] ${vtnname} ${vbrname} ${vbrifname} ${ifdescription} ${retcode}
165 [Documentation] Create VBR Interface in VBR
166 ${vbrifinfo} Create Dictionary if_name=${vbrifname} description=${ifdescription}
167 ${vbrifcreate} Create Dictionary interface=${vbrifinfo}
168 ${vbrifcreate_json}= json.dumps ${vbrifcreate}
169 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${VBRIFS_CREATE} data=${vbrifcreate_json}
170 Should Be Equal As Strings ${resp.status_code} ${retcode}
172 Define Portmap for VBRIF
173 [Arguments] ${vtnname} ${vbrname} ${vbrifname} ${logical_port_id}
174 [Documentation] Map Interface to a logical port
175 ${logical_port_info} Create Dictionary logical_port_id=${logical_port_id}
176 ${portmapdefine} Create Dictionary portmap=${logical_port_info}
177 ${portmapdefine_json}= json.dumps ${portmapdefine}
178 ${resp} RequestsLibrary.Put Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${VBRIFS}/${vbrifname}/${PORTMAP_CREATE} data=${portmapdefine_json}
179 Should Be Equal As Strings ${resp.status_code} 204
182 [Arguments] ${flowlistname} ${ipversion}
183 [Documentation] Create FLOWLIST in Coordinator
184 ${flowlistinfo} Create Dictionary fl_name=${flowlistname} ip_version=${ipversion}
185 ${flowlistcreate} Create Dictionary flowlist=${flowlistinfo}
186 ${flowlistcreate_json}= json.dumps ${flowlistcreate}
187 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${FLOWLISTS_CREATE} data=${flowlistcreate_json}
188 Should Be Equal As Strings ${resp.status_code} 201
191 [Arguments] ${flowlistname}
192 [Documentation] Create Flowlistentry for Coordinator
193 ${flowlistentryinfo} Create Dictionary seqnum=233 macethertype=0x800 ipdstaddr=10.0.0.1 ipdstaddrprefix=32 ipsrcaddr=10.0.0.3
194 ... ipsrcaddrprefix=32 ipproto=1
195 ${flowlistentrycreate} Create Dictionary flowlistentry=${flowlistentryinfo}
196 ${flowlistentrycreate_json}= json.dumps ${flowlistentrycreate}
197 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${FLOWLISTS}/${flowlistname}/${FLOWLISTENTRIES_CREATE} data=${flowlistentrycreate_json}
198 Should Be Equal As Strings ${resp.status_code} 201
200 Create FLOWLISTENTRY_ANY in FLOWLIST
201 [Arguments] ${flowlistname}
202 [Documentation] Create Flowlistentry_any for Coordinator
203 ${flowlistentryinfo} Create Dictionary seqnum=1
204 ${flowlistentrycreate} Create Dictionary flowlistentry=${flowlistentryinfo}
205 ${flowlistentrycreate_json}= json.dumps ${flowlistentrycreate}
206 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${FLOWLISTS}/${flowlistname}/${FLOWLISTENTRIES_CREATE} data=${flowlistentrycreate_json}
207 Should Be Equal As Strings ${resp.status_code} 201
209 Create VBRIF in FLOWFILTER
210 [Arguments] ${vtnname} ${vbrname} ${vbrifname} ${ff_type}
211 [Documentation] create vbridge interface flowfilter
212 ${flowfilters_info} Create Dictionary ff_type=${ff_type}
213 ${flowfiltersdefine} Create Dictionary flowfilter=${flowfilters_info}
214 ${flowfiltersdefine_json}= json.dumps ${flowfiltersdefine}
215 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${VBRIFS}/${vbrifname}/${FLOWFILTERS_CREATE} data=${flowfiltersdefine_json}
216 Should Be Equal As Strings ${resp.status_code} 201
218 Create FLOWFILTERENTRY DROP In VBRIFFLOWFILTER
219 [Arguments] ${vtnname} ${vbrname} ${vbrifname} ${actiontype}
220 [Documentation] create domonstration with pass actiontype
221 ${flowfilterentryinfo} Create Dictionary seqnum=233 fl_name=Flowlist1 action_type=${actiontype} priority=3 dscp=55
222 ${flowfilterentrycreate} Create Dictionary flowfilterentry=${flowfilterentryinfo}
223 ${flowfilterentrycreate_json}= json.dumps ${flowfilterentrycreate}
224 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${VBRIFS}/${vbrifname}/${FLOWFILTERS}/${FLOWFILTERENTRIES_CREATE} data=${flowfilterentrycreate_json}
225 Should Be Equal As Strings ${resp.status_code} 201
227 Create FLOWFILTERENTRY PASS In VBRIFFLOWFILTER
228 [Arguments] ${vtnname} ${vbrname} ${vbrifname} ${actiontype} ${seqnum}
229 [Documentation] create domonstration with pass actiontype
230 ${flowfilterentryinfo} Create Dictionary fl_name=Flowlist1 action_type=${actiontype} priority=3 dscp=55
231 ${flowfilterentrycreate} Create Dictionary flowfilterentry=${flowfilterentryinfo}
232 ${flowfilterentrycreate_json}= json.dumps ${flowfilterentrycreate}
233 ${resp} RequestsLibrary.Put Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${VBRIFS}/${vbrifname}/${FLOWFILTERS}/${FLOWFILTERS_UPDATE}/${seqnum} data=${flowfilterentrycreate_json}
234 Should Be Equal As Strings ${resp.status_code} 204
236 Create FLOWFILTER in VBR
237 [Arguments] ${vtnname} ${vbrname} ${ff_type}
238 [Documentation] create vtn flowfilter
239 ${flowfilters_info} Create Dictionary ff_type=${ff_type}
240 ${flowfiltersdefine} Create Dictionary flowfilter=${flowfilters_info}
241 ${flowfiltersdefine_json}= json.dumps ${flowfiltersdefine}
242 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${FLOWFILTERS_CREATE} data=${flowfiltersdefine_json}
243 Should Be Equal As Strings ${resp.status_code} 201
245 Create FLOWFILTERENTRY PASS in VBRFLOWFILTER
246 [Arguments] ${vtnname} ${vbrname} ${actiontype}
247 [Documentation] create domonstration with pass actiontype
248 ${flowfilterentryinfo} Create Dictionary seqnum=233 fl_name=Flowlist1 action_type=${actiontype} priority=3 dscp=55
249 ${flowfilterentryinfo_1} Create Dictionary vnode_name=${vbrname} fl_name=Flowlist1 direction=in
250 ${flowfilterentrycreate} Create Dictionary flowfilterentry=${flowfilterentryinfo}
251 ${flowfilterentrycreate_json}= json.dumps ${flowfilterentrycreate}
252 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${FLOWFILTERS}/${FLOWFILTERENTRIES_CREATE} data=${flowfilterentrycreate_json}
253 Should Be Equal As Strings ${resp.status_code} 201
255 Create FLOWFILTER in VTN
256 [Arguments] ${vtnname} ${ff_type}
257 [Documentation] create vtn flowfilter
258 ${flowfilters_info} Create Dictionary ff_type=${ff_type}
259 ${flowfiltersdefine} Create Dictionary flowfilter=${flowfilters_info}
260 ${flowfiltersdefine_json}= json.dumps ${flowfiltersdefine}
261 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${FLOWFILTERS_CREATE} data=${flowfiltersdefine_json}
262 Should Be Equal As Strings ${resp.status_code} 201
264 Create FLOWFILTERENTRY PASS in VTNFLOWFILTER
265 [Arguments] ${vtnname} ${actiontype}
266 [Documentation] create domonstration with pass actiontype
267 ${flowfilterentryinfo} Create Dictionary seqnum=233 fl_name=Flowlist1 action_type=${actiontype} priority=3 dscp=55
268 ${flowfilterentrycreate} Create Dictionary flowfilterentry=${flowfilterentryinfo}
269 ${flowfilterentrycreate_json}= json.dumps ${flowfilterentrycreate}
270 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${FLOWFILTERS}/${FLOWFILTERENTRIES_CREATE} data=${flowfilterentrycreate_json}
271 Should Be Equal As Strings ${resp.status_code} 201
273 Create VLANMAP in VBRIDGE
274 [Arguments] ${vtnname} ${vbrname} ${vlanid}
275 [Documentation] Create VLANMAP for VBRIDGE in Coordinator
276 ${vlaninfo} Create Dictionary vlan_id=${vlanid}
277 ${vlancreate} Create Dictionary vlanmap=${vlaninfo}
278 ${vlancreate_json}= json.dumps ${vlancreate}
279 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${VLANMAP_CREATE } data=${vlancreate_json}
280 Should Be Equal As Strings ${resp.status_code} 201
283 [Documentation] This will start mininet with custom topology on both the Virtual Machines
284 Install Package On Ubuntu System vlan
285 MininetKeywords.Start Mininet Single Controller ${TOOLS_SYSTEM_IP} ${ODL_SYSTEM_IP} ${vlan_topo} ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
288 [Arguments] ${flowlistname}
289 [Documentation] Delete a Flowlist
290 ${resp} RequestsLibrary.Delete Request session ${VTNWEBAPI}/${FLOWLISTS}/${flowlistname}.json
291 Should Be Equal As Strings ${resp.status_code} 204
294 [Arguments] ${host1} ${host2}
295 [Documentation] Ping hosts to check connectivity
296 Write ${host1} ping -c 1 ${host2}
297 ${result} Read Until mininet>
298 Should Contain ${result} 64 bytes
301 [Arguments] ${ctrlname} ${switch_id}
302 [Documentation] Get switch
303 ${resp} RequestsLibrary.Get Request session ${VTNWEBAPI}/${CTRLS}/${ctrlname}/${SW}/${switch_id}.json
304 ${contents} To JSON ${resp.content}
305 ${switchblock} Get From Dictionary ${contents} switch
306 ${status} Get From Dictionary ${switchblock} switch_id
307 Should Be Equal As Strings ${status} ${switch_id}
310 [Arguments] ${ctrlname} ${switch_id}
311 [Documentation] Get switch
312 ${resp} RequestsLibrary.Get Request session ${VTNWEBAPI}/${CTRLS}/${ctrlname}/${SW}/${switch_id}/${PORTS}
313 Should Be Equal As Strings ${resp.status_code} 200