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