diff options
author | YAMAMOTO Takashi <yamamoto@valinux.co.jp> | 2014-01-28 11:31:09 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-01-28 11:04:14 +0900 |
commit | 053c9851b6db984c1a6e566f30679db29384d708 (patch) | |
tree | 0e7ed08fd586e068f387a31808751bb3a7c2b303 | |
parent | 8639905bb7398d5c478a387189a283b5ace4d8ec (diff) |
ofproto_v1_2_parser: put some assertions
Put some assertions to catch usage mistakes earlier.
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/ofproto/ofproto_v1_2_parser.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/ryu/ofproto/ofproto_v1_2_parser.py b/ryu/ofproto/ofproto_v1_2_parser.py index 39a4e305..3a413008 100644 --- a/ryu/ofproto/ofproto_v1_2_parser.py +++ b/ryu/ofproto/ofproto_v1_2_parser.py @@ -904,7 +904,10 @@ class OFPFlowMod(MsgBase): self.flags = flags if match is None: match = OFPMatch() + assert isinstance(match, OFPMatch) self.match = match + for i in instructions: + assert isinstance(i, OFPInstruction) self.instructions = instructions def _serialize_body(self): @@ -945,7 +948,7 @@ class OFPInstruction(StringifyMixin): @OFPInstruction.register_instruction_type([ofproto_v1_2.OFPIT_GOTO_TABLE]) -class OFPInstructionGotoTable(StringifyMixin): +class OFPInstructionGotoTable(OFPInstruction): """ Goto table instruction @@ -976,7 +979,7 @@ class OFPInstructionGotoTable(StringifyMixin): @OFPInstruction.register_instruction_type([ofproto_v1_2.OFPIT_WRITE_METADATA]) -class OFPInstructionWriteMetadata(StringifyMixin): +class OFPInstructionWriteMetadata(OFPInstruction): """ Write metadata instruction @@ -1012,7 +1015,7 @@ class OFPInstructionWriteMetadata(StringifyMixin): @OFPInstruction.register_instruction_type([ofproto_v1_2.OFPIT_WRITE_ACTIONS, ofproto_v1_2.OFPIT_APPLY_ACTIONS, ofproto_v1_2.OFPIT_CLEAR_ACTIONS]) -class OFPInstructionActions(StringifyMixin): +class OFPInstructionActions(OFPInstruction): """ Actions instruction @@ -1033,6 +1036,8 @@ class OFPInstructionActions(StringifyMixin): def __init__(self, type_, actions=None, len_=None): super(OFPInstructionActions, self).__init__() self.type = type_ + for a in actions: + assert isinstance(a, OFPAction) self.actions = actions @classmethod |