blob: d0f154dc62e51a31cffa6d85440ab16f60612f1e [file] [log] [blame]
You Wangdb927a52016-02-26 11:03:28 -08001"""
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07002Copyright 2016 Open Networking Foundation (ONF)
3
4Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
5the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
6or 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 Wangdb927a52016-02-26 11:03:28 -080023This file contains classes for CHOTestMonkey that are related to application event
24Author: you@onlab.us
25"""
26from tests.CHOTestMonkey.dependencies.events.Event import EventType, EventStates, Event
27from tests.CHOTestMonkey.dependencies.elements.ONOSElement import HostIntent, PointIntent
28
Jon Hall2bb3e212017-05-24 17:07:25 -070029
You Wangdb927a52016-02-26 11:03:28 -080030class IntentEvent( Event ):
Jon Hall2bb3e212017-05-24 17:07:25 -070031
You Wangdb927a52016-02-26 11:03:28 -080032 def __init__( self ):
33 Event.__init__( self )
34 # The index of the ONOS CLI that is going to run the command
35 self.CLIIndex = 0
36
You Wang7a27f3a2016-07-05 10:12:27 -070037 def getRandomCorrespondent( self, hostA, connected=True ):
38 import random
39 if connected:
40 candidates = hostA.correspondents
41 else:
42 candidates = [ host for host in main.hosts if host not in hostA.correspondents and host != hostA ]
43 if len( candidates ) == 0:
44 return None
Jon Hall2bb3e212017-05-24 17:07:25 -070045 hostB = random.sample( candidates, 1 )[ 0 ]
You Wang7a27f3a2016-07-05 10:12:27 -070046 return hostB
47
48 def getRandomHostPair( self, connected=True ):
49 import random
50 candidateDict = {}
51 with main.variableLock:
52 for host in main.hosts:
53 correspondent = self.getRandomCorrespondent( host, connected=connected )
Jon Hall2bb3e212017-05-24 17:07:25 -070054 if correspondent is not None:
You Wang7a27f3a2016-07-05 10:12:27 -070055 candidateDict[ host ] = correspondent
56 if candidateDict == {}:
57 return None
Jon Hall2bb3e212017-05-24 17:07:25 -070058 hostA = random.sample( candidateDict.keys(), 1 )[ 0 ]
You Wang7a27f3a2016-07-05 10:12:27 -070059 hostB = candidateDict[ hostA ]
60 return [ hostA, hostB ]
61
62 def getIntentsByType( self, intentType ):
63 intents = []
64 with main.variableLock:
65 for intent in main.intents:
66 if intent.type == intentType:
67 intents.append( intent )
68 return intents
69
70 def getRandomIntentByType( self, intentType ):
71 import random
72 intents = self.getIntentsByType( intentType )
73 if len( intents ) == 0:
74 return None
75 intent = random.sample( intents, 1 )[ 0 ]
76 return intent
77
Jon Hall2bb3e212017-05-24 17:07:25 -070078
You Wangdb927a52016-02-26 11:03:28 -080079class HostIntentEvent( IntentEvent ):
Jon Hall2bb3e212017-05-24 17:07:25 -070080
You Wangdb927a52016-02-26 11:03:28 -080081 def __init__( self ):
82 IntentEvent.__init__( self )
83 self.hostA = None
84 self.hostB = None
85
86 def startHostIntentEvent( self ):
87 return EventStates().PASS
88
89 def startEvent( self, args ):
90 with self.eventLock:
You Wang52163202016-07-14 16:37:15 -070091 #main.log.info( "%s - starting event" % ( self.typeString ) )
You Wangdb927a52016-02-26 11:03:28 -080092 if self.typeIndex == EventType().APP_INTENT_HOST_ADD or self.typeIndex == EventType().APP_INTENT_HOST_DEL:
93 if len( args ) < 3:
94 main.log.warn( "%s - Not enough arguments: %s" % ( self.typeString, args ) )
95 return EventStates().ABORT
96 elif len( args ) > 3:
97 main.log.warn( "%s - Too many arguments: %s" % ( self.typeString, args ) )
98 return EventStates().ABORT
You Wang59dfeb62016-07-14 09:47:33 -070099 try:
100 if args[ 0 ] == 'random' or args[ 1 ] == 'random':
101 if self.typeIndex == EventType().APP_INTENT_HOST_ADD:
102 hostPairRandom = self.getRandomHostPair( connected=False )
Jon Hall2bb3e212017-05-24 17:07:25 -0700103 if hostPairRandom is None:
You Wang59dfeb62016-07-14 09:47:33 -0700104 main.log.warn( "All host pairs are connected, aborting event" )
105 return EventStates().ABORT
106 self.hostA = hostPairRandom[ 0 ]
107 self.hostB = hostPairRandom[ 1 ]
108 elif self.typeIndex == EventType().APP_INTENT_HOST_DEL:
109 intent = self.getRandomIntentByType( 'INTENT_HOST' )
Jon Hall2bb3e212017-05-24 17:07:25 -0700110 if intent is None:
You Wang59dfeb62016-07-14 09:47:33 -0700111 main.log.warn( "No host intent for deletion, aborting event" )
112 return EventStates().ABORT
113 self.hostA = intent.hostA
114 self.hostB = intent.hostB
115 elif args[ 0 ] == args[ 1 ]:
116 main.log.warn( "%s - invalid argument: %s, %s" % ( self.typeString, args[ 0 ], args[ 1 ] ) )
You Wangdb927a52016-02-26 11:03:28 -0800117 return EventStates().ABORT
You Wang59dfeb62016-07-14 09:47:33 -0700118 else:
119 for host in main.hosts:
120 if host.name == args[ 0 ]:
121 self.hostA = host
122 elif host.name == args[ 1 ]:
123 self.hostB = host
Jon Hall2bb3e212017-05-24 17:07:25 -0700124 if self.hostA is not None and self.hostB is not None:
You Wang59dfeb62016-07-14 09:47:33 -0700125 break
Jon Hall2bb3e212017-05-24 17:07:25 -0700126 if self.hostA is None:
You Wang59dfeb62016-07-14 09:47:33 -0700127 main.log.warn( "Host %s does not exist: " % ( args[ 0 ] ) )
128 return EventStates().ABORT
Jon Hall2bb3e212017-05-24 17:07:25 -0700129 if self.hostB is None:
You Wang59dfeb62016-07-14 09:47:33 -0700130 main.log.warn( "Host %s does not exist: " % ( args[ 1 ] ) )
131 return EventStates().ABORT
132 index = int( args[ 2 ] )
133 if index < 1 or index > int( main.numCtrls ):
134 main.log.warn( "%s - invalid argument: %s" % ( self.typeString, index ) )
You Wangdb927a52016-02-26 11:03:28 -0800135 return EventStates().ABORT
You Wang59dfeb62016-07-14 09:47:33 -0700136 if not main.controllers[ index - 1 ].isUp():
137 main.log.warn( self.typeString + " - invalid argument: onos %s is down" % ( controller.index ) )
138 return EventStates().ABORT
139 self.CLIIndex = index
140 return self.startHostIntentEvent()
141 except Exception:
142 main.log.warn( "Caught exception, aborting event" )
You Wang7a27f3a2016-07-05 10:12:27 -0700143 return EventStates().ABORT
You Wangdb927a52016-02-26 11:03:28 -0800144
Jon Hall2bb3e212017-05-24 17:07:25 -0700145
You Wangdb927a52016-02-26 11:03:28 -0800146class AddHostIntent( HostIntentEvent ):
Jon Hall2bb3e212017-05-24 17:07:25 -0700147
You Wangdb927a52016-02-26 11:03:28 -0800148 """
Jon Hall2bb3e212017-05-24 17:07:25 -0700149 Add a host-to-host intent ( bidirectional )
You Wangdb927a52016-02-26 11:03:28 -0800150 """
151 def __init__( self ):
152 HostIntentEvent.__init__( self )
153 self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ]
Jon Hall2bb3e212017-05-24 17:07:25 -0700154 self.typeIndex = int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
You Wangdb927a52016-02-26 11:03:28 -0800155
156 def startHostIntentEvent( self ):
You Wang7a27f3a2016-07-05 10:12:27 -0700157 try:
Jon Hall2bb3e212017-05-24 17:07:25 -0700158 assert self.hostA is not None and self.hostB is not None
You Wang7a27f3a2016-07-05 10:12:27 -0700159 # Check whether there already exists some intent for the host pair
160 # For now we should avoid installing overlapping intents
161 for intent in main.intents:
162 if not intent.type == 'INTENT_HOST':
163 continue
164 if intent.hostA == self.hostA and intent.hostB == self.hostB or\
Jon Hall2bb3e212017-05-24 17:07:25 -0700165 intent.hostB == self.hostA and intent.hostA == self.hostB:
You Wang7a27f3a2016-07-05 10:12:27 -0700166 main.log.warn( self.typeString + " - find an exiting intent for the host pair, abort installation" )
167 return EventStates().ABORT
You Wang52163202016-07-14 16:37:15 -0700168 main.log.info( "Event recorded: {} {} {} {} {}".format( self.typeIndex, self.typeString, self.hostA.name, self.hostB.name, self.CLIIndex ) )
You Wang7a27f3a2016-07-05 10:12:27 -0700169 controller = main.controllers[ self.CLIIndex - 1 ]
170 with controller.CLILock:
171 id = controller.CLI.addHostIntent( self.hostA.id, self.hostB.id )
Jon Hall2bb3e212017-05-24 17:07:25 -0700172 if id is None:
You Wang7a27f3a2016-07-05 10:12:27 -0700173 main.log.warn( self.typeString + " - add host intent failed" )
174 return EventStates().FAIL
175 with main.variableLock:
176 newHostIntent = HostIntent( id, self.hostA, self.hostB )
177 if self.hostA.isDown() or self.hostA.isRemoved() or self.hostB.isDown() or self.hostB.isRemoved():
178 newHostIntent.setFailed()
You Wang56577c82016-07-12 10:49:23 -0700179 else:
180 newHostIntent.setInstalled()
You Wang7a27f3a2016-07-05 10:12:27 -0700181 main.intents.append( newHostIntent )
You Wang7a27f3a2016-07-05 10:12:27 -0700182 return EventStates().PASS
183 except Exception:
184 main.log.warn( "Caught exception, aborting event" )
185 return EventStates().ABORT
You Wangdb927a52016-02-26 11:03:28 -0800186
Jon Hall2bb3e212017-05-24 17:07:25 -0700187
You Wangdb927a52016-02-26 11:03:28 -0800188class DelHostIntent( HostIntentEvent ):
Jon Hall2bb3e212017-05-24 17:07:25 -0700189
You Wangdb927a52016-02-26 11:03:28 -0800190 """
Jon Hall2bb3e212017-05-24 17:07:25 -0700191 Delete a host-to-host intent ( bidirectional )
You Wangdb927a52016-02-26 11:03:28 -0800192 """
193 def __init__( self ):
194 HostIntentEvent.__init__( self )
195 self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ]
Jon Hall2bb3e212017-05-24 17:07:25 -0700196 self.typeIndex = int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
You Wangdb927a52016-02-26 11:03:28 -0800197
198 def startHostIntentEvent( self ):
You Wang7a27f3a2016-07-05 10:12:27 -0700199 try:
Jon Hall2bb3e212017-05-24 17:07:25 -0700200 assert self.hostA is not None and self.hostB is not None
You Wang7a27f3a2016-07-05 10:12:27 -0700201 targetIntent = None
202 for intent in main.intents:
203 if not intent.type == 'INTENT_HOST':
204 continue
205 if intent.hostA == self.hostA and intent.hostB == self.hostB or\
Jon Hall2bb3e212017-05-24 17:07:25 -0700206 intent.hostB == self.hostA and intent.hostA == self.hostB:
You Wang7a27f3a2016-07-05 10:12:27 -0700207 targetIntent = intent
208 break
Jon Hall2bb3e212017-05-24 17:07:25 -0700209 if targetIntent is None:
You Wang7a27f3a2016-07-05 10:12:27 -0700210 main.log.warn( self.typeString + " - intent does not exist" )
211 return EventStates().FAIL
You Wang52163202016-07-14 16:37:15 -0700212 main.log.info( "Event recorded: {} {} {} {} {}".format( self.typeIndex, self.typeString, self.hostA.name, self.hostB.name, self.CLIIndex ) )
You Wang7a27f3a2016-07-05 10:12:27 -0700213 controller = main.controllers[ self.CLIIndex - 1 ]
214 with controller.CLILock:
215 result = controller.CLI.removeIntent( targetIntent.id, purge=True )
Jon Hall2bb3e212017-05-24 17:07:25 -0700216 if result is None or result == main.FALSE:
You Wang7a27f3a2016-07-05 10:12:27 -0700217 main.log.warn( self.typeString + " - delete host intent failed" )
218 return EventStates().FAIL
219 with main.variableLock:
You Wang56577c82016-07-12 10:49:23 -0700220 targetIntent.setWithdrawn()
You Wang7a27f3a2016-07-05 10:12:27 -0700221 main.intents.remove( targetIntent )
You Wang7a27f3a2016-07-05 10:12:27 -0700222 return EventStates().PASS
223 except Exception:
224 main.log.warn( "Caught exception, aborting event" )
225 return EventStates().ABORT
You Wangdb927a52016-02-26 11:03:28 -0800226
Jon Hall2bb3e212017-05-24 17:07:25 -0700227
You Wangdb927a52016-02-26 11:03:28 -0800228class PointIntentEvent( IntentEvent ):
Jon Hall2bb3e212017-05-24 17:07:25 -0700229
You Wangdb927a52016-02-26 11:03:28 -0800230 def __init__( self ):
231 IntentEvent.__init__( self )
232 self.deviceA = None
233 self.deviceB = None
234
235 def startPointIntentEvent( self ):
236 return EventStates().PASS
237
238 def startEvent( self, args ):
239 with self.eventLock:
You Wang52163202016-07-14 16:37:15 -0700240 #main.log.info( "%s - starting event" % ( self.typeString ) )
You Wangdb927a52016-02-26 11:03:28 -0800241 if self.typeIndex == EventType().APP_INTENT_POINT_ADD or self.typeIndex == EventType().APP_INTENT_POINT_DEL:
242 if len( args ) < 3:
243 main.log.warn( "%s - Not enough arguments: %s" % ( self.typeString, args ) )
244 return EventStates().ABORT
You Wang7a27f3a2016-07-05 10:12:27 -0700245 elif len( args ) > 4:
You Wangdb927a52016-02-26 11:03:28 -0800246 main.log.warn( "%s - Too many arguments: %s" % ( self.typeString, args ) )
247 return EventStates().ABORT
You Wang59dfeb62016-07-14 09:47:33 -0700248 try:
249 if args[ 0 ] == 'random' or args[ 1 ] == 'random':
250 if self.typeIndex == EventType().APP_INTENT_POINT_ADD:
251 hostPairRandom = self.getRandomHostPair( connected=False )
Jon Hall2bb3e212017-05-24 17:07:25 -0700252 if hostPairRandom is None:
You Wang59dfeb62016-07-14 09:47:33 -0700253 main.log.warn( "All host pairs are connected, aborting event" )
254 return EventStates().ABORT
255 self.deviceA = hostPairRandom[ 0 ].device
256 self.deviceB = hostPairRandom[ 1 ].device
257 elif self.typeIndex == EventType().APP_INTENT_POINT_DEL:
258 intent = self.getRandomIntentByType( 'INTENT_POINT' )
Jon Hall2bb3e212017-05-24 17:07:25 -0700259 if intent is None:
You Wang59dfeb62016-07-14 09:47:33 -0700260 main.log.warn( "No point intent for deletion, aborting event" )
261 return EventStates().ABORT
262 self.deviceA = intent.deviceA
263 self.deviceB = intent.deviceB
264 elif args[ 0 ] == args[ 1 ]:
265 main.log.warn( "%s - invalid argument: %s" % ( self.typeString, args[ 0 ], args[ 1 ] ) )
You Wangdb927a52016-02-26 11:03:28 -0800266 return EventStates().ABORT
You Wang7a27f3a2016-07-05 10:12:27 -0700267 else:
You Wang59dfeb62016-07-14 09:47:33 -0700268 for device in main.devices:
269 if device.name == args[ 0 ]:
270 self.deviceA = device
271 elif device.name == args[ 1 ]:
272 self.deviceB = device
Jon Hall2bb3e212017-05-24 17:07:25 -0700273 if self.deviceA is not None and self.deviceB is not None:
You Wang59dfeb62016-07-14 09:47:33 -0700274 break
Jon Hall2bb3e212017-05-24 17:07:25 -0700275 if self.deviceA is None:
You Wang59dfeb62016-07-14 09:47:33 -0700276 main.log.warn( "Device %s does not exist: " % ( args[ 0 ] ) )
277 return EventStates().ABORT
Jon Hall2bb3e212017-05-24 17:07:25 -0700278 if self.deviceB is None:
You Wang59dfeb62016-07-14 09:47:33 -0700279 main.log.warn( "Device %s does not exist: " % ( args[ 1 ] ) )
280 return EventStates().ABORT
281 index = int( args[ 2 ] )
282 if index < 1 or index > int( main.numCtrls ):
283 main.log.warn( "%s - invalid argument: %s" % ( self.typeString, index ) )
284 return EventStates().ABORT
285 if not main.controllers[ index - 1 ].isUp():
286 main.log.warn( self.typeString + " - invalid argument: onos %s is down" % ( controller.index ) )
287 return EventStates().ABORT
288 self.CLIIndex = index
289 if len( args ) == 4 and args[ 3 ] == 'bidirectional':
290 # Install point intents for both directions
291 resultA = self.startPointIntentEvent()
292 [ self.deviceA, self.deviceB ] = [ self.deviceB, self.deviceA ]
293 resultB = self.startPointIntentEvent()
294 if resultA == EventStates().PASS and resultB == EventStates().PASS:
295 return EventStates().PASS
296 else:
297 return EventStates().FAIL
298 else:
299 return self.startPointIntentEvent()
300 except Exception:
301 main.log.warn( "Caught exception, aborting event" )
302 return EventStates().ABORT
You Wangdb927a52016-02-26 11:03:28 -0800303
Jon Hall2bb3e212017-05-24 17:07:25 -0700304
You Wangdb927a52016-02-26 11:03:28 -0800305class AddPointIntent( PointIntentEvent ):
Jon Hall2bb3e212017-05-24 17:07:25 -0700306
You Wangdb927a52016-02-26 11:03:28 -0800307 """
308 Add a point-to-point intent
309 """
310 def __init__( self ):
311 PointIntentEvent.__init__( self )
312 self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ]
Jon Hall2bb3e212017-05-24 17:07:25 -0700313 self.typeIndex = int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
You Wangdb927a52016-02-26 11:03:28 -0800314
315 def startPointIntentEvent( self ):
You Wang7a27f3a2016-07-05 10:12:27 -0700316 try:
Jon Hall2bb3e212017-05-24 17:07:25 -0700317 assert self.deviceA is not None and self.deviceB is not None
You Wang7a27f3a2016-07-05 10:12:27 -0700318 controller = main.controllers[ self.CLIIndex - 1 ]
You Wang59dfeb62016-07-14 09:47:33 -0700319 # TODO: support multiple hosts under one device
You Wang7a27f3a2016-07-05 10:12:27 -0700320 # Check whether there already exists some intent for the device pair
321 # For now we should avoid installing overlapping intents
322 for intent in main.intents:
323 if not intent.type == 'INTENT_POINT':
324 continue
325 if intent.deviceA == self.deviceA and intent.deviceB == self.deviceB:
326 main.log.warn( self.typeString + " - find an exiting intent for the device pair, abort installation" )
327 return EventStates().ABORT
You Wang52163202016-07-14 16:37:15 -0700328 main.log.info( "Event recorded: {} {} {} {} {}".format( self.typeIndex, self.typeString, self.deviceA.name, self.deviceB.name, self.CLIIndex ) )
You Wang7a27f3a2016-07-05 10:12:27 -0700329 controller = main.controllers[ self.CLIIndex - 1 ]
330 with controller.CLILock:
You Wang7a27f3a2016-07-05 10:12:27 -0700331 srcMAC = ""
332 dstMAC = ""
333 if len( self.deviceA.hosts ) > 0:
334 srcMAC = self.deviceA.hosts[ 0 ].mac
335 if len( self.deviceB.hosts ) > 0:
336 dstMAC = self.deviceB.hosts[ 0 ].mac
You Wang59dfeb62016-07-14 09:47:33 -0700337 id = controller.CLI.addPointIntent( self.deviceA.dpid, self.deviceB.dpid, 1, 1, '', srcMAC, dstMAC )
Jon Hall2bb3e212017-05-24 17:07:25 -0700338 if id is None:
You Wang7a27f3a2016-07-05 10:12:27 -0700339 main.log.warn( self.typeString + " - add point intent failed" )
340 return EventStates().FAIL
341 with main.variableLock:
342 newPointIntent = PointIntent( id, self.deviceA, self.deviceB )
343 if self.deviceA.isDown() or self.deviceB.isDown() or self.deviceA.isRemoved() or self.deviceB.isRemoved():
344 newPointIntent.setFailed()
You Wang56577c82016-07-12 10:49:23 -0700345 else:
346 newPointIntent.setInstalled()
You Wang7a27f3a2016-07-05 10:12:27 -0700347 main.intents.append( newPointIntent )
You Wang7a27f3a2016-07-05 10:12:27 -0700348 return EventStates().PASS
349 except Exception:
350 main.log.warn( "Caught exception, aborting event" )
351 return EventStates().ABORT
You Wangdb927a52016-02-26 11:03:28 -0800352
Jon Hall2bb3e212017-05-24 17:07:25 -0700353
You Wangdb927a52016-02-26 11:03:28 -0800354class DelPointIntent( PointIntentEvent ):
Jon Hall2bb3e212017-05-24 17:07:25 -0700355
You Wangdb927a52016-02-26 11:03:28 -0800356 """
357 Delete a point-to-point intent
358 """
359 def __init__( self ):
360 PointIntentEvent.__init__( self )
361 self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ]
Jon Hall2bb3e212017-05-24 17:07:25 -0700362 self.typeIndex = int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
You Wangdb927a52016-02-26 11:03:28 -0800363
364 def startPointIntentEvent( self ):
You Wang7a27f3a2016-07-05 10:12:27 -0700365 try:
Jon Hall2bb3e212017-05-24 17:07:25 -0700366 assert self.deviceA is not None and self.deviceB is not None
You Wang7a27f3a2016-07-05 10:12:27 -0700367 targetIntent = None
368 for intent in main.intents:
369 if not intent.type == 'INTENT_POINT':
370 continue
371 if intent.deviceA == self.deviceA and intent.deviceB == self.deviceB:
372 targetIntent = intent
373 break
Jon Hall2bb3e212017-05-24 17:07:25 -0700374 if targetIntent is None:
You Wang7a27f3a2016-07-05 10:12:27 -0700375 main.log.warn( self.typeString + " - intent does not exist" )
376 return EventStates().FAIL
You Wang52163202016-07-14 16:37:15 -0700377 main.log.info( "Event recorded: {} {} {} {} {}".format( self.typeIndex, self.typeString, self.deviceA.name, self.deviceB.name, self.CLIIndex ) )
You Wang7a27f3a2016-07-05 10:12:27 -0700378 controller = main.controllers[ self.CLIIndex - 1 ]
379 with controller.CLILock:
380 result = controller.CLI.removeIntent( targetIntent.id, purge=True )
Jon Hall2bb3e212017-05-24 17:07:25 -0700381 if result is None or result == main.FALSE:
You Wang7a27f3a2016-07-05 10:12:27 -0700382 main.log.warn( self.typeString + " - delete point intent failed" )
383 return EventStates().FAIL
384 with main.variableLock:
You Wang56577c82016-07-12 10:49:23 -0700385 targetIntent.setWithdrawn()
You Wang7a27f3a2016-07-05 10:12:27 -0700386 main.intents.remove( targetIntent )
You Wang7a27f3a2016-07-05 10:12:27 -0700387 return EventStates().PASS
388 except Exception:
389 main.log.warn( "Caught exception, aborting event" )
390 return EventStates().ABORT