blob: 699a17d83406d59aa3366a8c39d393e272dabf38 [file] [log] [blame]
You Wangdb927a52016-02-26 11:03:28 -08001"""
2This file contains intent class for CHOTestMonkey
3Author: you@onlab.us
4"""
5from threading import Lock
6
7class 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
31class 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
43class 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
53class 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