Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 1 | |
| 2 | # Python OpenFlow bucket wrapper class |
| 3 | |
| 4 | from cstruct import ofp_bucket |
| 5 | from action_list import action_list |
| 6 | |
| 7 | |
| 8 | |
| 9 | class bucket(ofp_bucket): |
| 10 | """ |
| 11 | Wrapper class for bucket object |
| 12 | |
| 13 | Data members inherited from ofp_bucket: |
| 14 | @arg len |
| 15 | @arg weight |
| 16 | @arg watch_port |
| 17 | @arg watch_group |
| 18 | |
| 19 | """ |
| 20 | def __init__(self): |
| 21 | ofp_bucket.__init__(self) |
| 22 | self.actions = action_list() |
| 23 | self.type = None |
| 24 | self.len = self.__len__() |
| 25 | def show(self, prefix=''): |
| 26 | outstr = prefix + "bucket\n" |
| 27 | outstr += ofp_bucket.show(self, prefix) |
| 28 | outstr += self.actions.show() |
| 29 | return outstr |
| 30 | def unpack(self, binary_string): |
| 31 | binary_string = ofp_bucket.unpack(self, binary_string) |
| 32 | self.actions = action_list() |
| 33 | return self.actions.unpack(binary_string) |
| 34 | def pack(self): |
| 35 | self.len = len(self) |
| 36 | packed = "" |
| 37 | packed += ofp_bucket.pack(self) |
| 38 | packed += self.actions.pack() |
| 39 | return packed |
| 40 | def __len__(self): |
| 41 | return ofp_bucket.__len__(self) + self.actions.__len__() |
| 42 | |