@@ 65-92 (lines=28) @@ | ||
62 | super().__init__(pyof_class=Bucket, items=items) |
|
63 | ||
64 | ||
65 | class GroupMod(GenericMessage): |
|
66 | """Group setup and teardown (controller -> datapath).""" |
|
67 | ||
68 | header = Header(message_type=Type.OFPT_GROUP_MOD) |
|
69 | command = UBInt16(enum_ref=GroupModCommand) |
|
70 | group_type = UBInt8() |
|
71 | #: Pad to 64 bits. |
|
72 | pad = Pad(1) |
|
73 | group_id = UBInt32() |
|
74 | buckets = ListOfBuckets() |
|
75 | ||
76 | def __init__(self, xid=None, command=None, group_type=None, group_id=None, |
|
77 | buckets=None): |
|
78 | """Initialize all instance variables. |
|
79 | ||
80 | Args: |
|
81 | xid (int): Header's transaction id. Defaults to random. |
|
82 | command (GroupModCommand): One of OFPGC_*. |
|
83 | group_type (GroupType): One of OFPGT_*. |
|
84 | group_id (int): Group identifier. |
|
85 | buckets (:class:`ListOfBuckets`): The length of the bucket |
|
86 | array is inferred from the length field in the header. |
|
87 | """ |
|
88 | super().__init__(xid) |
|
89 | self.command = command |
|
90 | self.group_type = group_type |
|
91 | self.group_id = group_id |
|
92 | self.buckets = buckets |
|
93 |
@@ 403-427 (lines=25) @@ | ||
400 | self.tx_errors = tx_errors |
|
401 | self.duration_sec = duration_sec |
|
402 | self.duration_nsec = duration_nsec |
|
403 | ||
404 | ||
405 | class GroupDescStats(GenericStruct): |
|
406 | """Body of reply to OFPMP_GROUP_DESC request.""" |
|
407 | ||
408 | length = UBInt16() |
|
409 | group_type = UBInt8() |
|
410 | #: Pad to 64 bits. |
|
411 | pad = Pad(1) |
|
412 | group_id = UBInt32() |
|
413 | buckets = FixedTypeList(Bucket) |
|
414 | ||
415 | def __init__(self, length=None, group_type=None, group_id=None, |
|
416 | buckets=None): |
|
417 | """The constructor just assigns parameters to object attributes. |
|
418 | ||
419 | Args: |
|
420 | length: Length of this entry. |
|
421 | group_type: One of OFPGT_*. |
|
422 | group_id: Group identifier. |
|
423 | buckets: List of buckets in group. |
|
424 | """ |
|
425 | super().__init__() |
|
426 | self.length = length |
|
427 | self.group_type = group_type |
|
428 | self.group_id = group_id |
|
429 | self.buckets = buckets |
|
430 |
@@ 68-87 (lines=20) @@ | ||
65 | # Classes |
|
66 | ||
67 | ||
68 | class Header(GenericStruct): |
|
69 | """Representation of an OpenFlow message Header.""" |
|
70 | ||
71 | version = UBInt8(OFP_VERSION) |
|
72 | message_type = UBInt8(enum_ref=Type) |
|
73 | length = UBInt16() |
|
74 | xid = UBInt32() |
|
75 | ||
76 | def __init__(self, message_type=None, length=None, xid=None): |
|
77 | """The constructor takes the optional parameters below. |
|
78 | ||
79 | Args: |
|
80 | message_type (~pyof.v0x01.common.header.Type): Type of the message. |
|
81 | xid (int): ID of the message. Defaults to a random integer. |
|
82 | length (int): Length of the message, including the header itself. |
|
83 | """ |
|
84 | super().__init__() |
|
85 | self.message_type = message_type |
|
86 | self.length = length |
|
87 | self.xid = randint(0, MAXID) if xid is None else xid |
|
88 |