Skip to content
This repository was archived by the owner on Apr 22, 2024. It is now read-only.

Commit ba8a9e4

Browse files
committed
Change MultipartTypes to singular
Change it to match the project defaults. Fix #468
1 parent 3ed6d67 commit ba8a9e4

5 files changed

Lines changed: 42 additions & 42 deletions

File tree

pyof/v0x04/controller2switch/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from pyof.v0x04.controller2switch.table_mod import Table
2020

2121
__all__ = ('ConfigFlags', 'ControllerRole', 'Bucket', 'BucketCounter',
22-
'ExperimenterMultipartHeader', 'MultipartTypes',
22+
'ExperimenterMultipartHeader', 'MultipartType',
2323
'TableFeaturePropType', 'Property', 'InstructionsProperty',
2424
'NextTablesProperty', 'ActionsProperty', 'OxmProperty',
2525
'ListOfProperty', 'TableFeatures')
@@ -104,7 +104,7 @@ def find_class(self):
104104
return OxmProperty
105105

106106

107-
class MultipartTypes(IntEnum):
107+
class MultipartType(IntEnum):
108108
"""Types of Multipart Messages, both Request and Reply."""
109109

110110
#: Description of this OpenFlow switch.

pyof/v0x04/controller2switch/multipart_reply.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from pyof.v0x04.common.header import Header, Type
1414
from pyof.v0x04.common.port import Port
1515
from pyof.v0x04.controller2switch.common import (
16-
Bucket, BucketCounter, ExperimenterMultipartHeader, MultipartTypes,
16+
Bucket, BucketCounter, ExperimenterMultipartHeader, MultipartType,
1717
TableFeatures)
1818
from pyof.v0x04.controller2switch.meter_mod import (
1919
ListOfMeterBandHeader, MeterBandType, MeterFlags)
@@ -62,7 +62,7 @@ class MultipartReply(GenericMessage):
6262
#: Openflow :class:`~pyof.v0x04.common.header.Header`
6363
header = Header(message_type=Type.OFPT_MULTIPART_REPLY)
6464
#: One of the OFPMP_* constants.
65-
multipart_type = UBInt16(enum_ref=MultipartTypes)
65+
multipart_type = UBInt16(enum_ref=MultipartType)
6666
#: OFPMPF_REPLY_* flags.
6767
flags = UBInt16()
6868
#: Padding
@@ -139,22 +139,22 @@ def _unpack_body(self):
139139
def _get_body_instance(self):
140140
"""Return the body instance."""
141141
exp_header = ExperimenterMultipartHeader
142-
simple_body = {MultipartTypes.OFPMP_DESC: Desc,
143-
MultipartTypes.OFPMP_GROUP_FEATURES: GroupFeatures,
144-
MultipartTypes.OFPMP_METER_FEATURES: MeterFeatures,
145-
MultipartTypes.OFPMP_EXPERIMENTER: exp_header}
146-
147-
array_of_bodies = {MultipartTypes.OFPMP_FLOW: FlowStats,
148-
MultipartTypes.OFPMP_AGGREGATE: AggregateStatsReply,
149-
MultipartTypes.OFPMP_TABLE: TableStats,
150-
MultipartTypes.OFPMP_PORT_STATS: PortStats,
151-
MultipartTypes.OFPMP_QUEUE: QueueStats,
152-
MultipartTypes.OFPMP_GROUP: GroupStats,
153-
MultipartTypes.OFPMP_GROUP_DESC: GroupDescStats,
154-
MultipartTypes.OFPMP_METER: MeterStats,
155-
MultipartTypes.OFPMP_METER_CONFIG: MeterConfig,
156-
MultipartTypes.OFPMP_TABLE_FEATURES: TableFeatures,
157-
MultipartTypes.OFPMP_PORT_DESC: Port}
142+
simple_body = {MultipartType.OFPMP_DESC: Desc,
143+
MultipartType.OFPMP_GROUP_FEATURES: GroupFeatures,
144+
MultipartType.OFPMP_METER_FEATURES: MeterFeatures,
145+
MultipartType.OFPMP_EXPERIMENTER: exp_header}
146+
147+
array_of_bodies = {MultipartType.OFPMP_FLOW: FlowStats,
148+
MultipartType.OFPMP_AGGREGATE: AggregateStatsReply,
149+
MultipartType.OFPMP_TABLE: TableStats,
150+
MultipartType.OFPMP_PORT_STATS: PortStats,
151+
MultipartType.OFPMP_QUEUE: QueueStats,
152+
MultipartType.OFPMP_GROUP: GroupStats,
153+
MultipartType.OFPMP_GROUP_DESC: GroupDescStats,
154+
MultipartType.OFPMP_METER: MeterStats,
155+
MultipartType.OFPMP_METER_CONFIG: MeterConfig,
156+
MultipartType.OFPMP_TABLE_FEATURES: TableFeatures,
157+
MultipartType.OFPMP_PORT_DESC: Port}
158158

159159
if isinstance(self.multipart_type, (int, UBInt16)):
160160
self.multipart_type = self.multipart_type.enum_ref(

pyof/v0x04/controller2switch/multipart_request.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from pyof.v0x04.common.header import Header, Type
1212
from pyof.v0x04.common.port import PortNo
1313
from pyof.v0x04.controller2switch.common import (
14-
ExperimenterMultipartHeader, MultipartTypes, TableFeatures)
14+
ExperimenterMultipartHeader, MultipartType, TableFeatures)
1515
from pyof.v0x04.controller2switch.group_mod import Group
1616
from pyof.v0x04.controller2switch.meter_mod import Meter
1717
from pyof.v0x04.controller2switch.table_mod import Table
@@ -46,7 +46,7 @@ class MultipartRequest(GenericMessage):
4646
#: Openflow :class:`~pyof.v0x04.common.header.Header`
4747
header = Header(message_type=Type.OFPT_MULTIPART_REQUEST)
4848
#: One of the OFPMP_* constants.
49-
multipart_type = UBInt16(enum_ref=MultipartTypes)
49+
multipart_type = UBInt16(enum_ref=MultipartType)
5050
#: OFPMPF_REQ_* flags.
5151
flags = UBInt16(enum_ref=MultipartRequestFlags)
5252
#: Padding
@@ -127,16 +127,16 @@ def _unpack_body(self):
127127
def _get_body_instance(self):
128128
"""Return the body instance."""
129129
simple_body = {
130-
MultipartTypes.OFPMP_FLOW: FlowStatsRequest,
131-
MultipartTypes.OFPMP_AGGREGATE: AggregateStatsRequest,
132-
MultipartTypes.OFPMP_PORT_STATS: PortStatsRequest,
133-
MultipartTypes.OFPMP_QUEUE: QueueStatsRequest,
134-
MultipartTypes.OFPMP_GROUP: GroupStatsRequest,
135-
MultipartTypes.OFPMP_METER: MeterMultipartRequest,
136-
MultipartTypes.OFPMP_EXPERIMENTER: ExperimenterMultipartHeader
130+
MultipartType.OFPMP_FLOW: FlowStatsRequest,
131+
MultipartType.OFPMP_AGGREGATE: AggregateStatsRequest,
132+
MultipartType.OFPMP_PORT_STATS: PortStatsRequest,
133+
MultipartType.OFPMP_QUEUE: QueueStatsRequest,
134+
MultipartType.OFPMP_GROUP: GroupStatsRequest,
135+
MultipartType.OFPMP_METER: MeterMultipartRequest,
136+
MultipartType.OFPMP_EXPERIMENTER: ExperimenterMultipartHeader
137137
}
138138

139-
array_of_bodies = {MultipartTypes.OFPMP_TABLE_FEATURES: TableFeatures}
139+
array_of_bodies = {MultipartType.OFPMP_TABLE_FEATURES: TableFeatures}
140140

141141
if isinstance(self.multipart_type, UBInt16):
142142
self.multipart_type = self.multipart_type.enum_ref(

tests/v0x04/test_controller2switch/test_multipart_reply.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""MultipartReply message test."""
22

3-
from pyof.v0x04.controller2switch.common import MultipartTypes
3+
from pyof.v0x04.controller2switch.common import MultipartType
44
from pyof.v0x04.controller2switch.multipart_reply import (
55
Desc, MultipartReply, MultipartReplyFlags)
66
from tests.v0x04.test_struct import TestStruct
@@ -14,13 +14,13 @@ def setUpClass(cls):
1414
"""Configure raw file and its object in parent class (TestDump)."""
1515
super().setUpClass()
1616
super().set_message(MultipartReply, xid=16,
17-
multipart_type=MultipartTypes.OFPMP_METER_CONFIG,
17+
multipart_type=MultipartType.OFPMP_METER_CONFIG,
1818
flags=MultipartReplyFlags.OFPMPF_REPLY_MORE,
1919
body=b'')
2020
super().set_minimum_size(16)
2121

2222
@staticmethod
23-
def get_attributes(multipart_type=MultipartTypes.OFPMP_DESC,
23+
def get_attributes(multipart_type=MultipartType.OFPMP_DESC,
2424
flags=MultipartReplyFlags.OFPMPF_REPLY_MORE,
2525
body=b''):
2626
"""Method used to return a dict with instance paramenters."""
@@ -35,5 +35,5 @@ def test_pack_unpack_desc(self):
3535
serial_num="SERIAL NUMBER",
3636
dp_desc="DATAPATH DESCRIPTION")
3737
options = TestMultipartReply.get_attributes(
38-
multipart_type=MultipartTypes.OFPMP_DESC, body=instances)
38+
multipart_type=MultipartType.OFPMP_DESC, body=instances)
3939
self._test_pack_unpack(**options)

tests/v0x04/test_controller2switch/test_multipart_request.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""MultipartRequest message test."""
22
from pyof.v0x04.controller2switch.multipart_request import (
3-
MultipartRequest, MultipartRequestFlags, MultipartTypes, PortStatsRequest,
3+
MultipartRequest, MultipartRequestFlags, MultipartType, PortStatsRequest,
44
TableFeatures)
55
from tests.v0x04.test_struct import TestStruct
66

@@ -14,13 +14,13 @@ def setUpClass(cls):
1414
super().setUpClass()
1515

1616
super().set_message(MultipartRequest, xid=16,
17-
multipart_type=MultipartTypes.OFPMP_TABLE_FEATURES,
17+
multipart_type=MultipartType.OFPMP_TABLE_FEATURES,
1818
flags=MultipartRequestFlags.OFPMPF_REQ_MORE,
1919
body=b'')
2020
super().set_minimum_size(16)
2121

2222
@staticmethod
23-
def get_attributes(multipart_type=MultipartTypes.OFPMP_DESC,
23+
def get_attributes(multipart_type=MultipartType.OFPMP_DESC,
2424
flags=MultipartRequestFlags.OFPMPF_REQ_MORE,
2525
body=b''):
2626
"""Method used to return a dict with instance paramenters."""
@@ -30,26 +30,26 @@ def get_attributes(multipart_type=MultipartTypes.OFPMP_DESC,
3030
def test_pack_unpack_desc(self):
3131
"""Testing multipart_type with OFPMP_DESC."""
3232
options = TestMultipartRequest.get_attributes(
33-
multipart_type=MultipartTypes.OFPMP_DESC)
33+
multipart_type=MultipartType.OFPMP_DESC)
3434
self._test_pack_unpack(**options)
3535

3636
def test_pack_unpack_table(self):
3737
"""Testing multipart_type with OFPMP_TABLE."""
3838
options = TestMultipartRequest.get_attributes(
39-
multipart_type=MultipartTypes.OFPMP_TABLE)
39+
multipart_type=MultipartType.OFPMP_TABLE)
4040
self._test_pack_unpack(**options)
4141

4242
def test_pack_unpack__port_stats_request(self):
4343
"""Testing multipart_type with OFPMP_PORT_STATS."""
4444
options = TestMultipartRequest.get_attributes(
45-
multipart_type=MultipartTypes.OFPMP_PORT_STATS,
45+
multipart_type=MultipartType.OFPMP_PORT_STATS,
4646
body=PortStatsRequest(port_no=33))
4747
self._test_pack_unpack(**options)
4848

4949
def test_pack_unpack_port_desc(self):
5050
"""Testing multipart_type with OFPMP_PORT_DESC."""
5151
options = TestMultipartRequest.get_attributes(
52-
multipart_type=MultipartTypes.OFPMP_PORT_DESC)
52+
multipart_type=MultipartType.OFPMP_PORT_DESC)
5353
self._test_pack_unpack(**options)
5454

5555
def test_pack_unpack_table_features(self):
@@ -58,6 +58,6 @@ def test_pack_unpack_table_features(self):
5858
TableFeatures(table_id=6),
5959
TableFeatures(table_id=4)]
6060
options = TestMultipartRequest.get_attributes(
61-
multipart_type=MultipartTypes.OFPMP_TABLE_FEATURES,
61+
multipart_type=MultipartType.OFPMP_TABLE_FEATURES,
6262
body=instance)
6363
self._test_pack_unpack(**options)

0 commit comments

Comments
 (0)