Test Failed
Pull Request — master (#505)
by macartur
01:31
created

PortReason

Complexity

Total Complexity 0

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 0
dl 0
loc 9
ccs 0
cts 4
cp 0
c 0
b 0
f 0
1
"""Defines an PortStatus Message."""
2
# System imports
3
from enum import IntEnum
4
5
# Local source tree imports
6
from pyof.foundation.base import GenericMessage
7
from pyof.foundation.basic_types import Pad, UBInt8
8
from pyof.v0x04.common.header import Header, Type
9
from pyof.v0x04.common.port import Port
10
11
# Third-party imports
12
13
__all__ = ('PortStatus', 'PortReason')
14
15
# Enums
16
17
18
class PortReason(IntEnum):
19
    """What changed about the physical port."""
20
21
    #: The port was added
22
    OFPPR_ADD = 0
23
    #: The port was removed
24
    OFPPR_DELETE = 1
25
    #: Some attribute of the port has changed
26
    OFPPR_MODIFY = 2
27
28
29
# Classes
30
31
class PortStatus(GenericMessage):
32
    """A physical port has changed in the datapath."""
33
34
    #: :class:`~pyof.v0x04.common.action.ActionHeader`: OpenFlow Header
35
    header = Header(message_type=Type.OFPT_PORT_STATUS)
36
    #: One of OFPPR_*.
37
    reason = UBInt8(enum_ref=PortReason)
38
    #: Align to 32-bits.
39
    pad = Pad(7)
40
    #: :class:`~pyof.v0x04.common.port.Port`
41
    desc = Port()
42
43
    def __init__(self, xid=None, reason=None, desc=None):
44
        """Assign parameters to object attributes.
45
46
        Args:
47
            xid (int): Header's xid.
48
            reason (~pyof.v0x04.asynchronous.port_status.PortReason):
49
                Addition, deletion or modification.
50
            desc (~pyof.v0x04.common.port.Port): Port description.
51
        """
52
        super().__init__(xid)
53
        self.reason = reason
54
        self.desc = desc
55