def test_of_flow_mod(self): """Test convertion from Flow to OFFlow.""" flow_mod_01 = Flow01.from_dict(self.EXPECTED, self.SWITCH) flow_mod_04 = Flow04.from_dict(self.EXPECTED, self.SWITCH) of_flow_mod_01 = flow_mod_01.as_of_add_flow_mod() of_flow_mod_04 = flow_mod_04.as_of_delete_flow_mod() self.assertIsInstance(of_flow_mod_01, OFFlow01) self.assertIsInstance(of_flow_mod_04, OFFlow04)
def _handle_multipart_flow_stats(self, reply, switch): """Update switch flows after all replies are received.""" if self._is_multipart_reply_ours(reply, switch): # Get all flows from the reply flows = [Flow04.from_of_flow_stats(of_flow_stats, switch) for of_flow_stats in reply.body] # Get existent flows from the same xid (or create an empty list) all_flows = self._multipart_replies_flows.setdefault(switch.id, []) all_flows.extend(flows) if reply.flags.value % 2 == 0: # Last bit means more replies self._update_switch_flows(switch)
def test_flow_mod_goto(self, *args): """Convert a dict to flow and vice-versa.""" (mock_json, _, _) = args dpid = "00:00:00:00:00:00:00:01" mock_json.return_value = str(self.requested_instructions) mock_switch = get_switch_mock(dpid, 0x04) mock_switch.id = dpid flow = Flow04.from_dict(self.requested_instructions, mock_switch) actual = flow.as_dict() del actual['id'] del actual['stats'] self.assertDictEqual(self.requested_instructions, actual)
def _handle_multipart_flow_stats(self, reply, switch): """Update switch flows after all replies are received.""" if self._is_multipart_reply_ours(reply, switch, 'flows'): # Get all flows from the reply flows = [ Flow04.from_of_flow_stats(of_flow_stats, switch) for of_flow_stats in reply.body ] # Get existent flows from the same xid (or create an empty list) all_flows = self._multipart_replies_flows.setdefault(switch.id, []) all_flows.extend(flows) if reply.flags.value % 2 == 0: # Last bit means more replies self._update_switch_flows(switch) event_raw = KytosEvent( name='kytos/of_core.flow_stats.received', content={'switch': switch}) self.controller.buffers.app.put(event_raw)