<s> import abc <EOL> import six <EOL> from neutron . api import extensions <EOL> from neutron . api . v2 import attributes as attr <EOL> from neutron . api . v2 import base <EOL> from neutron . api . v2 import resource_helper <EOL> from neutron . common import exceptions as n_exc <EOL> from neutron import manager <EOL> from neutron . plugins . common import constants as n_const <EOL> from neutron . services . service_base import ServicePluginBase <EOL> from oslo_log import log <EOL> from networking_bgpvpn . neutron import extensions as bgpvpn_ext <EOL> from networking_bgpvpn . neutron . services . common import constants <EOL> LOG = log . getLogger ( __name__ ) <EOL> RT_REGEX = ( r'<STR_LIT>' <EOL> r'<STR_LIT>' <EOL> r'<STR_LIT>' ) <EOL> extensions . append_api_extensions_path ( bgpvpn_ext . __path__ ) <EOL> n_const . EXT_TO_SERVICE_MAPPING [ '<STR_LIT>' ] = constants . BGPVPN <EOL> class BGPVPNNotFound ( n_exc . NotFound ) : <EOL> message = _ ( "<STR_LIT>" ) <EOL> class BGPVPNNetAssocNotFound ( n_exc . NotFound ) : <EOL> message = _ ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> class BGPVPNRouterAssocNotFound ( n_exc . NotFound ) : <EOL> message = _ ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> class BGPVPNTypeNotSupported ( n_exc . BadRequest ) : <EOL> message = _ ( "<STR_LIT>" ) <EOL> class BGPVPNRDNotSupported ( n_exc . BadRequest ) : <EOL> message = _ ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> class BGPVPNNetAssocAlreadyExists ( n_exc . BadRequest ) : <EOL> message = _ ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> class BGPVPNRouterAssociationNotSupported ( n_exc . BadRequest ) : <EOL> message = _ ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> class BGPVPNRouterAssocAlreadyExists ( n_exc . BadRequest ) : <EOL> message = _ ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> class BGPVPNMultipleRouterAssocNotSupported ( n_exc . BadRequest ) : <EOL> message = _ ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> class BGPVPNNetworkAssocExistsAnotherBgpvpn ( n_exc . BadRequest ) : <EOL> message = _ ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> class BGPVPNDriverError ( n_exc . NeutronException ) : <EOL> message = _ ( "<STR_LIT>" ) <EOL> def _validate_rt_list ( data , valid_values = None ) : <EOL> if data is None or data is "<STR_LIT>" : <EOL> return <EOL> if not isinstance ( data , list ) : <EOL> msg = _ ( "<STR_LIT>" ) % data <EOL> LOG . debug ( msg ) <EOL> return msg <EOL> for item in data : <EOL> msg = attr . _validate_regex ( item , RT_REGEX ) <EOL> if msg : <EOL> LOG . debug ( msg ) <EOL> return msg <EOL> if len ( set ( data ) ) != len ( data ) : <EOL> msg = _ ( "<STR_LIT>" ) % '<STR_LIT:U+002CU+0020>' . join ( data ) <EOL> LOG . debug ( msg ) <EOL> return msg <EOL> validators = { '<STR_LIT>' : _validate_rt_list } <EOL> attr . validators . update ( validators ) <EOL> RESOURCE_ATTRIBUTE_MAP = { <EOL> constants . BGPVPN_RES : { <EOL> '<STR_LIT:id>' : { '<STR_LIT>' : False , '<STR_LIT>' : False , <EOL> '<STR_LIT>' : { '<STR_LIT>' : None } , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT:primary_key>' : True , <EOL> '<STR_LIT>' : True } , <EOL> '<STR_LIT>' : { '<STR_LIT>' : True , '<STR_LIT>' : False , <EOL> '<STR_LIT>' : { '<STR_LIT>' : None } , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : True } , <EOL> '<STR_LIT:name>' : { '<STR_LIT>' : True , '<STR_LIT>' : True , <EOL> '<STR_LIT:default>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT>' : None } , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : True } , <EOL> '<STR_LIT:type>' : { '<STR_LIT>' : True , '<STR_LIT>' : False , <EOL> '<STR_LIT:default>' : constants . BGPVPN_L3 , <EOL> '<STR_LIT>' : { '<STR_LIT>' : constants . BGPVPN_TYPES } , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : True } , <EOL> '<STR_LIT>' : { '<STR_LIT>' : True , '<STR_LIT>' : True , <EOL> '<STR_LIT:default>' : [ ] , <EOL> '<STR_LIT>' : attr . convert_to_list , <EOL> '<STR_LIT>' : { '<STR_LIT>' : None } , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : True } , <EOL> '<STR_LIT>' : { '<STR_LIT>' : True , '<STR_LIT>' : True , <EOL> '<STR_LIT:default>' : [ ] , <EOL> '<STR_LIT>' : attr . convert_to_list , <EOL> '<STR_LIT>' : { '<STR_LIT>' : None } , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : True } , <EOL> '<STR_LIT>' : { '<STR_LIT>' : True , '<STR_LIT>' : True , <EOL> '<STR_LIT:default>' : [ ] , <EOL> '<STR_LIT>' : attr . convert_to_list , <EOL> '<STR_LIT>' : { '<STR_LIT>' : None } , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : True } , <EOL> '<STR_LIT>' : { '<STR_LIT>' : True , '<STR_LIT>' : True , <EOL> '<STR_LIT:default>' : [ ] , <EOL> '<STR_LIT>' : attr . convert_to_list , <EOL> '<STR_LIT>' : { '<STR_LIT>' : None } , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : True } , <EOL> '<STR_LIT>' : { '<STR_LIT>' : False , '<STR_LIT>' : False , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : True } , <EOL> '<STR_LIT>' : { '<STR_LIT>' : False , '<STR_LIT>' : False , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : True } <EOL> } , <EOL> } <EOL> SUB_RESOURCE_ATTRIBUTE_MAP = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:id>' : { '<STR_LIT>' : False , '<STR_LIT>' : False , <EOL> '<STR_LIT>' : { '<STR_LIT>' : None } , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT:primary_key>' : True } , <EOL> '<STR_LIT>' : { '<STR_LIT>' : True , '<STR_LIT>' : False , <EOL> '<STR_LIT>' : { '<STR_LIT>' : None } , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : True } , <EOL> '<STR_LIT>' : { '<STR_LIT>' : True , '<STR_LIT>' : False , <EOL> '<STR_LIT>' : { '<STR_LIT>' : None } , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : True } <EOL> } <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:id>' : { '<STR_LIT>' : False , '<STR_LIT>' : False , <EOL> '<STR_LIT>' : { '<STR_LIT>' : None } , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT:primary_key>' : True } , <EOL> '<STR_LIT>' : { '<STR_LIT>' : True , '<STR_LIT>' : False , <EOL> '<STR_LIT>' : { '<STR_LIT>' : None } , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : True } , <EOL> '<STR_LIT>' : { '<STR_LIT>' : True , '<STR_LIT>' : False , <EOL> '<STR_LIT>' : { '<STR_LIT>' : None } , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : True } <EOL> } <EOL> } <EOL> } <EOL> class Bgpvpn ( extensions . ExtensionDescriptor ) : <EOL> @ classmethod <EOL> def get_name ( cls ) : <EOL> return "<STR_LIT>" <EOL> @ classmethod <EOL> def get_alias ( cls ) : <EOL> return "<STR_LIT>" <EOL> @ classmethod <EOL> def get_description ( cls ) : <EOL> return "<STR_LIT>" <EOL> @ classmethod <EOL> def get_updated ( cls ) : <EOL> return "<STR_LIT>" <EOL> @ classmethod <EOL> def get_resources ( cls ) : <EOL> plural_mappings = resource_helper . build_plural_mappings ( <EOL> { } , RESOURCE_ATTRIBUTE_MAP ) <EOL> plural_mappings [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> plural_mappings [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> plural_mappings [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> plural_mappings [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> plural_mappings [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> plural_mappings [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> attr . PLURALS . update ( plural_mappings ) <EOL> resources = resource_helper . build_resource_info ( plural_mappings , <EOL> RESOURCE_ATTRIBUTE_MAP , <EOL> constants . BGPVPN , <EOL> register_quota = True , <EOL> translate_name = True ) <EOL> plugin = manager . NeutronManager . get_service_plugins ( ) [ constants . BGPVPN ] <EOL> for collection_name in SUB_RESOURCE_ATTRIBUTE_MAP : <EOL> resource_name = collection_name [ : - <NUM_LIT:1> ] <EOL> parent = SUB_RESOURCE_ATTRIBUTE_MAP [ collection_name ] . get ( '<STR_LIT>' ) <EOL> params = SUB_RESOURCE_ATTRIBUTE_MAP [ collection_name ] . get ( <EOL> '<STR_LIT>' ) <EOL> controller = base . create_resource ( collection_name , resource_name , <EOL> plugin , params , <EOL> allow_bulk = True , <EOL> parent = parent , <EOL> allow_pagination = True , <EOL> allow_sorting = True ) <EOL> resource = extensions . ResourceExtension ( <EOL> collection_name , <EOL> controller , parent , <EOL> path_prefix = '<STR_LIT>' , <EOL> attr_map = params ) <EOL> resources . append ( resource ) <EOL> return resources <EOL> @ classmethod <EOL> def get_plugin_interface ( cls ) : <EOL> return BGPVPNPluginBase <EOL> def update_attributes_map ( self , attributes ) : <EOL> super ( Bgpvpn , self ) . update_attributes_map ( <EOL> attributes , extension_attrs_map = RESOURCE_ATTRIBUTE_MAP ) <EOL> def get_extended_resources ( self , version ) : <EOL> if version == "<STR_LIT>" : <EOL> return RESOURCE_ATTRIBUTE_MAP <EOL> else : <EOL> return { } <EOL> @ six . add_metaclass ( abc . ABCMeta ) <EOL> class BGPVPNPluginBase ( ServicePluginBase ) : <EOL> def get_plugin_name ( self ) : <EOL> return constants . BGPVPN <EOL> def get_plugin_type ( self ) : <EOL> return constants . BGPVPN <EOL> def get_plugin_description ( self ) : <EOL> return '<STR_LIT>' <EOL> @ abc . abstractmethod <EOL> def create_bgpvpn ( self , context , bgpvpn ) : <EOL> pass <EOL> @ abc . abstractmethod <EOL> def get_bgpvpns ( self , context , filters = None , fields = None ) : <EOL> pass <EOL> @ abc . abstractmethod <EOL> def get_bgpvpn ( self , context , id , fields = None ) : <EOL> pass <EOL> @ abc . abstractmethod <EOL> def update_bgpvpn ( self , context , id , bgpvpn ) : <EOL> pass <EOL> @ abc . abstractmethod <EOL> def delete_bgpvpn ( self , context , id ) : <EOL> pass <EOL> @ abc . abstractmethod <EOL> def create_bgpvpn_network_association ( self , context , bgpvpn_id , <EOL> network_association ) : <EOL> pass <EOL> @ abc . abstractmethod <EOL> def get_bgpvpn_network_association ( self , context , assoc_id , bgpvpn_id , <EOL> fields = None ) : <EOL> pass <EOL> @ abc . abstractmethod <EOL> def get_bgpvpn_network_associations ( self , context , bgpvpn_id , <EOL> filters = None , fields = None ) : <EOL> pass <EOL> @ abc . abstractmethod <EOL> def update_bgpvpn_network_association ( self , context , assoc_id , bgpvpn_id , <EOL> network_association ) : <EOL> pass <EOL> @ abc . abstractmethod <EOL> def delete_bgpvpn_network_association ( self , context , assoc_id , bgpvpn_id ) : <EOL> pass <EOL> @ abc . abstractmethod <EOL> def create_bgpvpn_router_association ( self , context , bgpvpn_id , <EOL> router_association ) : <EOL> pass <EOL> @ abc . abstractmethod <EOL> def get_bgpvpn_router_association ( self , context , assoc_id , bgpvpn_id , <EOL> fields = None ) : <EOL> pass <EOL> @ abc . abstractmethod <EOL> def get_bgpvpn_router_associations ( self , context , bgpvpn_id , filters = None , <EOL> fields = None ) : <EOL> pass <EOL> @ abc . abstractmethod <EOL> def delete_bgpvpn_router_association ( self , context , assoc_id , bgpvpn_id ) : <EOL> pass </s>
