blob: 373ed2b0331c865a887199eaf053557f3183f6c0 [file] [log] [blame]
kelvin-onlabd9e23de2015-08-06 10:34:44 -07001"""
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07002Copyright 2015 Open Networking Foundation ( ONF )
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07003
4Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
5the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
6or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
7
8 TestON is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 2 of the License, or
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070011 ( at your option ) any later version.
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -070012
13 TestON is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with TestON. If not, see <http://www.gnu.org/licenses/>.
20"""
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -070021"""
kelvin-onlabd9e23de2015-08-06 10:34:44 -070022 These functions can be used for topology comparisons
23"""
kelvin-onlabd9e23de2015-08-06 10:34:44 -070024import time
25import os
26import json
27
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070028
YPZhang81a7d4e2016-04-18 13:10:17 -070029def sendArpPackage( main, hostList ):
30 import json
YPZhang26a139e2016-04-25 14:01:55 -070031 import time
YPZhang81a7d4e2016-04-18 13:10:17 -070032 """
33 send arping package from host
34 return the total hosts number from Onos
35 """
YPZhangacaaf422016-07-26 09:34:03 -070036 main.log.info( "Sending Arping package..." )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070037 if isinstance( hostList, list ):
YPZhang81a7d4e2016-04-18 13:10:17 -070038 for h in hostList:
YPZhang26a139e2016-04-25 14:01:55 -070039 main.Mininet1.arping( srcHost=h, dstHost="10.0.0.1", output=main.FALSE, noResult=True )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070040 time.sleep( 0.5 )
YPZhang81a7d4e2016-04-18 13:10:17 -070041 else:
YPZhangacaaf422016-07-26 09:34:03 -070042 main.Mininet1.arping( srcHost=hostList, dstHost="10.0.0.1", output=main.FALSE, noResult=True )
43 try:
44 summaryStr = ""
Devin Lim142b5342017-07-20 15:22:39 -070045 summaryStr = json.loads( main.Cluster.active( 0 ).CLI.summary().encode() )
YPZhangacaaf422016-07-26 09:34:03 -070046 hostNum = summaryStr.get( 'hosts' )
47
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070048 except ( TypeError, ValueError ):
49 main.log.exception( " Object not as expected: {!r}".format( summaryStr ) )
YPZhangacaaf422016-07-26 09:34:03 -070050 return -1
51 except Exception:
52 main.log.exception( self.name + ": Uncaught exception!" )
53 return -1
54
YPZhang81a7d4e2016-04-18 13:10:17 -070055 return hostNum