Jon Hall | 66e001c | 2015-11-12 09:45:10 -0800 | [diff] [blame] | 1 | """ |
| 2 | These functions are for use with the Network config system |
| 3 | """ |
| 4 | import time |
| 5 | |
Jon Hall | bc080f9 | 2017-05-24 16:29:55 -0700 | [diff] [blame] | 6 | |
Jon Hall | 66e001c | 2015-11-12 09:45:10 -0800 | [diff] [blame] | 7 | def compareCfg( main, gossipTime=None ): |
| 8 | """ |
| 9 | Compare the network configurations across all nodes in the network |
| 10 | gossipTime is the number of seconds each gossip round take for the netCfg maps |
| 11 | """ |
| 12 | main.step( "Check net config" ) |
| 13 | if gossipTime: |
| 14 | time.sleep( gossipTime * len( main.nodes ) ) |
| 15 | responses = [] |
| 16 | failMsg = "Net Cfg is different on some nodes." |
| 17 | failed = False |
| 18 | for node in main.nodes: |
Jon Hall | bc080f9 | 2017-05-24 16:29:55 -0700 | [diff] [blame] | 19 | response = node.getNetCfg() |
Jon Hall | 66e001c | 2015-11-12 09:45:10 -0800 | [diff] [blame] | 20 | responses.append( node.pprint( response ) ) |
| 21 | if response == main.FALSE: |
| 22 | failed = True |
Jon Hall | bc080f9 | 2017-05-24 16:29:55 -0700 | [diff] [blame] | 23 | compare = [ i == responses[ 0 ] for i in responses ] |
Jon Hall | 66e001c | 2015-11-12 09:45:10 -0800 | [diff] [blame] | 24 | if failed: |
| 25 | failMsg += " Some nodes failed to GET netCfg." |
| 26 | utilities.assert_equals( expect=True, |
| 27 | actual=all( compare ), |
| 28 | onpass="Net Cfg is the same on all nodes", |
| 29 | onfail=failMsg ) |
| 30 | if not all( compare ): |
| 31 | main.log.debug( "Net Config results:" ) |
| 32 | for i in responses: |
| 33 | main.log.debug( i ) |