Jon Hall | a3e0243 | 2015-07-24 15:55:42 -0700 | [diff] [blame] | 1 | """ |
| 2 | These functions can be used for topology comparisons |
| 3 | """ |
| 4 | |
| 5 | import time |
| 6 | import os |
| 7 | import json |
| 8 | |
| 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 ): |
| 16 | t = main.Thread( target=main.CLIs[i].devices, |
| 17 | name="devices-" + str( i ), |
| 18 | args=[ ] ) |
| 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 | |
| 27 | def getAllHosts( main ): |
| 28 | """ |
| 29 | Return a list containing the hosts output from each ONOS node |
| 30 | """ |
| 31 | hosts = [] |
| 32 | ipResult = main.TRUE |
| 33 | threads = [] |
| 34 | for i in range( main.numCtrls ): |
| 35 | t = main.Thread( target=main.CLIs[i].hosts, |
| 36 | name="hosts-" + str( i ), |
| 37 | args=[ ] ) |
| 38 | threads.append( t ) |
| 39 | t.start() |
| 40 | |
| 41 | for t in threads: |
| 42 | t.join() |
| 43 | hosts.append( t.result ) |
| 44 | return hosts |
| 45 | |
| 46 | def getAllPorts( main ): |
| 47 | """ |
| 48 | Return a list containing the ports output from each ONOS node |
| 49 | """ |
| 50 | ports = [] |
| 51 | threads = [] |
| 52 | for i in range( main.numCtrls ): |
| 53 | t = main.Thread( target=main.CLIs[i].ports, |
| 54 | name="ports-" + str( i ), |
| 55 | args=[ ] ) |
| 56 | threads.append( t ) |
| 57 | t.start() |
| 58 | |
| 59 | for t in threads: |
| 60 | t.join() |
| 61 | ports.append( t.result ) |
| 62 | return ports |
| 63 | |
| 64 | def getAllLinks( main ): |
| 65 | """ |
| 66 | Return a list containing the links output from each ONOS node |
| 67 | """ |
| 68 | links = [] |
| 69 | threads = [] |
| 70 | for i in range( main.numCtrls ): |
| 71 | t = main.Thread( target=main.CLIs[i].links, |
| 72 | name="links-" + str( i ), |
| 73 | args=[ ] ) |
| 74 | threads.append( t ) |
| 75 | t.start() |
| 76 | |
| 77 | for t in threads: |
| 78 | t.join() |
| 79 | links.append( t.result ) |
| 80 | return links |
| 81 | |
| 82 | def getAllClusters( main ): |
| 83 | """ |
| 84 | Return a list containing the clusters output from each ONOS node |
| 85 | """ |
| 86 | clusters = [] |
| 87 | threads = [] |
| 88 | for i in range( main.numCtrls ): |
| 89 | t = main.Thread( target=main.CLIs[i].clusters, |
| 90 | name="clusters-" + str( i ), |
| 91 | args=[ ] ) |
| 92 | threads.append( t ) |
| 93 | t.start() |
| 94 | |
| 95 | for t in threads: |
| 96 | t.join() |
| 97 | clusters.append( t.result ) |
| 98 | return clusters |
| 99 | |
| 100 | |