Loading src/device/service/drivers/openconfig/OpenConfigDriver.py +1 −4 Original line number Diff line number Diff line Loading @@ -227,11 +227,8 @@ 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_messages = compose_config( # get template for configuration resource_key, resource_value, delete=delete, vendor=netconf_handler.vendor, message_renderer='pyangbind') # str_config_messages = compose_config( # get template for configuration # resource_key, resource_value, delete=delete, vendor=netconf_handler.vendor, message_renderer=netconf_handler.message_renderer) resource_key, resource_value, delete=delete, vendor=netconf_handler.vendor, message_renderer=netconf_handler.message_renderer) for str_config_message in str_config_messages: # configuration of the received templates if str_config_message is None: raise UnsupportedResourceKeyException(resource_key) logger.debug('[{:s}] str_config_message[{:d}] = {:s}'.format( Loading src/device/service/drivers/openconfig/templates/__init__.py +1 −1 Original line number Diff line number Diff line Loading @@ -121,7 +121,7 @@ def compose_config( # template generation 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' operation = 'delete' if delete else '' return [ '<config>{:s}</config>'.format( Loading src/device/service/drivers/openconfig/templates/interface/subinterface/edit_config.xml +0 −13 Original line number Diff line number Diff line Loading @@ -30,19 +30,6 @@ </match> </vlan> {% endif %} {% if address_ip is defined %} <oc-ip:ipv4> <oc-ip:addresses> <oc-ip:address> <oc-ip:ip>{{address_ip}}</oc-ip:ip> <oc-ip:config> <oc-ip:ip>{{address_ip}}</oc-ip:ip> <oc-ip:prefix-length>{{address_prefix}}</oc-ip:prefix-length> </oc-ip:config> </oc-ip:address> </oc-ip:addresses> </oc-ip:ipv4> {% endif %} </subinterface> </subinterfaces> {% endif %} Loading src/device/service/drivers/openconfig/templates/network_instance/interface/edit_config.xml +34 −0 Original line number Diff line number Diff line <network-instances xmlns="http://openconfig.net/yang/network-instance"> <network-instance> <name>{{name}}</name> <config> <name>{{name}}</name> <type xmlns:oc-ni-types="http://openconfig.net/yang/network-instance-types">oc-ni-types:L3VRF</type> </config> <interfaces> <interface{% if operation is defined %} xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="{{operation}}"{% endif %}> <id>{{id}}</id> Loading @@ -13,3 +17,33 @@ </interfaces> </network-instance> </network-instances> <interfaces xmlns="http://openconfig.net/yang/interfaces"> <interface> <name>{{interface}}</name> <config> <name>{{interface}}</name> </config> <subinterfaces> <subinterface> <index>{{subinterface}}</index> <config> <index>{{subinterface}}</index> </config> <ipv4 xmlns="http://openconfig.net/yang/interfaces/ip"> <config> <mtu>1500</mtu> </config> <addresses> <address> <ip>{{address_ip}}</ip> <config> <ip>{{address_ip}}</ip> <prefix-length>{{address_prefix}}</prefix-length> </config> </address> </addresses> </ipv4> </subinterface> </subinterfaces> </interface> </interfaces> src/device/service/drivers/openconfig/templates/network_instance/protocols/edit_config.xml +22 −0 Original line number Diff line number Diff line Loading @@ -9,15 +9,37 @@ <config> <identifier xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:{{identifier}}</identifier> <name>{{protocol_name}}</name> <enabled>true</enabled> </config> {% if identifier=='BGP' %} <bgp> <name>{{as}}</name> <global> <config> <as>{{as}}</as> <router-id>{{router_id}}</router-id> </config> </global> {% if neighbors is defined %} <neighbors> {% for neighbor in neighbors %} <neighbor> <neighbor-address>{{neighbor['ip_address']}}</neighbor-address> <afi-safis> <afi-safi xmlns:oc-bgp-types="http://openconfig.net/yang/bgp-types"> <afi-safi-name>oc-bgp-types:IPV4_UNICAST</afi-safi-name> <enabled>true</enabled> </afi-safi> </afi-safis> <config> <neighbor-address>{{neighbor['ip_address']}}</neighbor-address> <enabled>true</enabled> <peer-as>{{as}}</peer-as> </config> </neighbor> {% endfor %} </neighbors> {% endif %} </bgp> {% endif %} {% endif %} Loading Loading
src/device/service/drivers/openconfig/OpenConfigDriver.py +1 −4 Original line number Diff line number Diff line Loading @@ -227,11 +227,8 @@ 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_messages = compose_config( # get template for configuration resource_key, resource_value, delete=delete, vendor=netconf_handler.vendor, message_renderer='pyangbind') # str_config_messages = compose_config( # get template for configuration # resource_key, resource_value, delete=delete, vendor=netconf_handler.vendor, message_renderer=netconf_handler.message_renderer) resource_key, resource_value, delete=delete, vendor=netconf_handler.vendor, message_renderer=netconf_handler.message_renderer) for str_config_message in str_config_messages: # configuration of the received templates if str_config_message is None: raise UnsupportedResourceKeyException(resource_key) logger.debug('[{:s}] str_config_message[{:d}] = {:s}'.format( Loading
src/device/service/drivers/openconfig/templates/__init__.py +1 −1 Original line number Diff line number Diff line Loading @@ -121,7 +121,7 @@ def compose_config( # template generation 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' operation = 'delete' if delete else '' return [ '<config>{:s}</config>'.format( Loading
src/device/service/drivers/openconfig/templates/interface/subinterface/edit_config.xml +0 −13 Original line number Diff line number Diff line Loading @@ -30,19 +30,6 @@ </match> </vlan> {% endif %} {% if address_ip is defined %} <oc-ip:ipv4> <oc-ip:addresses> <oc-ip:address> <oc-ip:ip>{{address_ip}}</oc-ip:ip> <oc-ip:config> <oc-ip:ip>{{address_ip}}</oc-ip:ip> <oc-ip:prefix-length>{{address_prefix}}</oc-ip:prefix-length> </oc-ip:config> </oc-ip:address> </oc-ip:addresses> </oc-ip:ipv4> {% endif %} </subinterface> </subinterfaces> {% endif %} Loading
src/device/service/drivers/openconfig/templates/network_instance/interface/edit_config.xml +34 −0 Original line number Diff line number Diff line <network-instances xmlns="http://openconfig.net/yang/network-instance"> <network-instance> <name>{{name}}</name> <config> <name>{{name}}</name> <type xmlns:oc-ni-types="http://openconfig.net/yang/network-instance-types">oc-ni-types:L3VRF</type> </config> <interfaces> <interface{% if operation is defined %} xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="{{operation}}"{% endif %}> <id>{{id}}</id> Loading @@ -13,3 +17,33 @@ </interfaces> </network-instance> </network-instances> <interfaces xmlns="http://openconfig.net/yang/interfaces"> <interface> <name>{{interface}}</name> <config> <name>{{interface}}</name> </config> <subinterfaces> <subinterface> <index>{{subinterface}}</index> <config> <index>{{subinterface}}</index> </config> <ipv4 xmlns="http://openconfig.net/yang/interfaces/ip"> <config> <mtu>1500</mtu> </config> <addresses> <address> <ip>{{address_ip}}</ip> <config> <ip>{{address_ip}}</ip> <prefix-length>{{address_prefix}}</prefix-length> </config> </address> </addresses> </ipv4> </subinterface> </subinterfaces> </interface> </interfaces>
src/device/service/drivers/openconfig/templates/network_instance/protocols/edit_config.xml +22 −0 Original line number Diff line number Diff line Loading @@ -9,15 +9,37 @@ <config> <identifier xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:{{identifier}}</identifier> <name>{{protocol_name}}</name> <enabled>true</enabled> </config> {% if identifier=='BGP' %} <bgp> <name>{{as}}</name> <global> <config> <as>{{as}}</as> <router-id>{{router_id}}</router-id> </config> </global> {% if neighbors is defined %} <neighbors> {% for neighbor in neighbors %} <neighbor> <neighbor-address>{{neighbor['ip_address']}}</neighbor-address> <afi-safis> <afi-safi xmlns:oc-bgp-types="http://openconfig.net/yang/bgp-types"> <afi-safi-name>oc-bgp-types:IPV4_UNICAST</afi-safi-name> <enabled>true</enabled> </afi-safi> </afi-safis> <config> <neighbor-address>{{neighbor['ip_address']}}</neighbor-address> <enabled>true</enabled> <peer-as>{{as}}</peer-as> </config> </neighbor> {% endfor %} </neighbors> {% endif %} </bgp> {% endif %} {% endif %} Loading