Loading src/device/service/drivers/openconfig/OpenConfigDriver.py +5 −1 Original line number Diff line number Diff line Loading @@ -61,6 +61,7 @@ class NetconfSessionHandler: self.__port = int(port) self.__username = settings.get('username') self.__password = settings.get('password') self.__vendor =settings.get('vendor') self.__key_filename = settings.get('key_filename') self.__hostkey_verify = settings.get('hostkey_verify', True) self.__look_for_keys = settings.get('look_for_keys', True) Loading Loading @@ -94,6 +95,9 @@ class NetconfSessionHandler: @property def commit_per_rule(self): return self.__commit_per_delete @property def vendor(self): return self.__vendor @RETRY_DECORATOR def get(self, filter=None, with_defaults=None): # pylint: disable=redefined-builtin with self.__lock: Loading Loading @@ -199,7 +203,7 @@ def edit_config( chk_length(str_resource_name, resource, min_length=2, max_length=2) resource_key,resource_value = resource chk_string(str_resource_name + '.key', resource_key, allow_empty=False) str_config_message = compose_config(resource_key, resource_value, delete=delete) str_config_message = compose_config(resource_key, resource_value, delete=delete,vendor=netconf_handler.vendor) if str_config_message is None: raise UnsupportedResourceKeyException(resource_key) LOGGER.info('[{:s}] str_config_message[{:d}] = {:s}'.format( str_method, len(str_config_message), str(str_config_message))) Loading src/device/service/drivers/openconfig/templates/__init__.py +3 −3 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ # limitations under the License. import json, logging, lxml.etree as ET, re from typing import Any, Dict from typing import Any, Dict, Optional from jinja2 import Environment, PackageLoader, select_autoescape from device.service.driver_api._Driver import ( RESOURCE_ENDPOINTS, RESOURCE_INTERFACES, RESOURCE_NETWORK_INSTANCES, RESOURCE_ROUTING_POLICIES, RESOURCE_ACL) Loading Loading @@ -77,9 +77,9 @@ def parse(resource_key : str, xml_data : ET.Element): if parser is None: return [(resource_key, xml_data)] return parser(xml_data) def compose_config(resource_key : str, resource_value : str, delete : bool = False) -> str: def compose_config(resource_key : str, resource_value : str, delete : bool = False,vendor : Optional[str] = None) -> str: template_name = '{:s}/edit_config.xml'.format(RE_REMOVE_FILTERS.sub('', resource_key)) template = JINJA_ENV.get_template(template_name) data : Dict[str, Any] = json.loads(resource_value) operation = 'delete' if delete else 'merge' return '<config>{:s}</config>'.format(template.render(**data, operation=operation).strip()) return '<config>{:s}</config>'.format(template.render(**data, operation=operation, vendor=vendor).strip()) src/device/service/drivers/openconfig/templates/interface/subinterface/edit_config.xml +1 −1 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ <config> <index>{{index}}</index> <description>{{description}}</description> {% if vlan_id is not defined %} {% if vendor=="ADVA" and vlan_id is not defined %} <untagged-allowed xmlns="http://www.advaoptical.com/cim/adva-dnos-oc-interfaces">true</untagged-allowed> {% endif%} </config> Loading Loading
src/device/service/drivers/openconfig/OpenConfigDriver.py +5 −1 Original line number Diff line number Diff line Loading @@ -61,6 +61,7 @@ class NetconfSessionHandler: self.__port = int(port) self.__username = settings.get('username') self.__password = settings.get('password') self.__vendor =settings.get('vendor') self.__key_filename = settings.get('key_filename') self.__hostkey_verify = settings.get('hostkey_verify', True) self.__look_for_keys = settings.get('look_for_keys', True) Loading Loading @@ -94,6 +95,9 @@ class NetconfSessionHandler: @property def commit_per_rule(self): return self.__commit_per_delete @property def vendor(self): return self.__vendor @RETRY_DECORATOR def get(self, filter=None, with_defaults=None): # pylint: disable=redefined-builtin with self.__lock: Loading Loading @@ -199,7 +203,7 @@ def edit_config( chk_length(str_resource_name, resource, min_length=2, max_length=2) resource_key,resource_value = resource chk_string(str_resource_name + '.key', resource_key, allow_empty=False) str_config_message = compose_config(resource_key, resource_value, delete=delete) str_config_message = compose_config(resource_key, resource_value, delete=delete,vendor=netconf_handler.vendor) if str_config_message is None: raise UnsupportedResourceKeyException(resource_key) LOGGER.info('[{:s}] str_config_message[{:d}] = {:s}'.format( str_method, len(str_config_message), str(str_config_message))) Loading
src/device/service/drivers/openconfig/templates/__init__.py +3 −3 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ # limitations under the License. import json, logging, lxml.etree as ET, re from typing import Any, Dict from typing import Any, Dict, Optional from jinja2 import Environment, PackageLoader, select_autoescape from device.service.driver_api._Driver import ( RESOURCE_ENDPOINTS, RESOURCE_INTERFACES, RESOURCE_NETWORK_INSTANCES, RESOURCE_ROUTING_POLICIES, RESOURCE_ACL) Loading Loading @@ -77,9 +77,9 @@ def parse(resource_key : str, xml_data : ET.Element): if parser is None: return [(resource_key, xml_data)] return parser(xml_data) def compose_config(resource_key : str, resource_value : str, delete : bool = False) -> str: def compose_config(resource_key : str, resource_value : str, delete : bool = False,vendor : Optional[str] = None) -> str: template_name = '{:s}/edit_config.xml'.format(RE_REMOVE_FILTERS.sub('', resource_key)) template = JINJA_ENV.get_template(template_name) data : Dict[str, Any] = json.loads(resource_value) operation = 'delete' if delete else 'merge' return '<config>{:s}</config>'.format(template.render(**data, operation=operation).strip()) return '<config>{:s}</config>'.format(template.render(**data, operation=operation, vendor=vendor).strip())
src/device/service/drivers/openconfig/templates/interface/subinterface/edit_config.xml +1 −1 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ <config> <index>{{index}}</index> <description>{{description}}</description> {% if vlan_id is not defined %} {% if vendor=="ADVA" and vlan_id is not defined %} <untagged-allowed xmlns="http://www.advaoptical.com/cim/adva-dnos-oc-interfaces">true</untagged-allowed> {% endif%} </config> Loading