Loading src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/Constants.py +3 −1 Original line number Diff line number Diff line Loading @@ -14,6 +14,8 @@ DEFAULT_MTU = 1512 DEFAULT_ADDRESS_FAMILIES = ['IPV4'] DEFAULT_BGP_AS = 65000 DEFAULT_BGP_ROUTE_TARGET = '{:d}:{:d}'.format(DEFAULT_BGP_AS, 333) # Bearer mappings: # device_uuid:endpoint_uuid => ( Loading src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/L2VPN_SiteNetworkAccesses.py +19 −6 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ from .schemas.site_network_access import SCHEMA_SITE_NETWORK_ACCESS from .tools.Authentication import HTTP_AUTH from .tools.HttpStatusCodes import HTTP_NOCONTENT, HTTP_SERVERERROR from .tools.Validator import validate_message from .Constants import BEARER_MAPPINGS, DEFAULT_ADDRESS_FAMILIES, DEFAULT_MTU from .Constants import BEARER_MAPPINGS, DEFAULT_ADDRESS_FAMILIES, DEFAULT_BGP_AS, DEFAULT_BGP_ROUTE_TARGET, DEFAULT_MTU LOGGER = logging.getLogger(__name__) Loading Loading @@ -64,7 +64,7 @@ def process_site_network_access(context_client : ContextClient, site_network_acc endpoint_id.endpoint_uuid.uuid = endpoint_uuid for config_rule in service.service_config.config_rules: # pylint: disable=no-member if config_rule.resource_key != 'settings': continue if config_rule.resource_key != '/settings': continue json_settings = json.loads(config_rule.resource_value) if 'mtu' not in json_settings: # missing, add it Loading @@ -79,19 +79,33 @@ def process_site_network_access(context_client : ContextClient, site_network_acc msg = 'Specified AddressFamilies({:s}) differs from Service AddressFamilies({:s})' raise Exception(msg.format(str(json_settings['address_families']), str(DEFAULT_ADDRESS_FAMILIES))) if 'bgp_as' not in json_settings: # missing, add it json_settings['bgp_as'] = DEFAULT_BGP_AS elif json_settings['bgp_as'] != DEFAULT_BGP_AS: # differs, raise exception msg = 'Specified BgpAs({:s}) differs from Service BgpAs({:s})' raise Exception(msg.format(str(json_settings['bgp_as']), str(DEFAULT_BGP_AS))) if 'bgp_route_target' not in json_settings: # missing, add it json_settings['bgp_route_target'] = DEFAULT_BGP_ROUTE_TARGET elif json_settings['bgp_route_target'] != DEFAULT_BGP_ROUTE_TARGET: # differs, raise exception msg = 'Specified BgpRouteTarget({:s}) differs from Service BgpRouteTarget({:s})' raise Exception(msg.format(str(json_settings['bgp_route_target']), str(DEFAULT_BGP_ROUTE_TARGET))) config_rule.resource_value = json.dumps(json_settings, sort_keys=True) break else: # not found, add it config_rule = service.service_config.config_rules.add() # pylint: disable=no-member config_rule.action = ConfigActionEnum.CONFIGACTION_SET config_rule.resource_key = 'settings' config_rule.resource_key = '/settings' config_rule.resource_value = json.dumps({ 'mtu' : DEFAULT_MTU, 'address_families': DEFAULT_ADDRESS_FAMILIES, 'bgp_as' : DEFAULT_BGP_AS, 'bgp_route_target': DEFAULT_BGP_ROUTE_TARGET, }, sort_keys=True) endpoint_settings_key = 'device[{:s}]/endpoint[{:s}]/settings'.format(device_uuid, endpoint_uuid) endpoint_settings_key = '/device[{:s}]/endpoint[{:s}]/settings'.format(device_uuid, endpoint_uuid) for config_rule in service.service_config.config_rules: # pylint: disable=no-member if config_rule.resource_key != endpoint_settings_key: continue json_settings = json.loads(config_rule.resource_value) Loading Loading @@ -150,7 +164,6 @@ def process_site_network_access(context_client : ContextClient, site_network_acc 'vlan_id': cvlan_id, 'address_ip': address_ip, 'address_prefix': address_prefix, }, sort_keys=True) return service Loading Loading
src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/Constants.py +3 −1 Original line number Diff line number Diff line Loading @@ -14,6 +14,8 @@ DEFAULT_MTU = 1512 DEFAULT_ADDRESS_FAMILIES = ['IPV4'] DEFAULT_BGP_AS = 65000 DEFAULT_BGP_ROUTE_TARGET = '{:d}:{:d}'.format(DEFAULT_BGP_AS, 333) # Bearer mappings: # device_uuid:endpoint_uuid => ( Loading
src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/L2VPN_SiteNetworkAccesses.py +19 −6 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ from .schemas.site_network_access import SCHEMA_SITE_NETWORK_ACCESS from .tools.Authentication import HTTP_AUTH from .tools.HttpStatusCodes import HTTP_NOCONTENT, HTTP_SERVERERROR from .tools.Validator import validate_message from .Constants import BEARER_MAPPINGS, DEFAULT_ADDRESS_FAMILIES, DEFAULT_MTU from .Constants import BEARER_MAPPINGS, DEFAULT_ADDRESS_FAMILIES, DEFAULT_BGP_AS, DEFAULT_BGP_ROUTE_TARGET, DEFAULT_MTU LOGGER = logging.getLogger(__name__) Loading Loading @@ -64,7 +64,7 @@ def process_site_network_access(context_client : ContextClient, site_network_acc endpoint_id.endpoint_uuid.uuid = endpoint_uuid for config_rule in service.service_config.config_rules: # pylint: disable=no-member if config_rule.resource_key != 'settings': continue if config_rule.resource_key != '/settings': continue json_settings = json.loads(config_rule.resource_value) if 'mtu' not in json_settings: # missing, add it Loading @@ -79,19 +79,33 @@ def process_site_network_access(context_client : ContextClient, site_network_acc msg = 'Specified AddressFamilies({:s}) differs from Service AddressFamilies({:s})' raise Exception(msg.format(str(json_settings['address_families']), str(DEFAULT_ADDRESS_FAMILIES))) if 'bgp_as' not in json_settings: # missing, add it json_settings['bgp_as'] = DEFAULT_BGP_AS elif json_settings['bgp_as'] != DEFAULT_BGP_AS: # differs, raise exception msg = 'Specified BgpAs({:s}) differs from Service BgpAs({:s})' raise Exception(msg.format(str(json_settings['bgp_as']), str(DEFAULT_BGP_AS))) if 'bgp_route_target' not in json_settings: # missing, add it json_settings['bgp_route_target'] = DEFAULT_BGP_ROUTE_TARGET elif json_settings['bgp_route_target'] != DEFAULT_BGP_ROUTE_TARGET: # differs, raise exception msg = 'Specified BgpRouteTarget({:s}) differs from Service BgpRouteTarget({:s})' raise Exception(msg.format(str(json_settings['bgp_route_target']), str(DEFAULT_BGP_ROUTE_TARGET))) config_rule.resource_value = json.dumps(json_settings, sort_keys=True) break else: # not found, add it config_rule = service.service_config.config_rules.add() # pylint: disable=no-member config_rule.action = ConfigActionEnum.CONFIGACTION_SET config_rule.resource_key = 'settings' config_rule.resource_key = '/settings' config_rule.resource_value = json.dumps({ 'mtu' : DEFAULT_MTU, 'address_families': DEFAULT_ADDRESS_FAMILIES, 'bgp_as' : DEFAULT_BGP_AS, 'bgp_route_target': DEFAULT_BGP_ROUTE_TARGET, }, sort_keys=True) endpoint_settings_key = 'device[{:s}]/endpoint[{:s}]/settings'.format(device_uuid, endpoint_uuid) endpoint_settings_key = '/device[{:s}]/endpoint[{:s}]/settings'.format(device_uuid, endpoint_uuid) for config_rule in service.service_config.config_rules: # pylint: disable=no-member if config_rule.resource_key != endpoint_settings_key: continue json_settings = json.loads(config_rule.resource_value) Loading Loading @@ -150,7 +164,6 @@ def process_site_network_access(context_client : ContextClient, site_network_acc 'vlan_id': cvlan_id, 'address_ip': address_ip, 'address_prefix': address_prefix, }, sort_keys=True) return service Loading