blob: 5dc0bcd079b319e56633a8b3863cc37b67eca4c3 [file] [log] [blame]
Jon Hall602d0a72017-05-24 16:06:53 -07001def addBucket( main, egressPort="" ):
2 """
3 Description:
4 Create a single bucket which can be added to a Group.
5 Optional:
6 * egressPort: port of egress device
7 Returns:
8 * Returns a Bucket
9 * Returns None in case of error
10 Note:
11 The ip and port option are for the requests input's ip and port
12 of the ONOS node.
13 """
14 try:
kavitha Alagesan373e0552016-11-22 05:22:05 +053015
Jon Hall602d0a72017-05-24 16:06:53 -070016 bucket = {
17 "treatment": { "instructions": [] }
18 }
19 if egressPort:
20 bucket[ 'treatment' ][ 'instructions' ].append( {
21 "type": "OUTPUT",
22 "port": egressPort } )
23 return bucket
kavitha Alagesan373e0552016-11-22 05:22:05 +053024
Jon Hall602d0a72017-05-24 16:06:53 -070025 except ( AttributeError, TypeError ):
26 main.log.exception( self.name + ": Object not as expected" )
27 return None
28 except Exception:
29 main.log.exception( self.name + ": Uncaught exception!" )
30 main.cleanup()
31 main.exit()