blob: 64caed1f8a86def03fffcefcf81637c1afdcc069 [file] [log] [blame]
Rich Lane5ec97b82013-01-06 18:04:25 -08001
2# Python OpenFlow bucket wrapper class
3
4from cstruct import ofp_bucket
5from action_list import action_list
6
7
8
9class 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