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