blob: 7217d4dcebcd216cdd5483e14a7062427a1de6b7 [file] [log] [blame]
GlennRCa5391372015-10-14 17:28:15 -07001"""
2 These functions can be used for topology comparisons
3"""
GlennRCa5391372015-10-14 17:28:15 -07004import time
5import os
6import json
7
Jon Hallfc951072017-05-24 15:55:34 -07008
GlennRCa5391372015-10-14 17:28:15 -07009def getAllDevices( main ):
10 """
11 Return a list containing the devices output from each ONOS node
12 """
13 devices = []
14 threads = []
15 for i in range( main.numCtrls ):
Jon Hallfc951072017-05-24 15:55:34 -070016 t = main.Thread( target=main.CLIs[ i ].devices,
GlennRCa5391372015-10-14 17:28:15 -070017 name="devices-" + str( i ),
Jon Hallfc951072017-05-24 15:55:34 -070018 args=[] )
GlennRCa5391372015-10-14 17:28:15 -070019 threads.append( t )
20 t.start()
21
22 for t in threads:
23 t.join()
24 devices.append( t.result )
25 return devices
26
Jon Hallfc951072017-05-24 15:55:34 -070027
GlennRCa5391372015-10-14 17:28:15 -070028def getAllHosts( main ):
29 """
30 Return a list containing the hosts output from each ONOS node
31 """
32 hosts = []
33 ipResult = main.TRUE
34 threads = []
35 for i in range( main.numCtrls ):
Jon Hallfc951072017-05-24 15:55:34 -070036 t = main.Thread( target=main.CLIs[ i ].hosts,
GlennRCa5391372015-10-14 17:28:15 -070037 name="hosts-" + str( i ),
Jon Hallfc951072017-05-24 15:55:34 -070038 args=[] )
GlennRCa5391372015-10-14 17:28:15 -070039 threads.append( t )
40 t.start()
41
42 for t in threads:
43 t.join()
44 hosts.append( t.result )
45 return hosts
46
Jon Hallfc951072017-05-24 15:55:34 -070047
GlennRCa5391372015-10-14 17:28:15 -070048def getAllPorts( main ):
49 """
50 Return a list containing the ports output from each ONOS node
51 """
52 ports = []
53 threads = []
54 for i in range( main.numCtrls ):
Jon Hallfc951072017-05-24 15:55:34 -070055 t = main.Thread( target=main.CLIs[ i ].ports,
GlennRCa5391372015-10-14 17:28:15 -070056 name="ports-" + str( i ),
Jon Hallfc951072017-05-24 15:55:34 -070057 args=[] )
GlennRCa5391372015-10-14 17:28:15 -070058 threads.append( t )
59 t.start()
60
61 for t in threads:
62 t.join()
63 ports.append( t.result )
64 return ports
65
Jon Hallfc951072017-05-24 15:55:34 -070066
GlennRCa5391372015-10-14 17:28:15 -070067def getAllLinks( main ):
68 """
69 Return a list containing the links output from each ONOS node
70 """
71 links = []
72 threads = []
73 for i in range( main.numCtrls ):
Jon Hallfc951072017-05-24 15:55:34 -070074 t = main.Thread( target=main.CLIs[ i ].links,
GlennRCa5391372015-10-14 17:28:15 -070075 name="links-" + str( i ),
Jon Hallfc951072017-05-24 15:55:34 -070076 args=[] )
GlennRCa5391372015-10-14 17:28:15 -070077 threads.append( t )
78 t.start()
79
80 for t in threads:
81 t.join()
82 links.append( t.result )
83 return links
84
Jon Hallfc951072017-05-24 15:55:34 -070085
GlennRCa5391372015-10-14 17:28:15 -070086def getAllClusters( main ):
87 """
88 Return a list containing the clusters output from each ONOS node
89 """
90 clusters = []
91 threads = []
92 for i in range( main.numCtrls ):
Jon Hallfc951072017-05-24 15:55:34 -070093 t = main.Thread( target=main.CLIs[ i ].clusters,
GlennRCa5391372015-10-14 17:28:15 -070094 name="clusters-" + str( i ),
Jon Hallfc951072017-05-24 15:55:34 -070095 args=[] )
GlennRCa5391372015-10-14 17:28:15 -070096 threads.append( t )
97 t.start()
98
99 for t in threads:
100 t.join()
101 clusters.append( t.result )
102 return clusters