예제 #1
0
파일: fc.py 프로젝트: snapiri/dragonflow
 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'),
         ),
     )
예제 #2
0
 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',
         ), )
예제 #3
0
 def test_flow_classifier_no_ports(self):
     with testtools.ExpectedException(errors.ValidationError):
         sfc.FlowClassifier(
             id='id1',
             topic='topic',
             unique_key=1,
         ).validate()
예제 #4
0
    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'],
            ), )
예제 #5
0
 def test_flow_classifier_dest_port(self):
     # Check no exception raised
     sfc.FlowClassifier(
         id='id1',
         topic='topic',
         unique_key=1,
         dest_port='port1',
     ).validate()
예제 #6
0
    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'),
            ), )
예제 #7
0
 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',
         ), )
예제 #8
0
    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
            ))
예제 #9
0
    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',
예제 #10
0
    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,