Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 1 | def 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 Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 15 | |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 16 | bucket = { |
| 17 | "treatment": { "instructions": [] } |
| 18 | } |
| 19 | if egressPort: |
| 20 | bucket[ 'treatment' ][ 'instructions' ].append( { |
| 21 | "type": "OUTPUT", |
| 22 | "port": egressPort } ) |
| 23 | return bucket |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 24 | |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 25 | 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() |