LOG = logging.getLogger(__name__)
UUID_LEN = 36
class L7Parameter(model_base.BASEV2):
class FlowClassifier(model_base.BASEV2, model_base.HasId,
                     model_base.HasProject):
class FlowClassifierDbPlugin(fc_ext.FlowClassifierPluginBase):
    def _check_port_range_valid(cls, port_range_min,
                                port_range_max,
                                protocol):
    def _check_ip_prefix_valid(cls, ip_prefix, ethertype):
    def _logical_port_conflict(cls, first_logical_port, second_logical_port):
    def _ip_prefix_conflict(cls, first_ip_prefix, second_ip_prefix):
    def _port_range_conflict(
        cls, first_port_range_min, first_port_range_max,
        second_port_range_min, second_port_range_max
    ):
    def _protocol_conflict(cls, first_protocol, second_protocol):
    def _ethertype_conflict(cls, first_ethertype, second_ethertype):
    def flowclassifier_basic_conflict(
        cls, first_flowclassifier, second_flowclassifier
    ):
    def flowclassifier_conflict(
        cls, first_flowclassifier, second_flowclassifier
    ):
    def create_flow_classifier(self, context, flow_classifier):
    def _make_flow_classifier_dict(self, flow_classifier, fields=None):
    def get_flow_classifiers(self, context, filters=None, fields=None,
                             sorts=None, limit=None, marker=None,
                             page_reverse=False):
    def get_flow_classifier(self, context, id, fields=None):
    def _get_flow_classifier(self, context, id):
    def _get_port(self, context, id):
    def update_flow_classifier(self, context, id, flow_classifier):
    def delete_flow_classifier(self, context, id): LOG = logging.getLogger(__name__)
UUID_LEN = 36
PARAM_LEN = 255
VAR_MAX_LEN = 1024
class ChainParameter(model_base.BASEV2):
class ServiceFunctionParam(model_base.BASEV2):
class PortPairGroupParam(model_base.BASEV2):
class ChainClassifierAssoc(model_base.BASEV2):
class PortPair(model_base.BASEV2, model_base.HasId, model_base.HasProject):
class ChainGroupAssoc(model_base.BASEV2):
class PortPairGroup(model_base.BASEV2, model_base.HasId,
                    model_base.HasProject):
class PortChain(model_base.BASEV2, model_base.HasId, model_base.HasProject):
class GraphChainAssoc(model_base.BASEV2):
class ServiceGraph(model_base.BASEV2, model_base.HasId, model_base.HasProject):
class SfcDbPlugin(
    ext_sfc.SfcPluginBase,
    ext_sg.ServiceGraphPluginBase
):
    def _make_port_chain_dict(self, port_chain, fields=None):
    def _validate_port_pair_groups(self, context, pg_ids, pc_id=None):
    def _validate_correlation_consistency(self, context, ppg_ids, pc_corr):
    def _validate_flow_classifiers(self, context, fc_ids, pc_id=None):
    def _setup_chain_group_associations(
        self, context, port_chain, pg_ids
    ):
    def _setup_chain_classifier_associations(
        self, context, port_chain, fc_ids
    ):
    def create_port_chain(self, context, port_chain):
    def get_port_chains(self, context, filters=None, fields=None,
                        sorts=None, limit=None,
                        marker=None, page_reverse=False, default_sg=False):
    def get_port_chains_count(self, context, filters=None):
    def get_port_chain(self, context, id, fields=None):
    def _get_port_chain(self, context, id):
    def delete_port_chain(self, context, id):
    def update_port_chain(self, context, id, port_chain):
    def _make_port_pair_dict(self, port_pair, fields=None):
    def _validate_port_pair_ingress_egress(self, ingress, egress):
    def create_port_pair(self, context, port_pair):
    def get_port_pairs(self, context, filters=None, fields=None,
                       sorts=None, limit=None, marker=None,
                       page_reverse=False):
    def get_port_pairs_count(self, context, filters=None):
    def get_port_pair(self, context, id, fields=None):
    def _get_port_pair(self, context, id):
    def _get_port(self, context, id):
    def update_port_pair(self, context, id, port_pair):
    def delete_port_pair(self, context, id):
    def _make_port_pair_group_dict(self, port_pair_group, fields=None):
    def _validate_pps_in_ppg(self, portpairs_list, id=None):
    def create_port_pair_group(self, context, port_pair_group):
    def get_port_pair_groups(self, context, filters=None, fields=None,
                             sorts=None, limit=None, marker=None,
                             page_reverse=False):
    def get_port_pair_groups_count(self, context, filters=None):
    def get_port_pair_group(self, context, id, fields=None):
    def _get_port_pair_group(self, context, id):
    def _get_flow_classifier(self, context, id):
    def update_port_pair_group(self, context, id, port_pair_group):
    def delete_port_pair_group(self, context, id):
    def _graph_assocs_to_pc_dict(self, assocs):
    def _make_service_graph_dict(self, graph_db, fields=None):
    def _make_graph_chain_assoc_dict(self, assoc_db, fields=None):
    def _is_there_a_loop(self, parenthood, current_chain, traversed):
    def _any_port_chains_in_a_graph(self, context,
                                    port_chains=set(), graph_id=None):
    def _validate_port_chains_for_graph(self, context,
                                        port_chains, graph_id=None):
    def _setup_graph_chain_associations(self, context, graph_db, port_chains):
    def _get_branches(self, context, filters):
    def create_service_graph(self, context, service_graph):
    def get_service_graphs(self, context, filters=None,
                           fields=None, sorts=None, limit=None,
                           marker=None, page_reverse=False):
    def get_service_graph(self, context, id, fields=None):
    def _get_service_graph(self, context, id):
    def update_service_graph(self, context, id, service_graph):
    def delete_service_graph(self, context, id): FLOW_CLASSIFIER_EXT = "flow_classifier"
FLOW_CLASSIFIER_PREFIX = "/sfc"
SUPPORTED_L7_PARAMETERS = {}
RESOURCE_ATTRIBUTE_MAP = {
    'flow_classifiers': {
        'id': {
            'allow_post': False, 'allow_put': False,
            'is_visible': True,
            'validate': {'type:uuid': None},
            'primary_key': True},
        'name': {
            'allow_post': True, 'allow_put': True,
            'is_visible': True, 'default': None,
            'validate': {'type:string': db_const.NAME_FIELD_SIZE},
            'convert_to': normalize_string},
        'description': {
            'allow_post': True, 'allow_put': True,
            'is_visible': True, 'default': None,
            'validate': {'type:string': db_const.DESCRIPTION_FIELD_SIZE},
            'convert_to': normalize_string},
        'tenant_id': {
            'allow_post': True, 'allow_put': False,
            'is_visible': True,
            'validate': {'type:string': db_const.PROJECT_ID_FIELD_SIZE},
            'required_by_policy': True},
        'ethertype': {
            'allow_post': True, 'allow_put': False,
            'is_visible': True, 'default': None,
            'convert_to': normalize_ethertype},
        'protocol': {
            'allow_post': True, 'allow_put': False,
            'is_visible': True, 'default': None,
            'convert_to': normalize_protocol},
        'source_port_range_min': {
            'allow_post': True, 'allow_put': False,
            'is_visible': True, 'default': None,
            'convert_to': normalize_port_value},
        'source_port_range_max': {
            'allow_post': True, 'allow_put': False,
            'is_visible': True, 'default': None,
            'convert_to': normalize_port_value},
        'destination_port_range_min': {
            'allow_post': True, 'allow_put': False,
            'is_visible': True, 'default': None,
            'convert_to': normalize_port_value},
        'destination_port_range_max': {
            'allow_post': True, 'allow_put': False,
            'is_visible': True, 'default': None,
            'convert_to': normalize_port_value},
        'source_ip_prefix': {
            'allow_post': True, 'allow_put': False,
            'is_visible': True, 'default': None,
            'validate': {'type:subnet_or_none': None}},
        'destination_ip_prefix': {
            'allow_post': True, 'allow_put': False,
            'is_visible': True, 'default': None,
            'validate': {'type:subnet_or_none': None}},
        'logical_source_port': {
            'allow_post': True, 'allow_put': False,
            'is_visible': True, 'default': None,
            'validate': {'type:uuid_or_none': None}},
        'logical_destination_port': {
            'allow_post': True, 'allow_put': False,
            'is_visible': True, 'default': None,
            'validate': {'type:uuid_or_none': None}},
        'l7_parameters': {
            'allow_post': True, 'allow_put': False,
            'is_visible': True, 'default': None,
            'validate': {'type:dict': None},
            'convert_to': normalize_l7parameters},
    },
}
class FlowClassifierNotFound(neutron_exc.NotFound):
class FlowClassifierPortNotFound(neutron_exc.NotFound):
class FlowClassifierInvalidPortRange(neutron_exc.InvalidInput):
class FlowClassifierInvalidPortValue(neutron_exc.InvalidInput):
class FlowClassiferDuplicateInformation(neutron_exc.InvalidInput):
class FlowClassifierInUse(neutron_exc.InUse):
class FlowClassifierInConflict(neutron_exc.InvalidInput):
class FlowClassifierInvalidProtocol(neutron_exc.InvalidInput):
class FlowClassifierInvalidEthertype(neutron_exc.InvalidInput):
class FlowClassifierProtocolRequiredWithPorts(neutron_exc.InvalidInput):
class FlowClassifierIpPrefixFormatConflictWithEthertype(
    neutron_exc.InvalidInput
):
class FlowClassifierInvalidL7Parameter(neutron_exc.InvalidInput):
class Flowclassifier(extensions.ExtensionDescriptor):
class FlowClassifierPluginBase(service_base.ServicePluginBase,
                               metaclass=ABCMeta):
def normalize_protocol(value):
def normalize_ethertype(value):
def normalize_string(value):
def normalize_port_value(port):
def normalize_l7parameters(parameters):
    def get_name(cls):
    def get_alias(cls):
    def get_description(cls):
    def get_plugin_interface(cls):
    def get_updated(cls):
    def update_attributes_map(self, attributes):
    def get_resources(cls):
    def get_extended_resources(self, version):
    def get_plugin_type(self):
    def get_plugin_description(self):
    def create_flow_classifier(self, context, flow_classifier):
    def update_flow_classifier(self, context, id, flow_classifier):
    def delete_flow_classifier(self, context, id):
    def get_flow_classifiers(self, context, filters=None, fields=None,
                             sorts=None, limit=None, marker=None,
                             page_reverse=False):
    def get_flow_classifier(self, context, id, fields=None): SG_EXT = "service_graph"
SG_PREFIX = ext_sfc.SFC_PREFIX
SERVICE_GRAPH = 'service_graph'
SERVICE_GRAPHS = '%ss' % SERVICE_GRAPH
RESOURCE_ATTRIBUTE_MAP = {
    SERVICE_GRAPHS: {
        'id': {
            'allow_post': False, 'allow_put': False,
            'is_visible': True,
            'validate': {'type:uuid': None},
            'primary_key': True},
        'name': {
            'allow_post': True, 'allow_put': True,
            'is_visible': True, 'default': '',
            'validate': {'type:string': db_const.NAME_FIELD_SIZE}},
        'description': {
            'allow_post': True, 'allow_put': True,
            'is_visible': True, 'default': '',
            'validate': {'type:string': db_const.DESCRIPTION_FIELD_SIZE}},
        'project_id': {
            'allow_post': True, 'allow_put': False,
            'is_visible': True,
            'validate': {'type:string': db_const.PROJECT_ID_FIELD_SIZE},
            'required_by_policy': True},
        'port_chains': {
            'allow_post': True, 'allow_put': False,
            'is_visible': True,
            'validate': {'type:dict': None},
            'convert_to': normalize_service_graph}
    }
}
def validate_list_of_allowed_values(data, allowed_values=None):
def normalize_service_graph(port_chains):
    def get_name(cls):
    def get_alias(cls):
    def get_description(cls):
    def get_updated(cls):
    def update_attributes_map(self, attributes):
    def get_resources(cls):
    def get_extended_resources(self, version):
    def get_plugin_type(self):
    def get_plugin_description(self):
    def create_service_graph(self, context, service_graph):
    def update_service_graph(self, context, id, service_graph):
    def delete_service_graph(self, context, id):
    def get_service_graphs(self, context, filters=None,
                           fields=None, sorts=None, limit=None,
                           marker=None, page_reverse=False):
    def get_service_graph(self, context, id, fields=None):
class InvalidUUID(neutron_exc.InvalidInput):
class ServiceGraphInvalidPortChains(neutron_exc.InUse):
class ServiceGraphPortChainInUse(neutron_exc.InUse):
class ServiceGraphNotFound(neutron_exc.NotFound):
class ServiceGraphLoopDetected(neutron_exc.InvalidInput):
class ServiceGraphInconsistentEncapsulation(neutron_exc.InvalidInput):
class ServiceGraphImpossibleBranching(neutron_exc.InvalidInput):
class ServiceGraphFlowClassifierInConflict(neutron_exc.InvalidInput):
class ServiceGraphPortChainInConflict(neutron_exc.InvalidInput):
class Servicegraph(extensions.ExtensionDescriptor):
class ServiceGraphPluginBase(metaclass=ABCMeta): SFC_EXT = "sfc"
SFC_PREFIX = "/sfc"
DEFAULT_CHAIN_CORRELATION = 'mpls'
DEFAULT_CHAIN_SYMMETRY = False
DEFAULT_CHAIN_PARAMETERS = {'correlation': DEFAULT_CHAIN_CORRELATION,
                            'symmetric': DEFAULT_CHAIN_SYMMETRY}
DEFAULT_SF_PARAMETERS = {'correlation': None, 'weight': 1}
DEFAULT_PPG_LB_FIELDS = []
DEFAULT_PPG_N_TUPLE = {'ingress_n_tuple': {}, 'egress_n_tuple': {}}
DEFAULT_PPG_PARAMETERS = {'lb_fields': DEFAULT_PPG_LB_FIELDS,
                          'ppg_n_tuple_mapping': DEFAULT_PPG_N_TUPLE}
SUPPORTED_LB_FIELDS = [
    "eth_src", "eth_dst", "ip_src", "ip_dst",
    "tcp_src", "tcp_dst", "udp_src", "udp_dst"
]
SUPPORTED_PPG_TUPLE_MAPPING = {
    'source_ip_prefix': None,
    'destination_ip_prefix': None,
    'source_port_range_min': None,
    'source_port_range_max': None,
    'destination_port_range_min': None,
    'destination_port_range_max': None,
}
MAX_CHAIN_ID = 65535
RESOURCE_ATTRIBUTE_MAP = {
    'port_pairs': {
        'id': {
            'allow_post': False, 'allow_put': False,
            'is_visible': True,
            'validate': {'type:uuid': None},
            'primary_key': True
        },
        'name': {
            'allow_post': True, 'allow_put': True,
            'is_visible': True, 'default': '',
            'validate': {'type:string': db_const.NAME_FIELD_SIZE},
        },
        'description': {
            'allow_post': True, 'allow_put': True,
            'is_visible': True, 'default': '',
            'validate': {'type:string': db_const.DESCRIPTION_FIELD_SIZE},
        },
        'tenant_id': {
            'allow_post': True, 'allow_put': False,
            'is_visible': True,
            'validate': {'type:string': db_const.PROJECT_ID_FIELD_SIZE},
            'required_by_policy': True
        },
        'ingress': {
            'allow_post': True, 'allow_put': False,
            'is_visible': True,
            'validate': {'type:uuid': None}
        },
        'egress': {
            'allow_post': True, 'allow_put': False,
            'is_visible': True,
            'validate': {'type:uuid': None}
        },
        'service_function_parameters': {
            'allow_post': True, 'allow_put': False,
            'is_visible': True, 'default': None,
            'validate': {
                'type:dict': {
                    'correlation': {
                        'default': DEFAULT_SF_PARAMETERS['correlation'],
                        'type:values': [None, 'mpls', 'nsh']
                    },
                    'weight': {
                        'default': DEFAULT_SF_PARAMETERS['weight'],
                        'type:non_negative': None,
                        'convert_to': lib_converters.convert_to_int
                    }
                }
            },
            'convert_to': normalize_sf_parameters
        }
    },
    'port_chains': {
        'id': {
            'allow_post': False, 'allow_put': False,
            'is_visible': True,
            'validate': {'type:uuid': None},
            'primary_key': True
        },
        'chain_id': {
            'allow_post': True, 'allow_put': False,
            'is_visible': True, 'default': 0,
            'validate': {'type:range': (0, MAX_CHAIN_ID)},
            'convert_to': lib_converters.convert_to_int
        },
        'name': {
            'allow_post': True, 'allow_put': True,
            'is_visible': True, 'default': '',
            'validate': {'type:string': db_const.NAME_FIELD_SIZE},
        },
        'description': {
            'allow_post': True, 'allow_put': True,
            'is_visible': True, 'default': '',
            'validate': {'type:string': db_const.DESCRIPTION_FIELD_SIZE},
        },
        'tenant_id': {
            'allow_post': True, 'allow_put': False,
            'is_visible': True,
            'validate': {'type:string': db_const.PROJECT_ID_FIELD_SIZE},
            'required_by_policy': True
        },
        'port_pair_groups': {
            'allow_post': True, 'allow_put': True,
            'is_visible': True,
            'validate': {'type:uuid_list': None},
            'convert_to': normalize_port_pair_groups
        },
        'flow_classifiers': {
            'allow_post': True, 'allow_put': True,
            'is_visible': True, 'default': None,
            'validate': {'type:uuid_list': None},
            'convert_to': lib_converters.convert_to_list
        },
        'chain_parameters': {
            'allow_post': True, 'allow_put': False,
            'is_visible': True, 'default': None,
            'validate': {
                'type:dict': {
                    'correlation': {
                        'default': DEFAULT_CHAIN_PARAMETERS['correlation'],
                        'type:values': ['mpls', 'nsh']
                    },
                    'symmetric': {
                        'default': DEFAULT_CHAIN_PARAMETERS['symmetric'],
                        'convert_to': lib_converters.convert_to_boolean
                    }
                }
            },
            'convert_to': normalize_chain_parameters
        }
    },
    'port_pair_groups': {
        'id': {
            'allow_post': False, 'allow_put': False,
            'is_visible': True,
            'validate': {'type:uuid': None},
            'primary_key': True},
        'group_id': {
            'allow_post': False, 'allow_put': False,
            'is_visible': True
        },
        'name': {
            'allow_post': True, 'allow_put': True,
            'is_visible': True, 'default': '',
            'validate': {'type:string': db_const.NAME_FIELD_SIZE},
        },
        'description': {
            'allow_post': True, 'allow_put': True,
            'is_visible': True, 'default': '',
            'validate': {'type:string': db_const.DESCRIPTION_FIELD_SIZE},
        },
        'tenant_id': {
            'allow_post': True, 'allow_put': False,
            'is_visible': True,
            'validate': {'type:string': db_const.PROJECT_ID_FIELD_SIZE},
            'required_by_policy': True
        },
        'port_pairs': {
            'allow_post': True, 'allow_put': True,
            'is_visible': True, 'default': None,
            'validate': {'type:uuid_list': None},
            'convert_to': lib_converters.convert_none_to_empty_list
        },
        'port_pair_group_parameters': {
            'allow_post': True, 'allow_put': False,
            'is_visible': True, 'default': None,
            'validate': {
                'type:dict': {
                    'lb_fields': {
                        'default': DEFAULT_PPG_PARAMETERS['lb_fields'],
                        'type:list_of_allowed_values': SUPPORTED_LB_FIELDS
                    },
                    'ppg_n_tuple_mapping': {
                        'default': DEFAULT_PPG_PARAMETERS[
                            'ppg_n_tuple_mapping'],
                        'validate': {
                            'type:dict': {
                                'ingress_n_tuple': {
                                    'default': {},
                                    'validate': {
                                        'type:dict': ppg_n_tuple_validact_dict
                                    }
                                },
                                'egress_n_tuple': {
                                    'default': {},
                                    'validate': {
                                        'type:dict': ppg_n_tuple_validact_dict
                                    }
                                }
                            }
                        },
                        'convert_to': lib_converters.convert_none_to_empty_dict
                    }
                }
            },
            'convert_to': normalize_ppg_parameters
        }
    }
}
def validate_list_of_allowed_values(data, allowed_values=None):
def normalize_port_pair_groups(port_pair_groups):
def normalize_chain_parameters(parameters):
def normalize_sf_parameters(parameters):
def normalize_ppg_parameters(parameters):
    def get_name(cls):
    def get_alias(cls):
    def get_description(cls):
    def get_plugin_interface(cls):
    def get_updated(cls):
    def update_attributes_map(self, attributes):
    def get_resources(cls):
    def get_extended_resources(self, version):
    def get_plugin_type(self):
    def get_plugin_description(self):
    def create_port_chain(self, context, port_chain):
    def update_port_chain(self, context, id, port_chain):
    def delete_port_chain(self, context, id):
    def get_port_chains(self, context, filters=None, fields=None,
                        sorts=None, limit=None, marker=None,
                        page_reverse=False):
    def get_port_chain(self, context, id, fields=None):
    def create_port_pair_group(self, context, port_pair_group):
    def update_port_pair_group(self, context, id, port_pair_group):
    def delete_port_pair_group(self, context, id):
    def get_port_pair_groups(self, context, filters=None, fields=None,
                             sorts=None, limit=None, marker=None,
                             page_reverse=False):
    def get_port_pair_group(self, context, id, fields=None):
    def create_port_pair(self, context, port_pair):
    def update_port_pair(self, context, id, port_pair):
    def delete_port_pair(self, context, id):
    def get_port_pairs(self, context, filters=None, fields=None,
                       sorts=None, limit=None, marker=None,
                       page_reverse=False):
    def get_port_pair(self, context, id, fields=None):
class PortChainNotFound(neutron_exc.NotFound):
class PortChainUnavailableChainId(neutron_exc.InvalidInput):
class PortChainFlowClassifierInConflict(neutron_exc.InvalidInput):
class PortChainChainIdInConflict(neutron_exc.InvalidInput):
class PortChainInconsistentCorrelations(neutron_exc.InvalidInput):
class PortPairGroupNotSpecified(neutron_exc.InvalidInput):
class InconsistentCorrelations(neutron_exc.InvalidInput):
class InvalidPortPairGroups(neutron_exc.InUse):
class PortPairPortNotFound(neutron_exc.NotFound):
class PortPairIngressEgressDifferentHost(neutron_exc.InvalidInput):
class PortPairIngressNoHost(neutron_exc.InvalidInput):
class PortPairEgressNoHost(neutron_exc.InvalidInput):
class PortPairIngressEgressInUse(neutron_exc.InvalidInput):
class PortPairNotFound(neutron_exc.NotFound):
class PortPairGroupNotFound(neutron_exc.NotFound):
class PortPairGroupInUse(neutron_exc.InUse):
class PortPairInUse(neutron_exc.InUse):
class PPGParametersInvalidNTupleMappingParameter(neutron_exc.InvalidInput):
class Sfc(extensions.ExtensionDescriptor):
class SfcPluginBase(service_base.ServicePluginBase, metaclass=ABCMeta): DEFAULT_TAP_ENABLED = False
TAP_EXT = "networking-sfc-tap"
EXTENDED_ATTRIBUTES_2_0 = {
    'port_pair_groups': {
        'tap_enabled': {
            'allow_post': True, 'allow_put': False,
            'is_visible': True, 'default': DEFAULT_TAP_ENABLED,
            'convert_to': lib_converters.convert_to_boolean
        }
    }
}
class MultiplePortPairsInTapPPGNotSupported(neutron_exc.InvalidInput):
class ConsecutiveTapPPGNotSupported(neutron_exc.InvalidInput):
class Tap(extensions.ExtensionDescriptor):
    def get_name(cls):
    def get_alias(cls):
    def get_description(cls):
    def get_updated(cls):
    def get_extended_resources(self, version):
    def get_plugin_interface(cls): class SfcPluginContext():
class PortChainContext(SfcPluginContext):
class FlowClassifierContext(SfcPluginContext):
class PortPairContext(SfcPluginContext):
class PortPairGroupContext(SfcPluginContext):
class ServiceGraphContext(SfcPluginContext):
    def __init__(self, plugin, plugin_context):
    def __init__(self, plugin, plugin_context, portchain,
                 original_portchain=None):
    def current(self):
    def original(self):
    def __init__(self, plugin, plugin_context, flowclassifier,
                 original_flowclassifier=None):
    def current(self):
    def original(self):
    def __init__(self, plugin, plugin_context, portpair,
                 original_portpair=None):
    def current(self):
    def original(self):
    def __init__(self, plugin, plugin_context, portpairgroup,
                 original_portpairgroup=None):
    def current(self):
    def original(self):
    def __init__(self, plugin, plugin_context, service_graph,
                 original_graph=None):
    def current(self):
    def original(self): class SfcDriverError(exceptions.NeutronException):
class SfcException(exceptions.NeutronException):
class SfcBadRequest(exceptions.BadRequest, SfcException):
class SfcNoSubnetGateway(SfcDriverError):
class SfcNoSuchSubnet(SfcDriverError):
class FlowClassifierInvalid(SfcDriverError): LOG = logging.getLogger(__name__)
class OVSSfcDriver(driver_base.SfcDriverBase,
                   ovs_sfc_db.OVSSfcDriverDB):
    def initialize(self):
    def _setup_rpc(self):
    def _get_port_infos(self, context, port, segment, agent_host):
    def _get_agent_fdb(self, context, port, segment, agent_host):
    def _get_remote_pop_ports(self, context, flow_rule):
    def _get_network_other_active_entry_count(self, host, remote_port_id):
    def _call_on_l2pop_driver(self, context, method_name, flow_rule):
    def _update_agent_fdb_entries(self, context, flow_rule):
    def _delete_agent_fdb_entries(self, context, flow_rule):
    def _get_subnet_by_port(self, id):
    def _get_portgroup_members(self, context, pg_id, fwd_path):
    def _get_port_pair_detail_by_port_pair(self, context, port_pair_id):
    def _add_flowclassifier_port_assoc(self, fc_ids, project_id,
                                       src_node):
    def _remove_flowclassifier_port_assoc(self, fc_ids, project_id,
                                          src_nodes):
    def _create_portchain_path(self, context, port_chain, fwd_path):
    def _update_ppg_n_tuple_in_flow_rule(self, path_nodes,
                                         fwd_path, sf_path_length):
    def _delete_path_node_port_flowrule(self, context, node,
                                        port, pc_corr, fc_ids):
    def _delete_path_node_flowrule(self, context, node, pc_corr, fc_ids):
    def _delete_portchain_path(self, context, port_chain):
    def _update_path_node_next_hops(self, flow_rule):
    def _build_portchain_flowrule_body(self, node, port, pc_corr,
                                       add_fc_ids=None, del_fc_ids=None):
    def _filter_flow_classifiers(self, flow_rule, fc_ids):
    def _update_path_node_port_flowrules(self, context, node, port, pc_corr,
                                         add_fc_ids=None, del_fc_ids=None):
    def _update_path_node_flowrules(self, context, node, pc_corr,
                                    add_fc_ids=None, del_fc_ids=None):
    def _update_path_nodes(self, context, nodes, pc_corr,
                           add_fc_ids=None, del_fc_ids=None):
    def _get_portchain_fcs(self, port_chain):
    def _get_fcs_by_ids(self, fc_ids):
    def create_port_chain_precommit(self, context):
    def create_port_chain(self, context):
    def delete_port_chain(self, context):
    def _get_diff_set(self, orig, cur):
    def update_port_chain(self, context):
    def create_port_pair_group(self, context):
    def delete_port_pair_group(self, context):
    def update_port_pair_group(self, context):
    def _get_port_detail_info(self, port_id):
    def _create_port_pair_detail(self, port_pair):
    def create_port_pair(self, context):
    def delete_port_pair(self, context):
    def update_port_pair(self, context):
    def get_flowrules_by_host_portid(self, context, host, port_id):
    def _get_flow_rule_for_service_graph_node(
            self, context, node, port, port_chain):
    def _build_bare_flow_rule(self, node, port, pc_corr, pp_corr):
    def _build_fcs_from_fc_ids(self, flow_rule, fc_ids):
    def _extend_sg_src_chain_flow_rule(
            self, flow_rule, branch_point, add_fcs, del_fcs):
    def _extend_sg_dst_chain_flow_rule(
            self, flow_rule, on_add, matches, add_fcs=None, del_fcs=None):
    def update_flowrule_status(self, context, id, status):
    def _update_portchain_group_reference_count(self, flow_rule, host):
    def _service_graph_linking_logic(self, context, create):
    def create_service_graph_precommit(self, context):
    def create_service_graph_postcommit(self, context):
    def update_service_graph_precommit(self, context):
    def update_service_graph_postcommit(self, context):
    def delete_service_graph_precommit(self, context):
    def delete_service_graph_postcommit(self, context):
    def _get_tap_port_ingress_flow(self, context, sfc_plugin,
                                   port_chain_flowrules, port_detail_list):
    def _get_egress_flowrule_if_next_hop_tap(self, sfc_plugin, context,
                                             port_chain_flowrules,
                                             port_detail_list):
    def _validate_chain(self, context, port_chain, port_pair_groups, fwd_path):
    def _update_tap_enabled_node(self, node):
    def _build_tap_ingress_flow(self, pc_corr, node, fwd_path, delete=False,
                                configure=True):
    def _update_tap_ingress_flow_rules(self, flowrule_list, delete):
    def _is_tap_ports(self, port_detail_list):
    def _update_sc_path_parameter(self, nodes):
    def _update_next_hop_details(self, flow_rule, port_detail, detail): LOG = logging.getLogger(__name__)
class SfcRpcCallback():
class SfcAgentRpcClient():
    def __init__(self, driver):
    def get_flowrules_by_host_portid(self, context, **kwargs):
    def update_flowrules_status(self, context, **kwargs):
    def __init__(self, topic=sfc_topics.SFC_AGENT):
    def ask_agent_to_update_flow_rules(self, context, flow_rule):
    def ask_agent_to_delete_flow_rules(self, context, flow_rule): class BaseTestCase(n_base.BaseTestCase):
class NeutronDbPluginV2TestCase(test_db_plugin.NeutronDbPluginV2TestCase):
    def setUp(self, plugin=None, service_plugins=None, ext_mgr=None):
    def _mock_unnecessary_logging(self):
    def tearDown(self):
    def port(self, fmt=None, **kwargs): DB_FLOWCLASSIFIER_PLUGIN_CLASS = (
    "networking_sfc.db.flowclassifier_db.FlowClassifierDbPlugin"
)
class FlowClassifierDbPluginTestCaseBase(base.BaseTestCase):
class FlowClassifierDbPluginTestCase(
    base.NeutronDbPluginV2TestCase,
    FlowClassifierDbPluginTestCaseBase
):
    def _create_flow_classifier(
        self, fmt, flow_classifier=None, expected_res_status=None, **kwargs
    ):
    def flow_classifier(
        self, fmt=None, flow_classifier=None, do_delete=True, **kwargs
    ):
    def _get_expected_flow_classifier(self, flow_classifier):
    def _assert_flow_classifiers_match_subsets(self, flow_classifiers,
                                               subsets, sort_key=None):
    def _test_create_flow_classifier(
        self, flow_classifier, expected_flow_classifier=None
    ):
    def setUp(self, core_plugin=None, flowclassifier_plugin=None,
              ext_mgr=None):
    def test_create_flow_classifier(self):
    def test_create_flow_classifier_with_logical_destination_port(self):
    def test_quota_create_flow_classifier(self):
    def test_create_flow_classifier_with_all_fields(self):
    def test_create_flow_classifier_with_all_supported_ethertype(self):
    def test_create_flow_classifier_with_invalid_ethertype(self):
    def test_create_flow_classifier_with_all_supported_protocol(self):
    def test_create_flow_classifier_with_invalid_protocol(self):
    def test_create_flow_classifier_with_all_supported_port_protocol(self):
    def test_create_flow_classifier_with_invalid_ip_prefix_ethertype(self):
    def test_create_flow_classifier_with_invalid_port_protocol(self):
    def test_create_flow_classifier_with_all_supported_ip_prefix(self):
    def test_create_flow_classifier_with_invalid_ip_prefix(self):
    def test_create_flow_classifier_with_all_supported_l7_parameters(self):
    def test_create_flow_classifier_with_invalid_l7_parameters(self):
    def test_create_flow_classifier_with_port_id(self):
    def test_create_flow_classifier_with_nouuid_port_id(self):
    def test_create_flow_classifier_ethertype_conflict(self):
    def test_create_flow_classifier_protocol_conflict(self):
    def test_create_flow_classifier_source_ip_prefix_conflict(self):
    def test_create_flow_classifier_destination_ip_prefix_conflict(self):
    def test_create_flow_classifier_source_port_range_conflict(self):
    def test_create_flow_classifier_destination_port_range_conflict(self):
    def test_create_flow_classifier_not_all_fields_conflict(self):
    def test_create_flow_classifier_with_unknown_port_id(self):
    def test_list_flow_classifiers(self):
    def test_list_flow_classifiers_with_params(self):
    def test_list_flow_classifiers_with_unknown_params(self):
    def test_show_flow_classifier(self):
    def test_show_flow_classifier_noexist(self):
    def test_update_flow_classifier(self):
    def _test_update_with_field(
        self, fc, updates, expected_status_code
    ):
    def test_update_flow_classifer_unsupported_fields(self):
    def test_delete_flow_classifier(self):
    def test_delete_flow_classifier_noexist(self): DB_SFC_PLUGIN_CLASS = (
    "networking_sfc.db.sfc_db.SfcDbPlugin"
)
class SfcDbPluginTestCaseBase(
    base.BaseTestCase
):
class SfcDbPluginTestCase(
    base.NeutronDbPluginV2TestCase,
    test_flowclassifier_db.FlowClassifierDbPluginTestCaseBase,
    SfcDbPluginTestCaseBase
):
    def _assert_port_chain_equal(self, res_port_chain, expected):
    def _create_port_chain(
        self, fmt, port_chain=None, expected_res_status=None, **kwargs
    ):
    def port_chain(self, fmt=None, port_chain=None, do_delete=True, **kwargs):
    def _create_port_pair_group(
        self, fmt, port_pair_group=None, expected_res_status=None, **kwargs
    ):
    def port_pair_group(
        self, fmt=None, port_pair_group=None, do_delete=True, **kwargs
    ):
    def _create_port_pair(
        self, fmt, port_pair=None, expected_res_status=None, **kwargs
    ):
    def port_pair(self, fmt=None, port_pair=None, do_delete=True, **kwargs):
    def _create_service_graph(
        self, fmt, service_graph=None, expected_res_status=None, **kwargs
    ):
    def service_graph(self, fmt=None,
                      service_graph=None, do_delete=True, **kwargs):
    def _get_expected_port_pair(self, port_pair):
    def _test_create_port_pair(self, port_pair, expected_port_pair=None):
    def _test_create_port_pairs(
        self, port_pairs, expected_port_pairs=None
    ):
    def _get_expected_port_pair_group(self, port_pair_group):
    def _test_create_port_pair_group(
        self, port_pair_group, expected_port_pair_group=None
    ):
    def _test_create_port_pair_groups(
        self, port_pair_groups, expected_port_pair_groups=None
    ):
    def _get_expected_port_chain(port_chain):
    def _test_create_port_chain(self, port_chain, expected_port_chain=None):
    def _test_create_port_chains(
        self, port_chains, expected_port_chains=None
    ):
    def _get_expected_graph(service_graph):
    def _test_create_service_graph(self, service_graph, expected_graph=None):
    def setUp(self, core_plugin=None, sfc_plugin=None,
              flowclassifier_plugin=None, ext_mgr=None):
    def test_create_port_chain(self):
    def test_quota_create_port_chain(self):
    def test_create_port_chain_all_fields(self):
    def test_create_port_chain_all_fields_with_chain_id(self):
    def test_create_port_chain_all_fields_with_symmetric(self):
    def test_create_port_chain_multi_port_pair_groups(self):
    def test_create_port_chain_shared_port_pair_groups(self):
    def test_create_port_chain_shared_port_pair_groups_different_order(self):
    def test_create_port_chain_with_empty_chain_parameters(self):
    def test_create_port_chain_with_none_chain_parameters(self):
    def test_create_port_chain_with_default_chain_parameters(self):
    def test_create_port_chain_with_nsh_correlation(self):
    def test_create_port_chain_with_nsh_correlation_incompatible_ppg_fail(
            self):
    def test_create_port_chains_with_conflicting_chain_ids(self):
    def test_create_port_chain_with_none_flow_classifiers(self):
    def test_create_port_chain_with_empty_flow_classifiers(self):
    def test_create_port_chain_with_flow_classifiers(self):
    def test_create_port_chain_with_multi_flow_classifiers(self):
    def test_create_port_chain_with_flow_classifiers_basic_the_same(self):
    def test_create_multi_port_chain_with_flow_classifiers(self):
    def test_create_multi_port_chain_with_conflict_flow_classifiers(self):
    def test_create_multi_port_chain_with_same_flow_classifier(self):
    def test_create_port_chain_with_port_pairs(self):
    def test_create_port_chain_with_empty_port_pair_groups(self):
    def test_create_port_chain_with_nonuuid_port_pair_group_id(self):
    def test_create_port_chain_with_unknown_port_pair_group_id(self):
    def test_create_port_chain_with_same_port_pair_groups(self):
    def test_create_port_chain_with_no_port_pair_groups(self):
    def test_create_port_chain_with_consecutive_tap_port_pair_groups(self):
    def test_create_port_chain_with_non_consecutive_tap_port_pair_groups(self):
    def test_create_port_chain_with_invalid_chain_parameters(self):
    def test_create_port_chain_with_invalid_chain_parameters_symmetric(self):
    def test_create_port_chain_unknown_flow_classifiers(self):
    def test_create_port_chain_nouuid_flow_classifiers(self):
    def test_list_port_chains(self):
    def test_list_port_chains_with_params(self):
    def test_list_port_chains_with_unknown_params(self):
    def test_show_port_chain(self):
    def test_show_port_chain_noexist(self):
    def test_update_port_chain_add_flow_classifiers(self):
    def test_update_port_chain_remove_flow_classifiers(self):
    def test_update_port_chain_replace_flow_classifiers(self):
    def test_update_port_chain_flow_classifiers_basic_the_same(self):
    def test_update_port_chain_conflict_flow_classifiers(self):
    def test_update_port_chain_add_port_pair_groups(self):
    def test_update_port_chain_remove_port_pair_groups(self):
    def test_update_port_chain_replace_port_pair_groups(self):
    def test_update_port_chain_chain_parameters(self):
    def test_update_port_chain_part_of_graph_fail(self):
    def test_update_port_chain_consistency_with_consecutive_tap_ppg(self):
    def test_update_tap_port_chain_consistency(self):
    def test_delete_port_chain(self):
    def test_delete_port_chain_noexist(self):
    def test_delete_port_chain_part_of_graph_fail(self):
    def test_delete_flow_classifier_port_chain_exist(self):
    def test_create_port_pair_group(self):
    def test_quota_create_port_pair_group_quota(self):
    def test_create_port_pair_group_all_fields(self):
    def test_create_port_pair_group_with_empty_parameters(self):
    def test_create_port_pair_group_with_none_parameters(self):
    def test_create_port_pair_group_with_default_parameters(self):
    def test_create_port_pair_group_with_tap_enabled_parameter_true(self):
    def test_create_ppg_with_all_params_and_tap_enabled_parameter_true(self):
    def test_create_port_pair_group_with_port_pairs(self):
    def test_create_tap_port_pair_group_with_single_port_pair(self):
    def test_create_tap_pair_group_with_multiple_port_pairs(self):
    def test_create_port_pair_group_consistent_correlations(self):
    def test_create_port_pair_group_inconsistent_correlations(self):
    def test_create_port_pair_group_with_nouuid_port_pair_id(self):
    def test_create_port_pair_group_with_unknown_port_pair_id(self):
    def test_create_port_pair_group_share_port_pair_id(self):
    def test_list_port_pair_groups(self):
    def test_list_port_pair_groups_with_params(self):
    def test_list_port_pair_groups_with_unknown_params(self):
    def test_show_port_pair_group(self):
    def test_show_port_pair_group_noexist(self):
    def test_update_port_pair_group(self):
    def test_update_port_pair_group_consistency_checks(self):
    def test_update_tap_port_pair_group_consistency(self):
    def test_delete_port_pair_group(self):
    def test_delete_port_pair_group_port_chain_exist(self):
    def test_delete_port_pair_group_noexist(self):
    def test_create_port_pair(self):
    def test_quota_create_port_pair_quota(self):
    def test_create_port_pair_all_fields(self):
    def test_create_port_pair_none_service_function_parameters(self):
    def test_create_port_pair_empty_service_function_parameters(self):
    def test_create_port_pair_with_src_dst_same_port(self):
    def test_create_port_pair_empty_input(self):
    def test_create_port_pair_with_no_ingress(self):
    def test_create_port_pair_with_no_egress(self):
    def test_create_port_pair_with_nouuid_ingress(self):
    def test_create_port_pair_with_unknown_ingress(self):
    def test_create_port_pair_with_nouuid_egress(self):
    def test_create_port_pair_with_unknown_egress(self):
    def test_create_port_pair_ingress_egress_different_hosts(self):
    def test_create_port_pair_with_invalid_service_function_parameters(self):
    def test_create_port_pair_with_invalid_correlation(self):
    def test_create_port_pair_with_invalid_weight(self):
    def test_list_port_pairs(self):
    def test_list_port_pairs_with_params(self):
    def test_list_port_pairs_with_unknown_params(self):
    def test_show_port_pair(self):
    def test_show_port_pair_noexist(self):
    def test_update_port_pair(self):
    def test_update_port_pair_service_function_parameters(self):
    def test_update_port_pair_ingress(self):
    def test_update_port_pair_egress(self):
    def test_delete_port_pair(self):
    def test_delete_port_pair_noexist(self):
    def test_delete_port_pair_port_pair_group_exist(self):
    def test_delete_ingress_port_pair_exist(self):
    def test_delete_egress_port_pair_exist(self):
    def _test_create_service_graph_branching_ppg(
            self, src_corr, dst_corr, status):
    def test_create_service_graph_branching_ppg_no_src_corr_fail(self):
    def test_create_service_graph_branching_ppg_no_dst_corr_fail(self):
    def test_create_service_graph_branching_ppg_both_corrs_ok(self):
    def test_create_service_graph_linear_dependency_only(self):
    def test_create_service_graph_branching_no_class(self):
    def test_create_service_graph_same_chain_fail(self):
    def test_create_service_graph_with_already_used_pcs_fail(self):
    def test_create_service_graph_with_multiple_starts(self):
    def _test_create_service_graph_single_branching_two_fcs_each(
            self, fc1_dict, fc2_dict, fc3_dict, fc4_dict, expected_res_status
    ):
    def test_create_service_graph_unambiguous_branch(self):
    def test_create_service_graph_with_direct_loop_fail(self):
    def test_create_service_graph_with_indirect_loop_fail(self):
    def test_create_service_graph_with_inexistent_port_chains(self):
    def test_create_service_graph_with_joining_branches(self):
    def test_update_service_graph(self):
    def test_delete_service_graph(self):
from unittest import mock
from eventlet import greenthread
from neutron.api import extensions as api_ext
from neutron.common import config
from neutron.plugins.ml2.drivers import type_vxlan
from neutron_lib.api.definitions import portbindings
from neutron_lib import context
from neutron_lib import rpc as n_rpc
from oslo_utils import importutils
from networking_sfc.db import flowclassifier_db as fdb
from networking_sfc.db import sfc_db
from networking_sfc.extensions import flowclassifier
from networking_sfc.extensions import servicegraph
from networking_sfc.extensions import sfc
from networking_sfc.extensions import tap
from networking_sfc.services.sfc.common import context as sfc_ctx
from networking_sfc.services.sfc.common import exceptions as sfc_exc
from networking_sfc.services.sfc.drivers.ovs import driver
from networking_sfc.services.sfc.drivers.ovs import rpc
from networking_sfc.tests import base
from networking_sfc.tests.unit.db import test_flowclassifier_db
from networking_sfc.tests.unit.db import test_sfc_db
# Copyright 2015 Huawei.  All rights reserved.
# Copyright 2017 Intel Corporation.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.





class OVSSfcDriverTestCase(
    test_sfc_db.SfcDbPluginTestCaseBase,
    test_flowclassifier_db.FlowClassifierDbPluginTestCaseBase,
    base.NeutronDbPluginV2TestCase
):

    resource_prefix_map = dict([
        (k, sfc.SFC_PREFIX)
        for k in sfc.RESOURCE_ATTRIBUTE_MAP.keys()
    ] + [

        (k, flowclassifier.FLOW_CLASSIFIER_PREFIX)