blob: 39f32b17d4bea058a22983dc097cbda58145c3ef [file] [log] [blame]
Jon Hall66e001c2015-11-12 09:45:10 -08001"""
2These functions are for use with the Network config system
3"""
4import time
5
Jon Hallbc080f92017-05-24 16:29:55 -07006
Jon Hall66e001c2015-11-12 09:45:10 -08007def 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 Hallbc080f92017-05-24 16:29:55 -070019 response = node.getNetCfg()
Jon Hall66e001c2015-11-12 09:45:10 -080020 responses.append( node.pprint( response ) )
21 if response == main.FALSE:
22 failed = True
Jon Hallbc080f92017-05-24 16:29:55 -070023 compare = [ i == responses[ 0 ] for i in responses ]
Jon Hall66e001c2015-11-12 09:45:10 -080024 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 )