GlennRC | a539137 | 2015-10-14 17:28:15 -0700 | [diff] [blame] | 1 | """ |
| 2 | These functions can be used for topology comparisons |
| 3 | """ |
GlennRC | a539137 | 2015-10-14 17:28:15 -0700 | [diff] [blame] | 4 | import time |
| 5 | import os |
| 6 | import json |
| 7 | |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 8 | |
GlennRC | a539137 | 2015-10-14 17:28:15 -0700 | [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 | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 16 | t = main.Thread( target=main.CLIs[ i ].devices, |
GlennRC | a539137 | 2015-10-14 17:28:15 -0700 | [diff] [blame] | 17 | name="devices-" + str( i ), |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 18 | args=[] ) |
GlennRC | a539137 | 2015-10-14 17:28:15 -0700 | [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 | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 27 | |
GlennRC | a539137 | 2015-10-14 17:28:15 -0700 | [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 | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 36 | t = main.Thread( target=main.CLIs[ i ].hosts, |
GlennRC | a539137 | 2015-10-14 17:28:15 -0700 | [diff] [blame] | 37 | name="hosts-" + str( i ), |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 38 | args=[] ) |
GlennRC | a539137 | 2015-10-14 17:28:15 -0700 | [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 | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 47 | |
GlennRC | a539137 | 2015-10-14 17:28:15 -0700 | [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 | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 55 | t = main.Thread( target=main.CLIs[ i ].ports, |
GlennRC | a539137 | 2015-10-14 17:28:15 -0700 | [diff] [blame] | 56 | name="ports-" + str( i ), |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 57 | args=[] ) |
GlennRC | a539137 | 2015-10-14 17:28:15 -0700 | [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 | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 66 | |
GlennRC | a539137 | 2015-10-14 17:28:15 -0700 | [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 | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 74 | t = main.Thread( target=main.CLIs[ i ].links, |
GlennRC | a539137 | 2015-10-14 17:28:15 -0700 | [diff] [blame] | 75 | name="links-" + str( i ), |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 76 | args=[] ) |
GlennRC | a539137 | 2015-10-14 17:28:15 -0700 | [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 | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 85 | |
GlennRC | a539137 | 2015-10-14 17:28:15 -0700 | [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 | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 93 | t = main.Thread( target=main.CLIs[ i ].clusters, |
GlennRC | a539137 | 2015-10-14 17:28:15 -0700 | [diff] [blame] | 94 | name="clusters-" + str( i ), |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 95 | args=[] ) |
GlennRC | a539137 | 2015-10-14 17:28:15 -0700 | [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 |