Loading proto/acl.proto +1 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ message AclMatch { uint32 dst_port = 6; uint32 start_mpls_label = 7; uint32 end_mpls_label = 8; string tcp_flags = 9; } message AclAction { Loading src/common/Constants.py +1 −1 Original line number Diff line number Diff line Loading @@ -61,7 +61,7 @@ class ServiceNameEnum(Enum): CACHING = 'caching' TE = 'te' FORECASTER = 'forecaster' E2EORCHESTRATOR = 'e2eorchestrator' E2EORCHESTRATOR = 'e2e-orchestrator' OPTICALCONTROLLER = 'opticalcontroller' BGPLS = 'bgpls-speaker' Loading src/common/Settings.py +3 −2 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. import logging, os, time import logging, os, re, time from typing import Dict, List from common.Constants import ( DEFAULT_GRPC_BIND_ADDRESS, DEFAULT_GRPC_GRACE_PERIOD, DEFAULT_GRPC_MAX_WORKERS, DEFAULT_HTTP_BIND_ADDRESS, Loading Loading @@ -68,7 +68,8 @@ def get_setting(name, **kwargs): raise Exception('Setting({:s}) not specified in environment or configuration'.format(str(name))) def get_env_var_name(service_name : ServiceNameEnum, env_var_group): return ('{:s}SERVICE_{:s}'.format(service_name.value, env_var_group)).upper() service_name = re.sub(r'[^a-zA-Z0-9]', '_', service_name.value) return ('{:s}SERVICE_{:s}'.format(service_name, env_var_group)).upper() def get_service_host(service_name : ServiceNameEnum): envvar_name = get_env_var_name(service_name, ENVVAR_SUFIX_SERVICE_HOST) Loading src/device/requirements.in +1 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ Flask==2.1.3 Flask-HTTPAuth==4.5.0 Flask-RESTful==0.3.9 Jinja2==3.0.3 numpy<2.0.0 ncclient==0.6.15 p4runtime==1.3.0 pandas==1.5.* Loading src/device/service/drivers/openconfig/templates/__init__.py +28 −8 Original line number Diff line number Diff line Loading @@ -27,6 +27,9 @@ from .NetworkInstances import parse as parse_network_instances from .RoutingPolicy import parse as parse_routing_policy from .Acl import parse as parse_acl from .Inventory import parse as parse_inventory from .acl.acl_adapter import acl_cr_to_dict from .acl.acl_adapter_ipinfusion_proprietary import acl_cr_to_dict_ipinfusion_proprietary LOGGER = logging.getLogger(__name__) ALL_RESOURCE_KEYS = [ Loading Loading @@ -113,14 +116,31 @@ def compose_config( # template generation elif (message_renderer == "jinja"): templates = [] if "acl_ruleset" in resource_key: # MANAGING ACLs if vendor == 'ipinfusion': # ipinfusion proprietary netconf receipe is used temporarily enable_ingress_filter_path = 'acl/interfaces/ingress/enable_ingress_filter.xml' acl_entry_path = 'acl/acl-set/acl-entry/edit_config_ipinfusion_proprietary.xml' acl_ingress_path = 'acl/interfaces/ingress/edit_config_ipinfusion_proprietary.xml' data : Dict[str, Any] = acl_cr_to_dict_ipinfusion_proprietary(resource_value, delete=delete) else: enable_ingress_filter_path = 'acl/interfaces/ingress/enable_ingress_filter.xml' acl_entry_path = 'acl/acl-set/acl-entry/edit_config.xml' acl_ingress_path = 'acl/interfaces/ingress/edit_config.xml' data : Dict[str, Any] = acl_cr_to_dict(resource_value, delete=delete) if delete: # unpair acl and interface before removing acl templates.append(JINJA_ENV.get_template(acl_ingress_path)) templates.append(JINJA_ENV.get_template(acl_entry_path)) templates.append(JINJA_ENV.get_template(enable_ingress_filter_path)) else: templates.append(JINJA_ENV.get_template(enable_ingress_filter_path)) templates.append(JINJA_ENV.get_template(acl_entry_path)) templates.append(JINJA_ENV.get_template(acl_ingress_path)) else: template_name = '{:s}/edit_config.xml'.format(RE_REMOVE_FILTERS.sub('', resource_key)) templates.append(JINJA_ENV.get_template(template_name)) if "acl_ruleset" in resource_key: # MANAGING ACLs templates =[] templates.append(JINJA_ENV.get_template('acl/acl-set/acl-entry/edit_config.xml')) templates.append(JINJA_ENV.get_template('acl/interfaces/ingress/edit_config.xml')) data : Dict[str, Any] = json.loads(resource_value) operation = 'delete' if delete else 'merge' # others #operation = 'delete' if delete else '' # ipinfusion? Loading Loading
proto/acl.proto +1 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ message AclMatch { uint32 dst_port = 6; uint32 start_mpls_label = 7; uint32 end_mpls_label = 8; string tcp_flags = 9; } message AclAction { Loading
src/common/Constants.py +1 −1 Original line number Diff line number Diff line Loading @@ -61,7 +61,7 @@ class ServiceNameEnum(Enum): CACHING = 'caching' TE = 'te' FORECASTER = 'forecaster' E2EORCHESTRATOR = 'e2eorchestrator' E2EORCHESTRATOR = 'e2e-orchestrator' OPTICALCONTROLLER = 'opticalcontroller' BGPLS = 'bgpls-speaker' Loading
src/common/Settings.py +3 −2 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. import logging, os, time import logging, os, re, time from typing import Dict, List from common.Constants import ( DEFAULT_GRPC_BIND_ADDRESS, DEFAULT_GRPC_GRACE_PERIOD, DEFAULT_GRPC_MAX_WORKERS, DEFAULT_HTTP_BIND_ADDRESS, Loading Loading @@ -68,7 +68,8 @@ def get_setting(name, **kwargs): raise Exception('Setting({:s}) not specified in environment or configuration'.format(str(name))) def get_env_var_name(service_name : ServiceNameEnum, env_var_group): return ('{:s}SERVICE_{:s}'.format(service_name.value, env_var_group)).upper() service_name = re.sub(r'[^a-zA-Z0-9]', '_', service_name.value) return ('{:s}SERVICE_{:s}'.format(service_name, env_var_group)).upper() def get_service_host(service_name : ServiceNameEnum): envvar_name = get_env_var_name(service_name, ENVVAR_SUFIX_SERVICE_HOST) Loading
src/device/requirements.in +1 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ Flask==2.1.3 Flask-HTTPAuth==4.5.0 Flask-RESTful==0.3.9 Jinja2==3.0.3 numpy<2.0.0 ncclient==0.6.15 p4runtime==1.3.0 pandas==1.5.* Loading
src/device/service/drivers/openconfig/templates/__init__.py +28 −8 Original line number Diff line number Diff line Loading @@ -27,6 +27,9 @@ from .NetworkInstances import parse as parse_network_instances from .RoutingPolicy import parse as parse_routing_policy from .Acl import parse as parse_acl from .Inventory import parse as parse_inventory from .acl.acl_adapter import acl_cr_to_dict from .acl.acl_adapter_ipinfusion_proprietary import acl_cr_to_dict_ipinfusion_proprietary LOGGER = logging.getLogger(__name__) ALL_RESOURCE_KEYS = [ Loading Loading @@ -113,14 +116,31 @@ def compose_config( # template generation elif (message_renderer == "jinja"): templates = [] if "acl_ruleset" in resource_key: # MANAGING ACLs if vendor == 'ipinfusion': # ipinfusion proprietary netconf receipe is used temporarily enable_ingress_filter_path = 'acl/interfaces/ingress/enable_ingress_filter.xml' acl_entry_path = 'acl/acl-set/acl-entry/edit_config_ipinfusion_proprietary.xml' acl_ingress_path = 'acl/interfaces/ingress/edit_config_ipinfusion_proprietary.xml' data : Dict[str, Any] = acl_cr_to_dict_ipinfusion_proprietary(resource_value, delete=delete) else: enable_ingress_filter_path = 'acl/interfaces/ingress/enable_ingress_filter.xml' acl_entry_path = 'acl/acl-set/acl-entry/edit_config.xml' acl_ingress_path = 'acl/interfaces/ingress/edit_config.xml' data : Dict[str, Any] = acl_cr_to_dict(resource_value, delete=delete) if delete: # unpair acl and interface before removing acl templates.append(JINJA_ENV.get_template(acl_ingress_path)) templates.append(JINJA_ENV.get_template(acl_entry_path)) templates.append(JINJA_ENV.get_template(enable_ingress_filter_path)) else: templates.append(JINJA_ENV.get_template(enable_ingress_filter_path)) templates.append(JINJA_ENV.get_template(acl_entry_path)) templates.append(JINJA_ENV.get_template(acl_ingress_path)) else: template_name = '{:s}/edit_config.xml'.format(RE_REMOVE_FILTERS.sub('', resource_key)) templates.append(JINJA_ENV.get_template(template_name)) if "acl_ruleset" in resource_key: # MANAGING ACLs templates =[] templates.append(JINJA_ENV.get_template('acl/acl-set/acl-entry/edit_config.xml')) templates.append(JINJA_ENV.get_template('acl/interfaces/ingress/edit_config.xml')) data : Dict[str, Any] = json.loads(resource_value) operation = 'delete' if delete else 'merge' # others #operation = 'delete' if delete else '' # ipinfusion? Loading