def _flow_classifiers_by_lport(self, lport): return itertools.chain( self.db_store.get_all( sfc.FlowClassifier(source_port=lport), index=sfc.FlowClassifier.get_index('source_port'), ), self.db_store.get_all( sfc.FlowClassifier(dest_port=lport), index=sfc.FlowClassifier.get_index('dest_port'), ), )
def test_create_flow_classifier_postcommit(self): self.driver.create_flow_classifier_postcommit( self._get_fc_ctx( id='id1', project_id='id2', name='name', ethertype=constants.IPv4, source_ip_prefix='1.1.1.0/24', destination_ip_prefix='2.2.2.0/24', protocol=constants.PROTO_NAME_TCP, source_port_range_min=1111, source_port_range_max=2222, destination_port_range_min=3333, destination_port_range_max=4444, logical_source_port='port1', logical_destination_port='port2', ), ) self.driver.nb_api.create.assert_called_once_with( sfc.FlowClassifier( id='id1', topic='id2', name='name', ether_type=constants.IPv4, source_cidr='1.1.1.0/24', dest_cidr='2.2.2.0/24', protocol=constants.PROTO_NAME_TCP, source_transport_ports=[1111, 2222], dest_transport_ports=[3333, 4444], source_port='port1', dest_port='port2', ), )
def test_flow_classifier_no_ports(self): with testtools.ExpectedException(errors.ValidationError): sfc.FlowClassifier( id='id1', topic='topic', unique_key=1, ).validate()
def delete_flow_classifier_postcommit(self, context): flow_classifier = context.current self.nb_api.delete( sfc.FlowClassifier( id=flow_classifier['id'], topic=flow_classifier['project_id'], ), )
def test_flow_classifier_dest_port(self): # Check no exception raised sfc.FlowClassifier( id='id1', topic='topic', unique_key=1, dest_port='port1', ).validate()
def update_flow_classifier_postcommit(self, context): flow_classifier = context.current # Only name can be updated (and description which we ignore) self.nb_api.update( sfc.FlowClassifier( id=flow_classifier['id'], topic=flow_classifier['project_id'], name=flow_classifier.get('name'), ), )
def test_delete_flow_classifier_postcommit(self): self.driver.delete_flow_classifier_postcommit( self._get_fc_ctx( id='id1', project_id='id2', ), ) self.driver.nb_api.delete.assert_called_once_with( sfc.FlowClassifier( id='id1', topic='id2', ), )
def create_flow_classifier_postcommit(self, context): flow_classifier = context.current self.nb_api.create( sfc.FlowClassifier( id=flow_classifier['id'], topic=flow_classifier['project_id'], name=flow_classifier.get('name'), ether_type=flow_classifier.get('ethertype'), protocol=flow_classifier.get('protocol'), source_cidr=flow_classifier.get('source_ip_prefix'), dest_cidr=flow_classifier.get('destination_ip_prefix'), source_transport_ports=field_types.PortRange.from_min_max( flow_classifier.get('source_port_range_min'), flow_classifier.get('source_port_range_max'), ), dest_transport_ports=field_types.PortRange.from_min_max( flow_classifier.get('destination_port_range_min'), flow_classifier.get('destination_port_range_max'), ), source_port=flow_classifier.get('logical_source_port'), dest_port=flow_classifier.get('logical_destination_port'), # FIXME (dimak) add support for l7_parameters ))
lswitch='lswitch1', binding=test_app_base.local_binding, ) lport3 = l2.LogicalPort( id='lport3', topic='topic1', version=10, unique_key=29, lswitch='lswitch1', binding=test_app_base.local_binding, ) fc1 = sfc.FlowClassifier( id='fc1', topic='topic1', unique_key=22, source_port='lport1', ) fc2 = sfc.FlowClassifier( id='fc2', topic='topic1', unique_key=12, dest_port='lport2', ) fc3 = sfc.FlowClassifier( id='fc3', topic='topic1', unique_key=13, source_port='lport3',
lswitch='lswitch1', binding=test_app_base.local_binding, ) fc2lport = l2.LogicalPort( id='lport2', topic='topic1', version=10, unique_key=23, lswitch='lswitch1', binding=test_app_base.local_binding, ) fc1 = sfc.FlowClassifier( id='fc1', topic='topic1', unique_key=22, source_port='lport1', ) fc2 = sfc.FlowClassifier( id='fc2', topic='topic1', unique_key=23, dest_port='lport2', ) pp11ingress = l2.LogicalPort( id='pp11ingress', topic='topic1', version=10, unique_key=23,