You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 1 | """ |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame^] | 2 | Copyright 2016 Open Networking Foundation (ONF) |
| 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 |
| 11 | (at your option) any later version. |
| 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 | """ |
| 21 | |
| 22 | """ |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 23 | This file contains device, host and link class for CHOTestMonkey |
| 24 | Author: you@onlab.us |
| 25 | """ |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 26 | class NetworkElement: |
Jon Hall | 2bb3e21 | 2017-05-24 17:07:25 -0700 | [diff] [blame] | 27 | |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 28 | def __init__( self, index ): |
| 29 | self.default = '' |
| 30 | self.index = index |
| 31 | self.status = 'up' |
| 32 | |
| 33 | def isUp( self ): |
| 34 | return self.status == 'up' |
| 35 | |
| 36 | def isDown( self ): |
| 37 | return self.status == 'down' |
| 38 | |
| 39 | def isRemoved( self ): |
| 40 | return self.status == 'removed' |
| 41 | |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 42 | def setRemoved( self ): |
| 43 | self.status = 'removed' |
| 44 | |
| 45 | def bringDown( self ): |
| 46 | self.status = 'down' |
| 47 | |
| 48 | def bringUp( self ): |
| 49 | self.status = 'up' |
| 50 | |
Jon Hall | 2bb3e21 | 2017-05-24 17:07:25 -0700 | [diff] [blame] | 51 | |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 52 | class Device( NetworkElement ): |
Jon Hall | 2bb3e21 | 2017-05-24 17:07:25 -0700 | [diff] [blame] | 53 | |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 54 | def __init__( self, index, name, dpid ): |
| 55 | NetworkElement.__init__( self, index ) |
| 56 | self.name = name |
| 57 | self.dpid = dpid |
| 58 | self.hosts = [] |
| 59 | # For each bidirectional link, we only store one direction here |
| 60 | self.outgoingLinks = [] |
| 61 | |
| 62 | def __str__( self ): |
You Wang | 7a27f3a | 2016-07-05 10:12:27 -0700 | [diff] [blame] | 63 | return "name: " + self.name + ", dpid: " + self.dpid + ", status: " + self.status |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 64 | |
Jon Hall | 2bb3e21 | 2017-05-24 17:07:25 -0700 | [diff] [blame] | 65 | |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 66 | class Host( NetworkElement ): |
Jon Hall | 2bb3e21 | 2017-05-24 17:07:25 -0700 | [diff] [blame] | 67 | |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 68 | def __init__( self, index, name, id, mac, device, devicePort, vlan, ipAddresses ): |
| 69 | NetworkElement.__init__( self, index ) |
| 70 | self.name = name |
| 71 | self.id = id |
| 72 | self.mac = mac |
| 73 | self.device = device |
| 74 | self.devicePort = devicePort |
| 75 | self.vlan = vlan |
| 76 | self.ipAddresses = ipAddresses |
| 77 | self.correspondents = [] |
| 78 | self.handle = None |
| 79 | |
| 80 | def __str__( self ): |
You Wang | 7a27f3a | 2016-07-05 10:12:27 -0700 | [diff] [blame] | 81 | return "name: " + self.name + ", mac: " + self.mac + ", device: " + self.device.dpid + ", ipAddresses: " + str( self.ipAddresses ) + ", status: " + self.status |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 82 | |
| 83 | def setHandle( self, handle ): |
| 84 | self.handle = handle |
| 85 | |
Jon Hall | 2bb3e21 | 2017-05-24 17:07:25 -0700 | [diff] [blame] | 86 | |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 87 | class Link( NetworkElement ): |
Jon Hall | 2bb3e21 | 2017-05-24 17:07:25 -0700 | [diff] [blame] | 88 | |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 89 | """ |
| 90 | Unidirectional link |
| 91 | """ |
| 92 | def __init__( self, index, deviceA, portA, deviceB, portB ): |
| 93 | NetworkElement.__init__( self, index ) |
| 94 | self.backwardLink = None |
| 95 | self.deviceA = deviceA |
| 96 | self.portA = portA |
| 97 | self.deviceB = deviceB |
| 98 | self.portB = portB |
| 99 | |
| 100 | def __str__( self ): |
You Wang | 7a27f3a | 2016-07-05 10:12:27 -0700 | [diff] [blame] | 101 | return self.deviceA.dpid + "/" + self.portA + " - " + self.deviceB.dpid + "/" + self.portB + ", status: " + self.status |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 102 | |
| 103 | def setBackwardLink( self, link ): |
| 104 | self.backwardLink = link |