You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 1 | """ |
| 2 | This file contains intent class for CHOTestMonkey |
| 3 | Author: you@onlab.us |
| 4 | """ |
| 5 | from threading import Lock |
| 6 | |
| 7 | class Controller: |
| 8 | def __init__( self, index ): |
| 9 | self.default = '' |
| 10 | self.index = index |
| 11 | self.ip = main.onosIPs[ index - 1 ] |
| 12 | self.CLI = None |
| 13 | self.CLILock = Lock() |
| 14 | self.status = 'up' |
| 15 | |
| 16 | def setCLI( self, CLI ): |
| 17 | self.CLI = CLI |
| 18 | |
| 19 | def startCLI( self ): |
| 20 | return self.CLI.startOnosCli( self.ip ) |
| 21 | |
| 22 | def isUp( self ): |
| 23 | return self.status == 'up' |
| 24 | |
| 25 | def bringDown( self ): |
| 26 | self.status = 'down' |
| 27 | |
| 28 | def bringUp( self ): |
| 29 | self.status = 'up' |
| 30 | |
| 31 | class Intent: |
| 32 | def __init__( self, id ): |
| 33 | self.default = '' |
| 34 | self.type = 'INTENT' |
| 35 | self.id = id |
| 36 | |
| 37 | def isHostIntent( self ): |
| 38 | return self.type == 'INTENT_HOST' |
| 39 | |
| 40 | def isPointIntent( self ): |
| 41 | return self.type == 'INTENT_POINT' |
| 42 | |
| 43 | class HostIntent( Intent ): |
| 44 | def __init__( self, id, hostA, hostB ): |
| 45 | Intent.__init__( self, id ) |
| 46 | self.type = 'INTENT_HOST' |
| 47 | self.hostA = hostA |
| 48 | self.hostB = hostB |
| 49 | |
| 50 | def __str__( self ): |
| 51 | return "ID: " + self.id |
| 52 | |
| 53 | class PointIntent( Intent ): |
| 54 | def __init__( self, id, deviceA, deviceB ): |
| 55 | Intent.__init__( self, id ) |
| 56 | self.type = 'INTENT_POINT' |
| 57 | self.deviceA = deviceA |
| 58 | self.deviceB = deviceB |
| 59 | |
| 60 | def __str__( self ): |
| 61 | return "ID: " + self.id |