def test_sfc(self): initial_packet = self._get_bytes( self._gen_ethernet() / self._gen_ipv4(proto=inet.IPPROTO_UDP) / self._gen_udp(src_port=SRC_PORT, dst_port=DST_PORT) / ('0' * 64)) final_packet = self._get_bytes( self._gen_ethernet() / self._gen_ipv4(proto=inet.IPPROTO_UDP) / self._gen_udp(src_port=SRC_PORT, dst_port=DST_PORT) / ('{len}'.format(len=len(self.layout)) * 64)) fc = self.store( objects.FlowClassifierTestObj(self.neutron, self.nb_api), ) fc.create({'logical_source_port': self.src_port.port.port_id}, ) pc = self._create_pc(fc, self.layout) time.sleep(_QUICK_RESOURCE_READY_TIMEOUT) dst_key = (self.subnet.subnet_id, self.dst_port.port_id) port_policies = { dst_key: app_testing_objects.PortPolicy( rules=[ app_testing_objects.PortPolicyRule( app_testing_objects.ExactMatchFilter(final_packet), actions=[app_testing_objects.StopSimulationAction()], ), ], default_action=app_testing_objects.IgnoreAction(), ), } port_policies.update(self._create_port_policies(pc)) policy = self.store( app_testing_objects.Policy( initial_actions=[ app_testing_objects.SendAction( self.subnet.subnet_id, self.src_port.port_id, initial_packet, ), ], port_policies=port_policies, unknown_port_action=app_testing_objects.LogAction()), ) policy.start(self.topology) policy.wait(10) if policy.exceptions: raise policy.exceptions[0]
def test_fc(self): fc = self.store( objects.FlowClassifierTestObj(self.neutron, self.nb_api), ) fc.create(self._fc_params) pc = self._create_pc(fc, [1]) time.sleep(_QUICK_RESOURCE_READY_TIMEOUT) dst_key = (self.subnet.subnet_id, self.dst_port.port_id) port_policies = { dst_key: app_testing_objects.PortPolicy( rules=[ app_testing_objects.PortPolicyRule( app_testing_objects.ExactMatchFilter( self._final_packet, ), actions=[app_testing_objects.StopSimulationAction()], ), ], default_action=app_testing_objects.IgnoreAction(), ), } port_policies.update(self._create_port_policies(pc)) policy = self.store( app_testing_objects.Policy( initial_actions=[ app_testing_objects.SendAction( self.subnet.subnet_id, self.src_port.port_id, self._initial_packet, ), ], port_policies=port_policies, unknown_port_action=app_testing_objects.LogAction()), ) policy.start(self.topology) policy.wait(10) if policy.exceptions: raise policy.exceptions[0]