Skip to content

Commit

Permalink
Merge pull request #104 from kytos-ng/fix/exp_from_of
Browse files Browse the repository at this point in the history
fix: release 2022.3.1: experimenter class deser shouldn't use old `pyof ActionExperimenter.body`
  • Loading branch information
viniarck authored Feb 24, 2023
2 parents cb3c8d1 + 612c58a commit 898872f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ All notable changes to the of_core NApp will be documented in this file.
[UNRELEASED] - Under development
********************************

[2022.3.1] - 2023-02-23
***********************

Fixed
=====

- ``from_of_instruction`` experimenter class deserialization shouldn't use ``pyof ActionExperimenter.body``

[2022.3.0] - 2022-12-15
***********************

Expand Down
2 changes: 1 addition & 1 deletion kytos.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"username": "kytos",
"name": "of_core",
"description": "OpenFlow Core of Kytos Controller, responsible for main OpenFlow operations.",
"version": "2022.3.0",
"version": "2022.3.1",
"napp_dependencies": [],
"license": "MIT",
"url": "https://github.com/kytos/of_core.git",
Expand Down
1 change: 0 additions & 1 deletion tests/unit/test_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,3 @@ def test_add_experimenter_classes():
experimenter, func = 0xff000002, lambda body: resp
Action04.add_experimenter_classes(experimenter, func)
assert Action04._experimenter_classes[experimenter] == func
assert Action04.get_experimenter_class(experimenter, b'\xff') == resp
14 changes: 2 additions & 12 deletions v0x04/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,6 @@ def add_experimenter_classes(
"""Add a callable that take bytes to map to Experimenter Actions."""
cls._experimenter_classes[int(experimenter)] = func

@classmethod
def get_experimenter_class(cls, experimenter: int, body: bytes):
"""Get Experimenter class."""
return cls._experimenter_classes[int(experimenter)](body)


class InstructionAction(InstructionBase):
"""Base class for instruction dealing with actions."""
Expand All @@ -238,13 +233,8 @@ def as_dict(self):
@classmethod
def from_of_instruction(cls, of_instruction):
"""Create high-level Instruction from pyof Instruction."""
actions = []
for of_action in of_instruction.actions:
klass = Action
if isinstance(of_action, ActionExperimenter):
klass = Action.get_experimenter_class(of_action.experimenter,
of_action.body.pack())
actions.append(klass.from_of_action(of_action))
actions = [Action.from_of_action(of_action)
for of_action in of_instruction.actions]
return cls(actions)

def as_of_instruction(self):
Expand Down

0 comments on commit 898872f

Please sign in to comment.