5 Library RequestsLibrary
10 Variables ../variables/Variables.py
11 Resource ./Utils.robot
14 ${vlan_topo} sudo mn --controller=remote,ip=${ODL_SYSTEM_IP} --custom vlan_vtn_test.py --topo vlantopo
15 ${nexus_path} https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/org/opendaylight/vtn/distribution.vtn-coordinator
16 ${boron} 6.3.1-SNAPSHOT
17 ${carbon} 6.4.0-SNAPSHOT
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 http://yum.postgresql.org/9.3/redhat/rhel-7-x86_64/pgdg-centos93-9.3-2.noarch.rpm
44 SSHLibrary.Execute Command sudo yum install -q -y postgresql93-libs postgresql93 postgresql93-server postgresql93-contrib postgresql93-odbc-09.03.0400
45 Run Keyword If '${ODL_STREAM}' == 'boron' SSHLibrary.Execute Command wget "${nexus_path}/${boron}/maven-metadata.xml"
46 ... ELSE IF '${ODL_STREAM}' == 'carbon' SSHLibrary.Execute Command wget "${nexus_path}/${carbon}/maven-metadata.xml"
47 Run Keyword If '${ODL_STREAM}' == 'boron' or '${ODL_STREAM}' == 'carbon' SSHLibrary.Get_file maven-metadata.xml
48 ${time_stamp}= XML.Get Element Text maven-metadata.xml xpath=.//snapshot/timestamp
49 ${build_number}= XML.Get Element Text maven-metadata.xml xpath=.//snapshot/buildNumber
50 Run Keyword If '${ODL_STREAM}' == 'boron' SSHLibrary.Execute Command wget '${nexus_path}/${boron}/${vtn_dist}-6.3.1-${time_stamp}-${build_number}-bin.tar.bz2'
51 ... ELSE IF '${ODL_STREAM}' == 'carbon' SSHLibrary.Execute Command wget '${nexus_path}/${carbon}/${vtn_dist}-6.4.0-${time_stamp}-${build_number}-bin.tar.bz2'
52 Run Keyword If '${ODL_STREAM}' == 'boron' or '${ODL_STREAM}' == 'carbon' SSHLibrary.Execute Command tar -C/ -jxvf ${vtn_dist}*-bin.tar.bz2
53 ... ELSE SSHLibrary.Execute Command tar -C/ -jxvf ${WORKSPACE}/${BUNDLEFOLDER}/externalapps/${vtn_dist}*-bin.tar.bz2
54 SSHLibrary.Execute Command /usr/local/vtn/sbin/db_setup
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/sbin/db_setup
58 SSHLibrary.Execute Command sed -i 's/odcdrv_ping_interval = 30/odcdrv_ping_interval = 10/g' /usr/local/vtn/modules/odcdriver.conf
59 SSHLibrary.Execute Command sed -i 's/physical_attributes_read_interval = 40/physical_attributes_read_interval = 15/g' /usr/local/vtn/modules/vtndrvintf.conf
60 SSHLibrary.Execute Command /usr/local/vtn/bin/vtn_start
61 SSHLibrary.Execute Command /usr/local/vtn/bin/unc_dmctl status
62 SSHLibrary.Execute Command /usr/local/vtn/bin/drvodc_control loglevel trace
63 SSHLibrary.Execute Command /usr/local/vtn/bin/lgcnw_control loglevel trace
64 SSHLibrary.Execute Command exit
67 [Documentation] Exit the Launch Test
68 Log Stop the Launch Test
71 [Documentation] Start the VTNCo Test
72 Create Session session http://${ODL_SYSTEM_IP}:8083 headers=${VTNC_HEADERS}
75 [Documentation] Exit the VtnCo Test
78 Get Coordinator Version
79 [Documentation] Get API version for testing
80 ${resp} RequestsLibrary.Get Request session ${VTNWEBAPI}/api_version
81 Should Be Equal As Strings ${resp.status_code} 200
84 [Arguments] ${ctrlname} ${ctrlip}
85 [Documentation] Create a controller
86 ${controllerinfo} Create Dictionary controller_id=${ctrlname} type=odc ipaddr=${ctrlip} version=1.0
87 ${controllercreate} Create Dictionary controller=${controllerinfo}
88 ${controllercreate_json}= json.dumps ${controllercreate}
89 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${CTRLS_CREATE} data=${controllercreate_json}
90 Should Be Equal As Strings ${resp.status_code} 201
93 [Arguments] ${ctrlname}
94 [Documentation] Delete a Controller
95 ${resp} RequestsLibrary.Delete Request session ${VTNWEBAPI}/${CTRLS}/${ctrlname}.json
96 Should Be Equal As Strings ${resp.status_code} 204
99 [Arguments] ${ctrlname} ${ctrlip} ${desc}
100 [Documentation] Update controller
101 ${controllerinfo} Create Dictionary description=${desc} ipaddr=${ctrlip} version=1.0
102 ${controllerupdate} Create Dictionary controller=${controllerinfo}
103 ${controllerupdate_json}= json.dumps ${controllerupdate}
104 ${resp} RequestsLibrary.Put Request session ${VTNWEBAPI}/${CTRLS}/${ctrlname}.json data=${controllerupdate_json}
105 Should Be Equal As Strings ${resp.status_code} 204
108 [Arguments] ${ctrlname}
109 [Documentation] Trigger Manual Audit
110 ${auditinfo} Create Dictionary force=false real-network_audit=false
111 ${auditupdate} Create Dictionary audit=${auditinfo}
112 ${auditupdate_json}= json.dumps ${auditupdate}
113 ${resp} RequestsLibrary.Put Request session ${VTNWEBAPI}/${CTRLS}/${ctrlname}/audit.json data=${auditupdate_json}
114 Should Be Equal As Strings ${resp.status_code} 204
116 Check Controller Status
117 [Arguments] ${ctrlname} ${stat}
118 [Documentation] Get controller status
119 ${resp} RequestsLibrary.Get Request session ${VTNWEBAPI}/${CTRLS}/${ctrlname}.json
120 ${contents} To JSON ${resp.content}
121 ${controllerblock} Get From Dictionary ${contents} controller
122 ${status} Get From Dictionary ${controllerblock} operstatus
123 Should Be Equal As Strings ${status} ${stat}
126 [Arguments] ${vtnname} ${vtndescription}
127 [Documentation] Create VTN in Coordinator
128 ${vtninfo} Create Dictionary vtn_name=${vtnname} description=${vtndescription}
129 ${vtncreate} Create Dictionary vtn=${vtninfo}
130 ${vtncreate_json}= json.dumps ${vtncreate}
131 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS_CREATE} data=${vtncreate_json}
132 Should Be Equal As Strings ${resp.status_code} 201
135 [Arguments] ${vtnname}
136 [Documentation] Delete a VTN Created
137 ${resp} RequestsLibrary.Delete Request session ${VTNWEBAPI}/${VTNS}/${vtnname}.json
138 Should Be Equal As Strings ${resp.status_code} 204
141 [Arguments] ${vtnname} ${vbrname} ${ctrlname}
142 [Documentation] Create VBR for VTN in Coordinator
143 ${vbrinfo} Create Dictionary vbr_name=${vbrname} controller_id=${ctrlname} domain_id=(DEFAULT)
144 ${vbrcreate} Create Dictionary vbridge=${vbrinfo}
145 ${vbrcreate_json}= json.dumps ${vbrcreate}
146 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS_CREATE} data=${vbrcreate_json}
147 Run Keyword If '${vbrname}' == 'Vbr_audit' Should Be Equal As Strings ${resp.status_code} 202
148 ... ELSE Should Be Equal As Strings ${resp.status_code} 201
151 [Arguments] ${vtnname} ${vbrname} ${vbrifname} ${ifdescription} ${retcode}
152 [Documentation] Create VBR Interface in VBR
153 ${vbrifinfo} Create Dictionary if_name=${vbrifname} description=${ifdescription}
154 ${vbrifcreate} Create Dictionary interface=${vbrifinfo}
155 ${vbrifcreate_json}= json.dumps ${vbrifcreate}
156 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${VBRIFS_CREATE} data=${vbrifcreate_json}
157 Should Be Equal As Strings ${resp.status_code} ${retcode}
159 Define Portmap for VBRIF
160 [Arguments] ${vtnname} ${vbrname} ${vbrifname} ${logical_port_id}
161 [Documentation] Map Interface to a logical port
162 ${logical_port_info} Create Dictionary logical_port_id=${logical_port_id}
163 ${portmapdefine} Create Dictionary portmap=${logical_port_info}
164 ${portmapdefine_json}= json.dumps ${portmapdefine}
165 ${resp} RequestsLibrary.Put Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${VBRIFS}/${vbrifname}/${PORTMAP_CREATE} data=${portmapdefine_json}
166 Should Be Equal As Strings ${resp.status_code} 204
169 [Arguments] ${flowlistname} ${ipversion}
170 [Documentation] Create FLOWLIST in Coordinator
171 ${flowlistinfo} Create Dictionary fl_name=${flowlistname} ip_version=${ipversion}
172 ${flowlistcreate} Create Dictionary flowlist=${flowlistinfo}
173 ${flowlistcreate_json}= json.dumps ${flowlistcreate}
174 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${FLOWLISTS_CREATE} data=${flowlistcreate_json}
175 Should Be Equal As Strings ${resp.status_code} 201
178 [Arguments] ${flowlistname}
179 [Documentation] Create Flowlistentry for Coordinator
180 ${flowlistentryinfo} Create Dictionary seqnum=233 macethertype=0x800 ipdstaddr=10.0.0.1 ipdstaddrprefix=32 ipsrcaddr=10.0.0.3
181 ... ipsrcaddrprefix=32 ipproto=1
182 ${flowlistentrycreate} Create Dictionary flowlistentry=${flowlistentryinfo}
183 ${flowlistentrycreate_json}= json.dumps ${flowlistentrycreate}
184 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${FLOWLISTS}/${flowlistname}/${FLOWLISTENTRIES_CREATE} data=${flowlistentrycreate_json}
185 Should Be Equal As Strings ${resp.status_code} 201
187 Create FLOWLISTENTRY_ANY in FLOWLIST
188 [Arguments] ${flowlistname}
189 [Documentation] Create Flowlistentry_any for Coordinator
190 ${flowlistentryinfo} Create Dictionary seqnum=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 VBRIF in FLOWFILTER
197 [Arguments] ${vtnname} ${vbrname} ${vbrifname} ${ff_type}
198 [Documentation] create vbridge interface flowfilter
199 ${flowfilters_info} Create Dictionary ff_type=${ff_type}
200 ${flowfiltersdefine} Create Dictionary flowfilter=${flowfilters_info}
201 ${flowfiltersdefine_json}= json.dumps ${flowfiltersdefine}
202 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${VBRIFS}/${vbrifname}/${FLOWFILTERS_CREATE} data=${flowfiltersdefine_json}
203 Should Be Equal As Strings ${resp.status_code} 201
205 Create FLOWFILTERENTRY DROP In VBRIFFLOWFILTER
206 [Arguments] ${vtnname} ${vbrname} ${vbrifname} ${actiontype}
207 [Documentation] create domonstration with pass actiontype
208 ${flowfilterentryinfo} Create Dictionary seqnum=233 fl_name=Flowlist1 action_type=${actiontype} priority=3 dscp=55
209 ${flowfilterentrycreate} Create Dictionary flowfilterentry=${flowfilterentryinfo}
210 ${flowfilterentrycreate_json}= json.dumps ${flowfilterentrycreate}
211 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${VBRIFS}/${vbrifname}/${FLOWFILTERS}/${FLOWFILTERENTRIES_CREATE} data=${flowfilterentrycreate_json}
212 Should Be Equal As Strings ${resp.status_code} 201
214 Create FLOWFILTERENTRY PASS In VBRIFFLOWFILTER
215 [Arguments] ${vtnname} ${vbrname} ${vbrifname} ${actiontype} ${seqnum}
216 [Documentation] create domonstration with pass actiontype
217 ${flowfilterentryinfo} Create Dictionary 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.Put Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${VBRIFS}/${vbrifname}/${FLOWFILTERS}/${FLOWFILTERS_UPDATE}/${seqnum} data=${flowfilterentrycreate_json}
221 Should Be Equal As Strings ${resp.status_code} 204
223 Create FLOWFILTER in VBR
224 [Arguments] ${vtnname} ${vbrname} ${ff_type}
225 [Documentation] create vtn flowfilter
226 ${flowfilters_info} Create Dictionary ff_type=${ff_type}
227 ${flowfiltersdefine} Create Dictionary flowfilter=${flowfilters_info}
228 ${flowfiltersdefine_json}= json.dumps ${flowfiltersdefine}
229 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${FLOWFILTERS_CREATE} data=${flowfiltersdefine_json}
230 Should Be Equal As Strings ${resp.status_code} 201
232 Create FLOWFILTERENTRY PASS in VBRFLOWFILTER
233 [Arguments] ${vtnname} ${vbrname} ${actiontype}
234 [Documentation] create domonstration with pass actiontype
235 ${flowfilterentryinfo} Create Dictionary seqnum=233 fl_name=Flowlist1 action_type=${actiontype} priority=3 dscp=55
236 ${flowfilterentryinfo_1} Create Dictionary vnode_name=${vbrname} fl_name=Flowlist1 direction=in
237 ${flowfilterentrycreate} Create Dictionary flowfilterentry=${flowfilterentryinfo}
238 ${flowfilterentrycreate_json}= json.dumps ${flowfilterentrycreate}
239 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${FLOWFILTERS}/${FLOWFILTERENTRIES_CREATE} data=${flowfilterentrycreate_json}
240 Should Be Equal As Strings ${resp.status_code} 201
242 Create FLOWFILTER in VTN
243 [Arguments] ${vtnname} ${ff_type}
244 [Documentation] create vtn flowfilter
245 ${flowfilters_info} Create Dictionary ff_type=${ff_type}
246 ${flowfiltersdefine} Create Dictionary flowfilter=${flowfilters_info}
247 ${flowfiltersdefine_json}= json.dumps ${flowfiltersdefine}
248 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${FLOWFILTERS_CREATE} data=${flowfiltersdefine_json}
249 Should Be Equal As Strings ${resp.status_code} 201
251 Create FLOWFILTERENTRY PASS in VTNFLOWFILTER
252 [Arguments] ${vtnname} ${actiontype}
253 [Documentation] create domonstration with pass actiontype
254 ${flowfilterentryinfo} Create Dictionary seqnum=233 fl_name=Flowlist1 action_type=${actiontype} priority=3 dscp=55
255 ${flowfilterentrycreate} Create Dictionary flowfilterentry=${flowfilterentryinfo}
256 ${flowfilterentrycreate_json}= json.dumps ${flowfilterentrycreate}
257 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${FLOWFILTERS}/${FLOWFILTERENTRIES_CREATE} data=${flowfilterentrycreate_json}
258 Should Be Equal As Strings ${resp.status_code} 201
260 Create VLANMAP in VBRIDGE
261 [Arguments] ${vtnname} ${vbrname} ${vlanid}
262 [Documentation] Create VLANMAP for VBRIDGE in Coordinator
263 ${vlaninfo} Create Dictionary vlan_id=${vlanid}
264 ${vlancreate} Create Dictionary vlanmap=${vlaninfo}
265 ${vlancreate_json}= json.dumps ${vlancreate}
266 ${resp} RequestsLibrary.Post Request session ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${VLANMAP_CREATE } data=${vlancreate_json}
267 Should Be Equal As Strings ${resp.status_code} 201
270 [Documentation] This will start mininet with custom topology on both the Virtual Machines
271 Install Package On Ubuntu System vlan
272 Start Mininet ${TOOLS_SYSTEM_IP} ${vlan_topo} ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
275 [Arguments] ${flowlistname}
276 [Documentation] Delete a Flowlist
277 ${resp} RequestsLibrary.Delete Request session ${VTNWEBAPI}/${FLOWLISTS}/${flowlistname}.json
278 Should Be Equal As Strings ${resp.status_code} 204
281 [Arguments] ${host1} ${host2}
282 [Documentation] Ping hosts to check connectivity
283 Write ${host1} ping -c 1 ${host2}
284 ${result} Read Until mininet>
285 Should Contain ${result} 64 bytes
288 [Arguments] ${ctrlname} ${switch_id}
289 [Documentation] Get switch
290 ${resp} RequestsLibrary.Get Request session ${VTNWEBAPI}/${CTRLS}/${ctrlname}/${SW}/${switch_id}.json
291 ${contents} To JSON ${resp.content}
292 ${switchblock} Get From Dictionary ${contents} switch
293 ${status} Get From Dictionary ${switchblock} switch_id
294 Should Be Equal As Strings ${status} ${switch_id}
297 [Arguments] ${ctrlname} ${switch_id}
298 [Documentation] Get switch
299 ${resp} RequestsLibrary.Get Request session ${VTNWEBAPI}/${CTRLS}/${ctrlname}/${SW}/${switch_id}/${PORTS}
300 Should Be Equal As Strings ${resp.status_code} 200