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[2]
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[3]
65 ${nitrogen_version_val}= SSHLibrary.Execute Command echo ${carbon_version} | awk -F"-" '{print $1}'
66 SSHLibrary.Execute Command sudo mv maven-metadata.xml old-maven-metadata.xml
67 CompareStream.Run_Keyword_If_Equals carbon SSHLibrary.Execute Command wget "${vtn_coordinator_nexus_path}/${carbon_version}/maven-metadata.xml"
68 CompareStream.Run_Keyword_If_Equals nitrogen SSHLibrary.Execute Command wget "${vtn_coordinator_nexus_path}/${nitrogen_version}/maven-metadata.xml"
69 SSHLibrary.Get_file maven-metadata.xml
70 ${value}= XML.Get Element Text maven-metadata.xml xpath=.//snapshotVersion[1]/value
71 CompareStream.Run_Keyword_If_Equals carbon SSHLibrary.Execute Command wget '${vtn_coordinator_nexus_path}/${carbon_version}/${vtn_dist}-${value}-bin.tar.bz2'
72 CompareStream.Run_Keyword_If_Equals nitrogen SSHLibrary.Execute Command wget '${vtn_coordinator_nexus_path}/${nitrogen_version}/${vtn_dist}-${value}-bin.tar.bz2'
73 SSHLibrary.Execute Command tar -C/ -jxvf ${vtn_dist}*-bin.tar.bz2
76 [Documentation] Exit the Launch Test
77 Log Stop the Launch Test
80 [Documentation] Start the VTNCo Test
81 Create Session session http://${ODL_SYSTEM_IP}:8083 headers=${VTNC_HEADERS}
84 [Documentation] Exit the VtnCo Test
87 Get Coordinator Version
88 [Documentation] Get API version for testing
89 ${resp} RequestsLibrary.Get Request session ${VTNWEBAPI}/api_version
90 Should Be Equal As Strings ${resp.status_code} 200
93 [Arguments] ${ctrlname} ${ctrlip}
94 [Documentation] Create a controller
95 ${controllerinfo} Create Dictionary controller_id=${ctrlname} type=odc ipaddr=${ctrlip} version=1.0
96 ${controllercreate} Create Dictionary controller=${controllerinfo}
97 ${controllercreate_json}= json.dumps ${controllercreate}
98 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${CTRLS_CREATE} data=${controllercreate_json}
99 Should Be Equal As Strings ${resp.status_code} 201
102 [Arguments] ${ctrlname}
103 [Documentation] Delete a Controller
104 ${resp} RequestsLibrary.Delete Request session ${VTNWEBAPI}/${CTRLS}/${ctrlname}.json
105 Should Be Equal As Strings ${resp.status_code} 204
108 [Arguments] ${ctrlname} ${ctrlip} ${desc}
109 [Documentation] Update controller
110 ${controllerinfo} Create Dictionary description=${desc} ipaddr=${ctrlip} version=1.0
111 ${controllerupdate} Create Dictionary controller=${controllerinfo}
112 ${controllerupdate_json}= json.dumps ${controllerupdate}
113 ${resp} RequestsLibrary.Put Request session ${VTNWEBAPI}/${CTRLS}/${ctrlname}.json data=${controllerupdate_json}
114 Should Be Equal As Strings ${resp.status_code} 204
117 [Arguments] ${ctrlname}
118 [Documentation] Trigger Manual Audit
119 ${auditinfo} Create Dictionary force=false real-network_audit=false
120 ${auditupdate} Create Dictionary audit=${auditinfo}
121 ${auditupdate_json}= json.dumps ${auditupdate}
122 ${resp} RequestsLibrary.Put Request session ${VTNWEBAPI}/${CTRLS}/${ctrlname}/audit.json data=${auditupdate_json}
123 Should Be Equal As Strings ${resp.status_code} 204
125 Check Controller Status
126 [Arguments] ${ctrlname} ${stat}
127 [Documentation] Get controller status
128 ${resp} RequestsLibrary.Get Request session ${VTNWEBAPI}/${CTRLS}/${ctrlname}.json
129 ${contents} To JSON ${resp.content}
130 ${controllerblock} Get From Dictionary ${contents} controller
131 ${status} Get From Dictionary ${controllerblock} operstatus
132 Should Be Equal As Strings ${status} ${stat}
135 [Arguments] ${vtnname} ${vtndescription}
136 [Documentation] Create VTN in Coordinator
137 ${vtninfo} Create Dictionary vtn_name=${vtnname} description=${vtndescription}
138 ${vtncreate} Create Dictionary vtn=${vtninfo}
139 ${vtncreate_json}= json.dumps ${vtncreate}
140 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS_CREATE} data=${vtncreate_json}
141 Should Be Equal As Strings ${resp.status_code} 201
144 [Arguments] ${vtnname}
145 [Documentation] Delete a VTN Created
146 ${resp} RequestsLibrary.Delete Request session ${VTNWEBAPI}/${VTNS}/${vtnname}.json
147 Should Be Equal As Strings ${resp.status_code} 204
150 [Arguments] ${vtnname} ${vbrname} ${ctrlname}
151 [Documentation] Create VBR for VTN in Coordinator
152 ${vbrinfo} Create Dictionary vbr_name=${vbrname} controller_id=${ctrlname} domain_id=(DEFAULT)
153 ${vbrcreate} Create Dictionary vbridge=${vbrinfo}
154 ${vbrcreate_json}= json.dumps ${vbrcreate}
155 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS_CREATE} data=${vbrcreate_json}
156 Run Keyword If '${vbrname}' == 'Vbr_audit' Should Be Equal As Strings ${resp.status_code} 202
157 ... ELSE Should Be Equal As Strings ${resp.status_code} 201
160 [Arguments] ${vtnname} ${vbrname} ${vbrifname} ${ifdescription} ${retcode}
161 [Documentation] Create VBR Interface in VBR
162 ${vbrifinfo} Create Dictionary if_name=${vbrifname} description=${ifdescription}
163 ${vbrifcreate} Create Dictionary interface=${vbrifinfo}
164 ${vbrifcreate_json}= json.dumps ${vbrifcreate}
165 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${VBRIFS_CREATE} data=${vbrifcreate_json}
166 Should Be Equal As Strings ${resp.status_code} ${retcode}
168 Define Portmap for VBRIF
169 [Arguments] ${vtnname} ${vbrname} ${vbrifname} ${logical_port_id}
170 [Documentation] Map Interface to a logical port
171 ${logical_port_info} Create Dictionary logical_port_id=${logical_port_id}
172 ${portmapdefine} Create Dictionary portmap=${logical_port_info}
173 ${portmapdefine_json}= json.dumps ${portmapdefine}
174 ${resp} RequestsLibrary.Put Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${VBRIFS}/${vbrifname}/${PORTMAP_CREATE} data=${portmapdefine_json}
175 Should Be Equal As Strings ${resp.status_code} 204
178 [Arguments] ${flowlistname} ${ipversion}
179 [Documentation] Create FLOWLIST in Coordinator
180 ${flowlistinfo} Create Dictionary fl_name=${flowlistname} ip_version=${ipversion}
181 ${flowlistcreate} Create Dictionary flowlist=${flowlistinfo}
182 ${flowlistcreate_json}= json.dumps ${flowlistcreate}
183 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${FLOWLISTS_CREATE} data=${flowlistcreate_json}
184 Should Be Equal As Strings ${resp.status_code} 201
187 [Arguments] ${flowlistname}
188 [Documentation] Create Flowlistentry for Coordinator
189 ${flowlistentryinfo} Create Dictionary seqnum=233 macethertype=0x800 ipdstaddr=10.0.0.1 ipdstaddrprefix=32 ipsrcaddr=10.0.0.3
190 ... ipsrcaddrprefix=32 ipproto=1
191 ${flowlistentrycreate} Create Dictionary flowlistentry=${flowlistentryinfo}
192 ${flowlistentrycreate_json}= json.dumps ${flowlistentrycreate}
193 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${FLOWLISTS}/${flowlistname}/${FLOWLISTENTRIES_CREATE} data=${flowlistentrycreate_json}
194 Should Be Equal As Strings ${resp.status_code} 201
196 Create FLOWLISTENTRY_ANY in FLOWLIST
197 [Arguments] ${flowlistname}
198 [Documentation] Create Flowlistentry_any for Coordinator
199 ${flowlistentryinfo} Create Dictionary seqnum=1
200 ${flowlistentrycreate} Create Dictionary flowlistentry=${flowlistentryinfo}
201 ${flowlistentrycreate_json}= json.dumps ${flowlistentrycreate}
202 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${FLOWLISTS}/${flowlistname}/${FLOWLISTENTRIES_CREATE} data=${flowlistentrycreate_json}
203 Should Be Equal As Strings ${resp.status_code} 201
205 Create VBRIF in FLOWFILTER
206 [Arguments] ${vtnname} ${vbrname} ${vbrifname} ${ff_type}
207 [Documentation] create vbridge interface flowfilter
208 ${flowfilters_info} Create Dictionary ff_type=${ff_type}
209 ${flowfiltersdefine} Create Dictionary flowfilter=${flowfilters_info}
210 ${flowfiltersdefine_json}= json.dumps ${flowfiltersdefine}
211 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${VBRIFS}/${vbrifname}/${FLOWFILTERS_CREATE} data=${flowfiltersdefine_json}
212 Should Be Equal As Strings ${resp.status_code} 201
214 Create FLOWFILTERENTRY DROP In VBRIFFLOWFILTER
215 [Arguments] ${vtnname} ${vbrname} ${vbrifname} ${actiontype}
216 [Documentation] create domonstration with pass actiontype
217 ${flowfilterentryinfo} Create Dictionary seqnum=233 fl_name=Flowlist1 action_type=${actiontype} priority=3 dscp=55
218 ${flowfilterentrycreate} Create Dictionary flowfilterentry=${flowfilterentryinfo}
219 ${flowfilterentrycreate_json}= json.dumps ${flowfilterentrycreate}
220 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${VBRIFS}/${vbrifname}/${FLOWFILTERS}/${FLOWFILTERENTRIES_CREATE} data=${flowfilterentrycreate_json}
221 Should Be Equal As Strings ${resp.status_code} 201
223 Create FLOWFILTERENTRY PASS In VBRIFFLOWFILTER
224 [Arguments] ${vtnname} ${vbrname} ${vbrifname} ${actiontype} ${seqnum}
225 [Documentation] create domonstration with pass actiontype
226 ${flowfilterentryinfo} Create Dictionary fl_name=Flowlist1 action_type=${actiontype} priority=3 dscp=55
227 ${flowfilterentrycreate} Create Dictionary flowfilterentry=${flowfilterentryinfo}
228 ${flowfilterentrycreate_json}= json.dumps ${flowfilterentrycreate}
229 ${resp} RequestsLibrary.Put Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${VBRIFS}/${vbrifname}/${FLOWFILTERS}/${FLOWFILTERS_UPDATE}/${seqnum} data=${flowfilterentrycreate_json}
230 Should Be Equal As Strings ${resp.status_code} 204
232 Create FLOWFILTER in VBR
233 [Arguments] ${vtnname} ${vbrname} ${ff_type}
234 [Documentation] create vtn flowfilter
235 ${flowfilters_info} Create Dictionary ff_type=${ff_type}
236 ${flowfiltersdefine} Create Dictionary flowfilter=${flowfilters_info}
237 ${flowfiltersdefine_json}= json.dumps ${flowfiltersdefine}
238 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${FLOWFILTERS_CREATE} data=${flowfiltersdefine_json}
239 Should Be Equal As Strings ${resp.status_code} 201
241 Create FLOWFILTERENTRY PASS in VBRFLOWFILTER
242 [Arguments] ${vtnname} ${vbrname} ${actiontype}
243 [Documentation] create domonstration with pass actiontype
244 ${flowfilterentryinfo} Create Dictionary seqnum=233 fl_name=Flowlist1 action_type=${actiontype} priority=3 dscp=55
245 ${flowfilterentryinfo_1} Create Dictionary vnode_name=${vbrname} fl_name=Flowlist1 direction=in
246 ${flowfilterentrycreate} Create Dictionary flowfilterentry=${flowfilterentryinfo}
247 ${flowfilterentrycreate_json}= json.dumps ${flowfilterentrycreate}
248 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${FLOWFILTERS}/${FLOWFILTERENTRIES_CREATE} data=${flowfilterentrycreate_json}
249 Should Be Equal As Strings ${resp.status_code} 201
251 Create FLOWFILTER in VTN
252 [Arguments] ${vtnname} ${ff_type}
253 [Documentation] create vtn flowfilter
254 ${flowfilters_info} Create Dictionary ff_type=${ff_type}
255 ${flowfiltersdefine} Create Dictionary flowfilter=${flowfilters_info}
256 ${flowfiltersdefine_json}= json.dumps ${flowfiltersdefine}
257 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${FLOWFILTERS_CREATE} data=${flowfiltersdefine_json}
258 Should Be Equal As Strings ${resp.status_code} 201
260 Create FLOWFILTERENTRY PASS in VTNFLOWFILTER
261 [Arguments] ${vtnname} ${actiontype}
262 [Documentation] create domonstration with pass actiontype
263 ${flowfilterentryinfo} Create Dictionary seqnum=233 fl_name=Flowlist1 action_type=${actiontype} priority=3 dscp=55
264 ${flowfilterentrycreate} Create Dictionary flowfilterentry=${flowfilterentryinfo}
265 ${flowfilterentrycreate_json}= json.dumps ${flowfilterentrycreate}
266 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${FLOWFILTERS}/${FLOWFILTERENTRIES_CREATE} data=${flowfilterentrycreate_json}
267 Should Be Equal As Strings ${resp.status_code} 201
269 Create VLANMAP in VBRIDGE
270 [Arguments] ${vtnname} ${vbrname} ${vlanid}
271 [Documentation] Create VLANMAP for VBRIDGE in Coordinator
272 ${vlaninfo} Create Dictionary vlan_id=${vlanid}
273 ${vlancreate} Create Dictionary vlanmap=${vlaninfo}
274 ${vlancreate_json}= json.dumps ${vlancreate}
275 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${VLANMAP_CREATE } data=${vlancreate_json}
276 Should Be Equal As Strings ${resp.status_code} 201
279 [Documentation] This will start mininet with custom topology on both the Virtual Machines
280 Install Package On Ubuntu System vlan
281 MininetKeywords.Start Mininet Single Controller ${TOOLS_SYSTEM_IP} ${ODL_SYSTEM_IP} ${vlan_topo} ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
284 [Arguments] ${flowlistname}
285 [Documentation] Delete a Flowlist
286 ${resp} RequestsLibrary.Delete Request session ${VTNWEBAPI}/${FLOWLISTS}/${flowlistname}.json
287 Should Be Equal As Strings ${resp.status_code} 204
290 [Arguments] ${host1} ${host2}
291 [Documentation] Ping hosts to check connectivity
292 Write ${host1} ping -c 1 ${host2}
293 ${result} Read Until mininet>
294 Should Contain ${result} 64 bytes
297 [Arguments] ${ctrlname} ${switch_id}
298 [Documentation] Get switch
299 ${resp} RequestsLibrary.Get Request session ${VTNWEBAPI}/${CTRLS}/${ctrlname}/${SW}/${switch_id}.json
300 ${contents} To JSON ${resp.content}
301 ${switchblock} Get From Dictionary ${contents} switch
302 ${status} Get From Dictionary ${switchblock} switch_id
303 Should Be Equal As Strings ${status} ${switch_id}
306 [Arguments] ${ctrlname} ${switch_id}
307 [Documentation] Get switch
308 ${resp} RequestsLibrary.Get Request session ${VTNWEBAPI}/${CTRLS}/${ctrlname}/${SW}/${switch_id}/${PORTS}
309 Should Be Equal As Strings ${resp.status_code} 200