blob: 216387837294070407a333e35d368c8660d3ad6c [file] [log] [blame]
admin07529932013-11-22 14:58:28 -08001
2class OnosSanity4ARP :
3
4 def __init__(self) :
5 self.default = ''
6
7#**********************************************************************************************************************************************************************************************
8#Test startup
9#Tests the startup of Zookeeper1, Cassandra1, and ONOS1 to be certain that all started up successfully
10 def CASE1(self,main) : #Check to be sure ZK, Cass, and ONOS are up, then get ONOS version
11 import time
Jon Hallf89c8552014-04-02 13:14:06 -070012 main.Zookeeper1.start()
13 main.Zookeeper2.start()
14 main.Zookeeper3.start()
15 main.Zookeeper4.start()
admin07529932013-11-22 14:58:28 -080016 main.log.report("Pulling latest code from github to all nodes")
17 main.ONOS1.git_pull()
18 main.ONOS2.git_pull()
19 main.ONOS3.git_pull()
20 main.ONOS4.git_pull()
21 main.Cassandra1.start()
22 main.Cassandra2.start()
23 main.Cassandra3.start()
24 main.Cassandra4.start()
25 time.sleep(20)
26 main.ONOS1.drop_keyspace()
27 main.ONOS1.start()
28 time.sleep(10)
29 main.ONOS2.start()
30 main.ONOS3.start()
31 main.ONOS4.start()
32 main.ONOS1.start_rest()
33 time.sleep(5)
admin68453302013-12-16 15:40:04 -080034 test= main.ONOS1.rest_status()
35 if test == main.FALSE:
36 main.ONOS1.start_rest()
admin07529932013-11-22 14:58:28 -080037 main.ONOS1.get_version()
38 main.log.report("Startup check Zookeeper1, Cassandra1, and ONOS1 connections")
39 main.case("Checking if the startup was clean...")
40 main.step("Testing startup Zookeeper")
41 data = main.Zookeeper1.isup()
42 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...")
43 main.step("Testing startup Cassandra")
44 data = main.Cassandra1.isup()
45 if data == main.FALSE:
46 main.Cassandra1.stop()
47 main.Cassandra2.stop()
48 main.Cassandra3.stop()
49 main.Cassandra4.stop()
50
51 time.sleep(5)
52
53 main.Cassandra1.start()
54 main.Cassandra2.start()
55 main.Cassandra3.start()
56 main.Cassandra4.start()
57 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Cassandra is up!",onfail="Cassandra is down...")
58 main.step("Testing startup ONOS")
59 data = main.ONOS1.isup()
60 if data == main.FALSE:
61 main.log.report("Something is funny... restarting ONOS")
62 main.ONOS1.stop()
63 time.sleep(3)
64 main.ONOS1.start()
65 time.sleep(5)
66 data = main.ONOS1.isup()
67 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running!",onfail="ONOS didn't start...")
68
69#**********************************************************************************************************************************************************************************************
70#Assign Controllers
71#This test first checks the ip of a mininet host, to be certain that the mininet exists(Host is defined in Params as <CASE1><destination>).
72#Then the program assignes each ONOS instance a single controller to a switch(To be the initial master), then assigns all controllers.
73#NOTE: The reason why all four controllers are assigned although one was already assigned as the master is due to the 'ovs-vsctl set-controller' command erases all present controllers if
74# the controllers already assigned to the switch are not specified.
75
76 def CASE2(self,main) : #Make sure mininet exists, then assign controllers to switches
77 import time
78 main.log.report("Check if mininet started properly, then assign controllers ONOS 1,2,3 and 4")
79 main.case("Checking if one MN host exists")
80 main.step("Host IP Checking using checkIP")
81 result = main.Mininet1.checkIP(main.params['CASE1']['destination'])
82 main.step("Verifying the result")
83 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured")
84 main.step("assigning ONOS controllers to switches")
85 for i in range(25):
86 if i < 3:
87 j=i+1
88 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
89 time.sleep(1)
Jon Hallf89c8552014-04-02 13:14:06 -070090 main.Mininet1.assign_sw_controller(sw=str(j),count=4,ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'],ip2=main.params['CTRL']['ip2'],port2=main.params['CTRL']['port2'],ip3=main.params['CTRL']['ip3'],port3=main.params['CTRL']['port3'],ip4=main.params['CTRL']['ip4'],port4=main.params['CTRL']['port4'])
admin07529932013-11-22 14:58:28 -080091 elif i >= 3 and i < 5:
92 j=i+1
93 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2'])
94 time.sleep(1)
Jon Hallf89c8552014-04-02 13:14:06 -070095 main.Mininet1.assign_sw_controller(sw=str(j),count=4,ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'],ip2=main.params['CTRL']['ip2'],port2=main.params['CTRL']['port2'],ip3=main.params['CTRL']['ip3'],port3=main.params['CTRL']['port3'],ip4=main.params['CTRL']['ip4'],port4=main.params['CTRL']['port4'])
admin07529932013-11-22 14:58:28 -080096 elif i >= 5 and i < 15:
97 j=i+1
98 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3'])
99 time.sleep(1)
Jon Hallf89c8552014-04-02 13:14:06 -0700100 main.Mininet1.assign_sw_controller(sw=str(j),count=4,ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'],ip2=main.params['CTRL']['ip2'],port2=main.params['CTRL']['port2'],ip3=main.params['CTRL']['ip3'],port3=main.params['CTRL']['port3'],ip4=main.params['CTRL']['ip4'],port4=main.params['CTRL']['port4'])
admin07529932013-11-22 14:58:28 -0800101 else:
102 j=i+16
103 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4'])
104 time.sleep(1)
Jon Hallf89c8552014-04-02 13:14:06 -0700105 main.Mininet1.assign_sw_controller(sw=str(j),count=4,ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'],ip2=main.params['CTRL']['ip2'],port2=main.params['CTRL']['port2'],ip3=main.params['CTRL']['ip3'],port3=main.params['CTRL']['port3'],ip4=main.params['CTRL']['ip4'],port4=main.params['CTRL']['port4'])
admin07529932013-11-22 14:58:28 -0800106 main.Mininet1.get_sw_controller("s1")
admin07529932013-11-22 14:58:28 -0800107
108# **********************************************************************************************************************************************************************************************
109#Add Flows
110#Deletes any remnant flows from any previous test, add flows from the file labeled <FLOWDEF>, then runs the check flow test
111#NOTE: THE FLOWDEF FILE MUST BE PRESENT ON TESTON VM!!! TestON will copy the file from its home machine into /tmp/flowtmp on the machine the ONOS instance is present on
112
113 def CASE3(self,main) : #Delete any remnant flows, then add flows, and time how long it takes flow tables to update
114 main.log.report("Delete any flows from previous tests, then add flows from FLOWDEF file, then wait for switch flow tables to update")
115 import time
admin07529932013-11-22 14:58:28 -0800116 main.case("Taking care of these flows!")
117 main.step("Cleaning out any leftover flows...")
118 main.ONOS1.delete_flow("all")
admin07529932013-11-22 14:58:28 -0800119 strtTime = time.time()
120 main.ONOS1.add_flow(main.params['FLOWDEF'])
121 main.case("Checking flows")
admin07529932013-11-22 14:58:28 -0800122
123 count = 1
124 i = 6
125 while i < 16 :
126 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
127 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admin68453302013-12-16 15:40:04 -0800128 if ping == main.FALSE and count < 9:
admin07529932013-11-22 14:58:28 -0800129 count = count + 1
130 i = 6
admin68453302013-12-16 15:40:04 -0800131 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
132 time.sleep(2)
133 elif ping == main.FALSE and count ==9:
admin07529932013-11-22 14:58:28 -0800134 main.log.error("Ping test failed")
135 i = 17
admin68453302013-12-16 15:40:04 -0800136 result = main.FALSE
admin07529932013-11-22 14:58:28 -0800137 elif ping == main.TRUE:
138 i = i + 1
139 result2 = main.TRUE
admin68453302013-12-16 15:40:04 -0800140 endTime = time.time()
141 if result == main.TRUE:
142 main.log.report("\tTime to complete add flows: "+str(round(endTime-strtTime,2))+" seconds")
admin07529932013-11-22 14:58:28 -0800143 else:
144 main.log.report("\tPING TEST FAIL")
145
admin68453302013-12-16 15:40:04 -0800146 result2 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admin07529932013-11-22 14:58:28 -0800147 main.step("Verifying the result")
admin68453302013-12-16 15:40:04 -0800148 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flow check PASS",onfail="Flow check FAIL")
admin07529932013-11-22 14:58:28 -0800149
150#**********************************************************************************************************************************************************************************************
151#This test case removes Controllers 2,3, and 4 then performs a ping test.
152#The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned.
153#The ping test performs single pings on hosts from opposite sides of the topology. If one ping fails, the test waits 5 seconds before trying again.
154#If the ping test fails 6 times, then the test case will return false
155
156 def CASE4(self,main) :
157 main.log.report("Remove ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts")
158 import time
159 for i in range(25):
160 if i < 15:
161 j=i+1
162 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) #Assigning a single controller removes all other controllers
163 else:
164 j=i+16
165 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
166
167 strtTime = time.time()
168 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admin68453302013-12-16 15:40:04 -0800169 for i in range(2):
admin07529932013-11-22 14:58:28 -0800170 if result == main.FALSE:
admin68453302013-12-16 15:40:04 -0800171 time.sleep(5)
admin07529932013-11-22 14:58:28 -0800172 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
173 else:
174 break
175
176 count = 1
177 i = 6
178 while i < 16 :
179 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
180 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
181 if ping == main.FALSE and count < 6:
182 count = count + 1
183 i = 6
184 main.log.info("Ping failed, making attempt number "+str(count)+" in 5 seconds")
admin68453302013-12-16 15:40:04 -0800185 time.sleep(2)
admin07529932013-11-22 14:58:28 -0800186 elif ping == main.FALSE and count ==6:
187 main.log.error("Ping test failed")
188 i = 17
189 result = main.FALSE
190 elif ping == main.TRUE:
191 i = i + 1
192 result = main.TRUE
193 endTime = time.time()
194 if result == main.TRUE:
195 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
196 else:
197 main.log.report("\tPING TEST FAIL")
198 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
199
200# **********************************************************************************************************************************************************************************************
201#This test case restores the controllers removed by Case 4 then performs a ping test.
202
203 def CASE5(self,main) :
204 main.log.report("Restore ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts")
205 import time
206 for i in range(25):
207 if i < 15:
208 j=i+1
Jon Hallf89c8552014-04-02 13:14:06 -0700209 main.Mininet1.assign_sw_controller(sw=str(j),count=4,ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'],ip2=main.params['CTRL']['ip2'],port2=main.params['CTRL']['port2'],ip3=main.params['CTRL']['ip3'],port3=main.params['CTRL']['port3'],ip4=main.params['CTRL']['ip4'],port4=main.params['CTRL']['port4'])
admin07529932013-11-22 14:58:28 -0800210 else:
211 j=i+16
Jon Hallf89c8552014-04-02 13:14:06 -0700212 main.Mininet1.assign_sw_controller(sw=str(j),count=4,ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'],ip2=main.params['CTRL']['ip2'],port2=main.params['CTRL']['port2'],ip3=main.params['CTRL']['ip3'],port3=main.params['CTRL']['port3'],ip4=main.params['CTRL']['ip4'],port4=main.params['CTRL']['port4'])
admin07529932013-11-22 14:58:28 -0800213
214 strtTime = time.time()
215 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admin68453302013-12-16 15:40:04 -0800216 for i in range(2):
admin07529932013-11-22 14:58:28 -0800217 if result == main.FALSE:
218 time.sleep(3)
219 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
220 else:
221 break
222
223 count = 1
224 i = 6
225 while i < 16 :
226 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
227 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
228 if ping == main.FALSE and count < 6:
229 count = count + 1
230 i = 6
231 main.log.info("Ping failed, making attempt number "+str(count)+" in 5 seconds")
admin68453302013-12-16 15:40:04 -0800232 time.sleep(2)
admin07529932013-11-22 14:58:28 -0800233 elif ping == main.FALSE and count ==6:
234 main.log.error("Ping test failed")
235 i = 17
236 result = main.FALSE
237 elif ping == main.TRUE:
238 i = i + 1
239 result = main.TRUE
240 endTime = time.time()
241 if result == main.TRUE:
242 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
243 else:
244 main.log.report("\tPING TEST FAILED")
245 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
246
247# **********************************************************************************************************************************************************************************************
248#Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time
249
250 def CASE6(self,main) :
251 main.log.report("Bring Link between s1 and s2 down, then ping until all hosts are reachable or fail after 10 attempts")
252 import time
253 main.case("Bringing Link down... ")
254 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
255 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...")
256
257 strtTime = time.time()
258 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
admin68453302013-12-16 15:40:04 -0800259 for i in range(2):
admin07529932013-11-22 14:58:28 -0800260 if result == main.FALSE:
admin68453302013-12-16 15:40:04 -0800261 time.sleep(5)
admin07529932013-11-22 14:58:28 -0800262 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
263 else:
264 break
265
266 count = 1
267 i = 6
268 while i < 16 :
269 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
270 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
271 if ping == main.FALSE and count < 10:
272 count = count + 1
273 main.log.info("Ping failed, making attempt number "+str(count)+" in 5 seconds")
274 i = 6
admin68453302013-12-16 15:40:04 -0800275 time.sleep(2)
admin07529932013-11-22 14:58:28 -0800276 elif ping == main.FALSE and count == 10:
277 main.log.error("Ping test failed")
278 i = 17
279 result = main.FALSE
280 elif ping == main.TRUE:
281 i = i + 1
282 result = main.TRUE
283 endTime = time.time()
284 if result == main.TRUE:
285 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
286 else:
287 main.log.report("\tPING TEST FAILED")
288 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
289
290# **********************************************************************************************************************************************************************************************
291#Brings the link that Case 6 took down back up, then runs a ping test to view reroute time
292
293 def CASE7(self,main) :
294 main.log.report("Bring Link between s1 and s2 up, then ping until all hosts are reachable or fail after 10 attempts")
295 import time
296 main.case("Bringing Link up... ")
297 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
298 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...")
299
300 strtTime = time.time()
301 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admin68453302013-12-16 15:40:04 -0800302 for i in range(2):
admin07529932013-11-22 14:58:28 -0800303 if result == main.FALSE:
admin68453302013-12-16 15:40:04 -0800304 time.sleep(5)
admin07529932013-11-22 14:58:28 -0800305 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
306 else:
307 break
308
309 strtTime = time.time()
310 count = 1
311 i = 6
312 while i < 16 :
313 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
314 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
315 if ping == main.FALSE and count < 10:
316 count = count + 1
317 main.log.info("Ping failed, making attempt number "+str(count)+" in 5 seconds")
318 i = 6
admin68453302013-12-16 15:40:04 -0800319 time.sleep(2)
admin07529932013-11-22 14:58:28 -0800320 elif ping == main.FALSE and count ==10:
321 main.log.error("Ping test failed")
322 i = 17
323 result = main.FALSE
324 elif ping == main.TRUE:
325 i = i + 1
326 result = main.TRUE
327 endTime = time.time()
328 if result == main.TRUE:
329 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
330 else:
331 main.log.report("\tPING TESTS FAILED")
332 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
333
334
335# ******************************************************************************************************************************************************************
336# Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch
337
338 def CASE21(self,main) :
339 import json
admin07529932013-11-22 14:58:28 -0800340 main.log.report("Test device discovery function, by attach/detach/move host h1 from s1->s6->s1.")
admin68453302013-12-16 15:40:04 -0800341 main.log.report("Check initially hostMAC/IP exist on the mininet...")
admin07529932013-11-22 14:58:28 -0800342 host = main.params['YANK']['hostname']
343 mac = main.params['YANK']['hostmac']
admin68453302013-12-16 15:40:04 -0800344 hostip = main.params['YANK']['hostip']
admin07529932013-11-22 14:58:28 -0800345 RestIP1 = main.params['RESTCALL']['restIP1']
admin07529932013-11-22 14:58:28 -0800346 RestPort = main.params['RESTCALL']['restPort']
347 url = main.params['RESTCALL']['restURL']
348 #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort)
admin68453302013-12-16 15:40:04 -0800349
admin07529932013-11-22 14:58:28 -0800350 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
Jon Hallf38785a2014-04-08 16:28:22 -0700351 Reststatus, RestSwitch, RestPort = main.ONOS1.find_host(RestIP1,RestPort,url, hostip)
admin07529932013-11-22 14:58:28 -0800352 try:
admin68453302013-12-16 15:40:04 -0800353 attachedSW = RestSwitch[0]['dpid']
354 host_ip = RestSwitch[0]['devices'][0]['ipv4addresses']
admin07529932013-11-22 14:58:28 -0800355 except:
356 Reststatus = 0
admin68453302013-12-16 15:40:04 -0800357 if Reststatus == 1 and host_ip == '10.0.0.1':
admin07529932013-11-22 14:58:28 -0800358 main.log.report("\tFound host " + host + " attached to switchDPID = " + attachedSW)
admin68453302013-12-16 15:40:04 -0800359 result = main.TRUE
360 elif Reststatus > 1:
361 main.log.report("\t Host " + host + " with MAC:" + str(mac) + " has " + Reststatus + " duplicated IP addresses. FAILED")
admin07529932013-11-22 14:58:28 -0800362 else:
363 main.log.report("\t Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
364 result = main.FALSE
365
admin68453302013-12-16 15:40:04 -0800366 main.log.info("\n\t\t\t\t ping issue one ping from" + str(host) + "to generate arp to switch. Ping result is not important" )
367
admin07529932013-11-22 14:58:28 -0800368 ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 #####
369
370 main.log.report("Yank out s1-eth1")
371 main.case("Yankout s6-eth1 (link to h1) from s1")
372 result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf'])
373 time.sleep(3)
374 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...")
admin68453302013-12-16 15:40:04 -0800375
376 main.log.info("\n\t\t\t\t ping issue one ping from" + str(host) + "to generate arp to switch. Ping result is not important" )
admin07529932013-11-22 14:58:28 -0800377 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
Jon Hallf38785a2014-04-08 16:28:22 -0700378 Reststatus, RestSwitch, RestPort = main.ONOS1.find_host(RestIP1,RestPort,url, hostip)
admin07529932013-11-22 14:58:28 -0800379 try:
admin68453302013-12-16 15:40:04 -0800380 attachedSW = RestSwitch[0]['dpid']
381 host_ip = RestSwitch[0]['devices'][0]['ipv4addresses']
admin07529932013-11-22 14:58:28 -0800382 except:
383 Reststatus = 0
admin68453302013-12-16 15:40:04 -0800384 if Reststatus == 1 and host_ip == '10.0.0.1':
385 main.log.report("\tFound host " + host + " attached to switchDPID = " + attachedSW)
admin07529932013-11-22 14:58:28 -0800386 result = main.TRUE
admin68453302013-12-16 15:40:04 -0800387 elif Reststatus > 1:
388 main.log.report("\t Host " + host + " with MAC:" + str(mac) + " has " + Reststatus + " duplicated IP addresses. FAILED")
admin07529932013-11-22 14:58:28 -0800389 else:
admin68453302013-12-16 15:40:04 -0800390 main.log.report("\t Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
admin07529932013-11-22 14:58:28 -0800391 result = main.FALSE
admin68453302013-12-16 15:40:04 -0800392
393
admin07529932013-11-22 14:58:28 -0800394 ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ######
395 main.log.report("Plug s1-eth1 into s6")
396 main.case("Plug s1-eth1 to s6")
397 result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf'])
398 time.sleep(3)
399 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...")
admin68453302013-12-16 15:40:04 -0800400 main.log.info("\n\t\t\t\t ping issue one ping from" + str(host) + "to generate arp to switch. Ping result is not important" )
401
admin07529932013-11-22 14:58:28 -0800402 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
Jon Hallf38785a2014-04-08 16:28:22 -0700403 Reststatus, RestSwitch, RestPort = main.ONOS1.find_host(RestIP1,RestPort,url, hostip)
admin07529932013-11-22 14:58:28 -0800404 try:
admin68453302013-12-16 15:40:04 -0800405 attachedSW = RestSwitch[0]['dpid']
406 host_ip = RestSwitch[0]['devices'][0]['ipv4addresses']
admin07529932013-11-22 14:58:28 -0800407 except:
408 Reststatus = 0
admin68453302013-12-16 15:40:04 -0800409 if Reststatus == 1 and host_ip == '10.0.0.1':
410 main.log.report("\tFound host " + host + " attached to switchDPID = " + attachedSW)
411 result = main.TRUE
412 elif Reststatus > 1:
413 main.log.report("\t Host " + host + " with MAC:" + str(mac) + " has " + Reststatus + " duplicated IP addresses. FAILED")
admin07529932013-11-22 14:58:28 -0800414 else:
admin68453302013-12-16 15:40:04 -0800415 main.log.report("\t Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
admin07529932013-11-22 14:58:28 -0800416 result = main.FALSE
417
admin68453302013-12-16 15:40:04 -0800418
admin07529932013-11-22 14:58:28 -0800419 ###### Step to put interface "s1-eth1" back to s1"#####
420 main.log.report("Move s1-eth1 back on to s1")
421 main.case("Move s1-eth1 back to s1")
422 result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf'])
423 time.sleep(3)
424 retult = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf'])
425 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...")
admin68453302013-12-16 15:40:04 -0800426 main.log.info("\n\t\t\t\t ping issue one ping from" + str(host) + "to generate arp to switch. Ping result is not important" )
427
admin07529932013-11-22 14:58:28 -0800428 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
Jon Hallf38785a2014-04-08 16:28:22 -0700429 Reststatus, RestSwitch, RestPort = main.ONOS1.find_host(RestIP1,RestPort,url, hostip)
admin07529932013-11-22 14:58:28 -0800430 try:
admin68453302013-12-16 15:40:04 -0800431 attachedSW = RestSwitch[0]['dpid']
432 host_ip = RestSwitch[0]['devices'][0]['ipv4addresses']
admin07529932013-11-22 14:58:28 -0800433 except:
434 Reststatus = 0
admin68453302013-12-16 15:40:04 -0800435 if Reststatus == 1 and host_ip == '10.0.0.1':
436 main.log.report("\tFound host " + host + " attached to switchDPID = " + attachedSW)
437 result = main.TRUE
438 elif Reststatus > 1:
439 main.log.report("\t Host " + host + " with MAC:" + str(mac) + " has " + Reststatus + " duplicated IP addresses. FAILED")
admin07529932013-11-22 14:58:28 -0800440 else:
admin68453302013-12-16 15:40:04 -0800441 main.log.report("\t Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
admin07529932013-11-22 14:58:28 -0800442 result = main.FALSE
443
admin68453302013-12-16 15:40:04 -0800444
admin07529932013-11-22 14:58:28 -0800445 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED")
446
admin07529932013-11-22 14:58:28 -0800447