Code Duplication    Length = 20-28 lines in 3 locations

pyof/v0x04/controller2switch/group_mod.py 1 location

@@ 65-92 (lines=28) @@
62
        """
63
        super().__init__(pyof_class=Bucket, items=items)
64
65
66
class GroupMod(GenericMessage):
67
    """Group setup and teardown (controller -> datapath)."""
68
69
    header = Header(message_type=Type.OFPT_GROUP_MOD)
70
    command = UBInt16(enum_ref=GroupModCommand)
71
    group_type = UBInt8()
72
    #: Pad to 64 bits.
73
    pad = Pad(1)
74
    group_id = UBInt32()
75
    buckets = ListOfBuckets()
76
77
    def __init__(self, xid=None, command=None, group_type=None, group_id=None,
78
                 buckets=None):
79
        """Create a GroupMod with the optional parameters below.
80
81
        Args:
82
            xid (int): Header's transaction id. Defaults to random.
83
            command (GroupModCommand): One of OFPGC_*.
84
            group_type (GroupType): One of OFPGT_*.
85
            group_id (int): Group identifier.
86
            buckets (:class:`ListOfBuckets`): The length of the bucket
87
                array is inferred from the length field in the header.
88
        """
89
        super().__init__(xid)
90
        self.command = command
91
        self.group_type = group_type
92
        self.group_id = group_id
93
        self.buckets = buckets
94

pyof/v0x04/controller2switch/multipart_reply.py 1 location

@@ 403-427 (lines=25) @@
400
        Args:
401
            port_no (:class:`int`, :class:`~pyof.v0x04.common.port.Port`):
402
                Port Number.
403
            queue_id (int): Queue ID.
404
            tx_bytes (int): Number of transmitted bytes.
405
            tx_packets (int): Number of transmitted packets.
406
            tx_errors (int): Number of packets dropped due to overrun.
407
            duration_sec (int): Time queue has been alive in seconds.
408
            duration_nsec (int): Time queue has been alive in nanoseconds
409
                beyond duration_sec.
410
        """
411
        super().__init__()
412
        self.port_no = port_no
413
        self.queue_id = queue_id
414
        self.tx_bytes = tx_bytes
415
        self.tx_packets = tx_packets
416
        self.tx_errors = tx_errors
417
        self.duration_sec = duration_sec
418
        self.duration_nsec = duration_nsec
419
420
421
class GroupDescStats(GenericStruct):
422
    """Body of reply to OFPMP_GROUP_DESC request."""
423
424
    length = UBInt16()
425
    group_type = UBInt8()
426
    #: Pad to 64 bits.
427
    pad = Pad(1)
428
    group_id = UBInt32()
429
    buckets = FixedTypeList(Bucket)
430

pyof/v0x01/common/header.py 1 location

@@ 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
        """Create a Header with 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