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

FlowRemovedReason

Complexity

Total Complexity 0

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 0
dl 0
loc 11
ccs 0
cts 5
cp 0
c 0
b 0
f 0
1
"""The controller has requested to be notified when flows time out."""
2
# System imports
3
from enum import IntEnum
4
5
from pyof.foundation.base import GenericMessage
6
from pyof.foundation.basic_types import UBInt8, UBInt16, UBInt32, UBInt64
7
# Local source tree imports
8
from pyof.v0x04.common.flow_match import Match
9
from pyof.v0x04.common.header import Header, Type
10
11
__all__ = ('FlowRemoved', 'FlowRemovedReason')
12
13
# Enums
14
15
16
class FlowRemovedReason(IntEnum):
17
    """Why the flow was removed."""
18
19
    #: Flow idle time exceeded idle_timeout
20
    OFPRR_IDLE_TIMEOUT = 0
21
    #: Time exceeded hard_timeout
22
    OFPRR_HARD_TIMEOUT = 1
23
    #: Evicted by a DELETE flow mod
24
    OFPRR_DELETE = 2
25
    #: Group was removed.
26
    OFPRR_GROUP_DELETE = 3
27
28
29
# Classes
30 View Code Duplication
class FlowRemoved(GenericMessage):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
31
    """Flow removed (datapath -> controller).
32
33
    If the controller has requested to be notified when flow entries time out
34
    or are deleted from tables, the datapath does this with the
35
    OFPT_FLOW_REMOVED message.
36
    """
37
38
    #: :class:`~pyof.v0x04.common.header.Header`: OpenFlow Header
39
    header = Header(message_type=Type.OFPT_FLOW_REMOVED)
40
    #: Opaque controller-issued identifier.
41
    cookie = UBInt64()
42
    #: Priority level of flow entry.
43
    priority = UBInt16()
44
    #: One of OFPRR_*.
45
    reason = UBInt8(enum_ref=FlowRemovedReason)
46
    #: ID of the table
47
    table_id = UBInt8()
48
    #: Time flow was alive in seconds.
49
    duration_sec = UBInt32()
50
    #: Time flow was alive in nanoseconds beyond duration_sec.
51
    duration_nsec = UBInt32()
52
    #: Idle timeout from original flow mod.
53
    idle_timeout = UBInt16()
54
    #: Hard timeout from original flow mod.
55
    hard_timeout = UBInt16()
56
    packet_count = UBInt64()
57
    byte_count = UBInt64()
58
    #: Description of fields. Variable size.
59
    #: :class:`~pyof.v0x04.common.flow_match.Match`
60
    match = Match()
61
62
    def __init__(self, xid=None, cookie=None, priority=None, reason=None,
63
                 table_id=None, duration_sec=None, duration_nsec=None,
64
                 idle_timeout=None, hard_timeout=None, packet_count=None,
65
                 byte_count=None, match=None):
66
        """Assign parameters to object attributes.
67
68
        Args:
69
            xid (int): OpenFlow Header's xid.
70
            cookie (int): Opaque controller-issued identifier.
71
            priority (int): Priority level of flow entry.
72
            reason (~pyof.v0x04.asynchronous.flow_removed.FlowRemovedReason):
73
                Why the flow was removed.
74
            table_id (int): ID of the table.
75
            duration_sec (int): Time the flow was alive in seconds.
76
            duration_nsec (int): Time the flow was alive in nanoseconds in
77
                addition to duration_sec.
78
            idle_timeout (int): Idle timeout from original flow mod.
79
            hard_timeout (int): Hard timeout from original flow mod.
80
            packet_count (int): Number of packets.
81
            byte_count (int): Byte count.
82
            match (~pyof.v0x04.common.flow_match.Match): Fields' description.
83
        """
84
        super().__init__(xid)
85
        self.cookie = cookie
86
        self.priority = priority
87
        self.reason = reason
88
        self.table_id = table_id
89
        self.duration_sec = duration_sec
90
        self.duration_nsec = duration_nsec
91
        self.idle_timeout = idle_timeout
92
        self.hard_timeout = hard_timeout
93
        self.packet_count = packet_count
94
        self.byte_count = byte_count
95
        self.match = match
96