blob: 6831811345724ede7d6568238eaa6dc97fad9d6e [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
You Wang2b687c02016-05-13 17:01:31 -070036 self.expectedState = 'INSTALLED'
You Wangdb927a52016-02-26 11:03:28 -080037
38 def isHostIntent( self ):
39 return self.type == 'INTENT_HOST'
40
41 def isPointIntent( self ):
42 return self.type == 'INTENT_POINT'
43
You Wang2b687c02016-05-13 17:01:31 -070044 def isFailed( self ):
45 return self.expectedState == 'FAILED'
46
47 def isInstalled( self ):
48 return self.expectedState == 'INSTALLED'
49
50 def setFailed( self ):
51 self.expectedState = 'FAILED'
52
53 def setInstalled( self ):
54 self.expectedState = 'INSTALLED'
55
You Wangdb927a52016-02-26 11:03:28 -080056class HostIntent( Intent ):
57 def __init__( self, id, hostA, hostB ):
58 Intent.__init__( self, id )
59 self.type = 'INTENT_HOST'
60 self.hostA = hostA
61 self.hostB = hostB
You Wang2b687c02016-05-13 17:01:31 -070062 self.deviceA = hostA.device
63 self.deviceB = hostB.device
You Wangdb927a52016-02-26 11:03:28 -080064
65 def __str__( self ):
66 return "ID: " + self.id
67
68class PointIntent( Intent ):
69 def __init__( self, id, deviceA, deviceB ):
70 Intent.__init__( self, id )
71 self.type = 'INTENT_POINT'
72 self.deviceA = deviceA
73 self.deviceB = deviceB
74
75 def __str__( self ):
76 return "ID: " + self.id