Subhash Kumar Singh | c73b3a7 | 2015-11-03 21:34:04 -0800 | [diff] [blame] | 1 | """ |
| 2 | These functions can be used for topology comparisons |
| 3 | """ |
Subhash Kumar Singh | c73b3a7 | 2015-11-03 21:34:04 -0800 | [diff] [blame] | 4 | import time |
| 5 | import os |
| 6 | import json |
| 7 | |
Jon Hall | bc080f9 | 2017-05-24 16:29:55 -0700 | [diff] [blame] | 8 | |
Subhash Kumar Singh | c73b3a7 | 2015-11-03 21:34:04 -0800 | [diff] [blame] | 9 | def 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 Hall | bc080f9 | 2017-05-24 16:29:55 -0700 | [diff] [blame] | 16 | t = main.Thread( target=main.CLIs[ i ].devices, |
Subhash Kumar Singh | c73b3a7 | 2015-11-03 21:34:04 -0800 | [diff] [blame] | 17 | name="devices-" + str( i ), |
Jon Hall | bc080f9 | 2017-05-24 16:29:55 -0700 | [diff] [blame] | 18 | args=[] ) |
Subhash Kumar Singh | c73b3a7 | 2015-11-03 21:34:04 -0800 | [diff] [blame] | 19 | 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 Hall | bc080f9 | 2017-05-24 16:29:55 -0700 | [diff] [blame] | 27 | |
Subhash Kumar Singh | c73b3a7 | 2015-11-03 21:34:04 -0800 | [diff] [blame] | 28 | def 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 Hall | bc080f9 | 2017-05-24 16:29:55 -0700 | [diff] [blame] | 36 | t = main.Thread( target=main.CLIs[ i ].hosts, |
Subhash Kumar Singh | c73b3a7 | 2015-11-03 21:34:04 -0800 | [diff] [blame] | 37 | name="hosts-" + str( i ), |
Jon Hall | bc080f9 | 2017-05-24 16:29:55 -0700 | [diff] [blame] | 38 | args=[] ) |
Subhash Kumar Singh | c73b3a7 | 2015-11-03 21:34:04 -0800 | [diff] [blame] | 39 | 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 Hall | bc080f9 | 2017-05-24 16:29:55 -0700 | [diff] [blame] | 47 | |
Subhash Kumar Singh | c73b3a7 | 2015-11-03 21:34:04 -0800 | [diff] [blame] | 48 | def 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 Hall | bc080f9 | 2017-05-24 16:29:55 -0700 | [diff] [blame] | 55 | t = main.Thread( target=main.CLIs[ i ].ports, |
Subhash Kumar Singh | c73b3a7 | 2015-11-03 21:34:04 -0800 | [diff] [blame] | 56 | name="ports-" + str( i ), |
Jon Hall | bc080f9 | 2017-05-24 16:29:55 -0700 | [diff] [blame] | 57 | args=[] ) |
Subhash Kumar Singh | c73b3a7 | 2015-11-03 21:34:04 -0800 | [diff] [blame] | 58 | 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 Hall | bc080f9 | 2017-05-24 16:29:55 -0700 | [diff] [blame] | 66 | |
Subhash Kumar Singh | c73b3a7 | 2015-11-03 21:34:04 -0800 | [diff] [blame] | 67 | def 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 Hall | bc080f9 | 2017-05-24 16:29:55 -0700 | [diff] [blame] | 74 | t = main.Thread( target=main.CLIs[ i ].links, |
Subhash Kumar Singh | c73b3a7 | 2015-11-03 21:34:04 -0800 | [diff] [blame] | 75 | name="links-" + str( i ), |
Jon Hall | bc080f9 | 2017-05-24 16:29:55 -0700 | [diff] [blame] | 76 | args=[] ) |
Subhash Kumar Singh | c73b3a7 | 2015-11-03 21:34:04 -0800 | [diff] [blame] | 77 | 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 Hall | bc080f9 | 2017-05-24 16:29:55 -0700 | [diff] [blame] | 85 | |
Subhash Kumar Singh | c73b3a7 | 2015-11-03 21:34:04 -0800 | [diff] [blame] | 86 | def 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 Hall | bc080f9 | 2017-05-24 16:29:55 -0700 | [diff] [blame] | 93 | t = main.Thread( target=main.CLIs[ i ].clusters, |
Subhash Kumar Singh | c73b3a7 | 2015-11-03 21:34:04 -0800 | [diff] [blame] | 94 | name="clusters-" + str( i ), |
Jon Hall | bc080f9 | 2017-05-24 16:29:55 -0700 | [diff] [blame] | 95 | args=[] ) |
Subhash Kumar Singh | c73b3a7 | 2015-11-03 21:34:04 -0800 | [diff] [blame] | 96 | threads.append( t ) |
| 97 | t.start() |
| 98 | |
| 99 | for t in threads: |
| 100 | t.join() |
| 101 | clusters.append( t.result ) |
| 102 | return clusters |