kelvin-onlab | d9e23de | 2015-08-06 10:34:44 -0700 | [diff] [blame] | 1 | """ |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 2 | Copyright 2015 Open Networking Foundation ( ONF ) |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 3 | |
| 4 | Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 5 | the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 6 | or 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 Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 11 | ( at your option ) any later version. |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 12 | |
| 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 Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 21 | """ |
kelvin-onlab | d9e23de | 2015-08-06 10:34:44 -0700 | [diff] [blame] | 22 | These functions can be used for topology comparisons |
| 23 | """ |
kelvin-onlab | d9e23de | 2015-08-06 10:34:44 -0700 | [diff] [blame] | 24 | import time |
| 25 | import os |
| 26 | import json |
| 27 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 28 | |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 29 | def sendArpPackage( main, hostList ): |
| 30 | import json |
YPZhang | 26a139e | 2016-04-25 14:01:55 -0700 | [diff] [blame] | 31 | import time |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 32 | """ |
| 33 | send arping package from host |
| 34 | return the total hosts number from Onos |
| 35 | """ |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 36 | main.log.info( "Sending Arping package..." ) |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 37 | if isinstance( hostList, list ): |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 38 | for h in hostList: |
YPZhang | 26a139e | 2016-04-25 14:01:55 -0700 | [diff] [blame] | 39 | main.Mininet1.arping( srcHost=h, dstHost="10.0.0.1", output=main.FALSE, noResult=True ) |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 40 | else: |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 41 | main.Mininet1.arping( srcHost=hostList, dstHost="10.0.0.1", output=main.FALSE, noResult=True ) |
Devin Lim | a7cfdbd | 2017-09-29 15:02:22 -0700 | [diff] [blame] | 42 | |
| 43 | def getHostNum( main ): |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 44 | try: |
| 45 | summaryStr = "" |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 46 | summaryStr = json.loads( main.Cluster.active( 0 ).CLI.summary().encode() ) |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 47 | hostNum = summaryStr.get( 'hosts' ) |
Devin Lim | a7cfdbd | 2017-09-29 15:02:22 -0700 | [diff] [blame] | 48 | main.log.info( "host nums from ONOS : " + str( hostNum ) ) |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 49 | except ( TypeError, ValueError ): |
| 50 | main.log.exception( " Object not as expected: {!r}".format( summaryStr ) ) |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 51 | return -1 |
| 52 | except Exception: |
| 53 | main.log.exception( self.name + ": Uncaught exception!" ) |
| 54 | return -1 |
| 55 | |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 56 | return hostNum |