diff --git a/src/device/service/drivers/openconfig/templates/Interfaces.py b/src/device/service/drivers/openconfig/templates/Interfaces.py index 33f977524c6f65655fbe17f6d2d95a7cfc223967..da1bbd4837000cfcaf9d7cfc1165550addf46b4b 100644 --- a/src/device/service/drivers/openconfig/templates/Interfaces.py +++ b/src/device/service/drivers/openconfig/templates/Interfaces.py @@ -49,12 +49,13 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]: subinterface = {} add_value_from_tag(subinterface, 'name', interface_name) + add_value_from_tag(subinterface, 'mtu', interface_mtu) subinterface_index = xml_subinterface.find('oci:index', namespaces=NAMESPACES) if subinterface_index is None or subinterface_index.text is None: continue add_value_from_tag(subinterface, 'index', subinterface_index, cast=int) - vlan_id = xml_subinterface.find('ocv:vlan/ocv:config/ocv:vlan-id', namespaces=NAMESPACES) + vlan_id = xml_subinterface.find('ocv:vlan/ocv:match/ocv:single-tagged/ocv:config/ocv:vlan-id', namespaces=NAMESPACES) add_value_from_tag(subinterface, 'vlan_id', vlan_id, cast=int) # TODO: implement support for multiple IP addresses per subinterface diff --git a/src/device/service/drivers/openconfig/templates/NetworkInstances.py b/src/device/service/drivers/openconfig/templates/NetworkInstances.py index b091a0d206195a6c2ce94008628071cd9e30944f..0cd6bbfd3f6545693ae0525433a2bb8452d27418 100644 --- a/src/device/service/drivers/openconfig/templates/NetworkInstances.py +++ b/src/device/service/drivers/openconfig/templates/NetworkInstances.py @@ -39,10 +39,11 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]: add_value_from_tag(network_instance, 'name', ni_name) ni_type = xml_network_instance.find('ocni:config/ocni:type', namespaces=NAMESPACES) + ni_type.text = ni_type.text.replace('oc-ni-types:','') add_value_from_tag(network_instance, 'type', ni_type) - #ni_router_id = xml_network_instance.find('ocni:config/ocni:router-id', namespaces=NAMESPACES) - #add_value_from_tag(network_instance, 'router_id', ni_router_id) + ni_router_id = xml_network_instance.find('ocni:config/ocni:router-id', namespaces=NAMESPACES) + add_value_from_tag(network_instance, 'router_id', ni_router_id) ni_route_dist = xml_network_instance.find('ocni:config/ocni:route-distinguisher', namespaces=NAMESPACES) add_value_from_tag(network_instance, 'route_distinguisher', ni_route_dist) @@ -71,6 +72,8 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]: if protocol['identifier'] == 'BGP': bgp_as = xml_protocol.find('ocni:bgp/ocni:global/ocni:config/ocni:as', namespaces=NAMESPACES) add_value_from_tag(protocol, 'as', bgp_as, cast=int) + bgp_id = xml_protocol.find('ocni:bgp/ocni:global/ocni:config/ocni:router-id', namespaces=NAMESPACES) + add_value_from_tag(protocol, 'router_id', bgp_id) resource_key = '/network_instance[{:s}]/protocols[{:s}]'.format( network_instance['name'], protocol['identifier']) @@ -94,7 +97,7 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]: add_value_from_tag(table_connection, 'address_family', address_family, cast=lambda s: s.replace('oc-types:', '')) - default_import_policy = xml_table_connection.find('ocni:default-import-policy', namespaces=NAMESPACES) + default_import_policy = xml_table_connection.find('ocni:config/ocni:default-import-policy', namespaces=NAMESPACES) add_value_from_tag(table_connection, 'default_import_policy', default_import_policy) resource_key = '/network_instance[{:s}]/table_connections[{:s}][{:s}][{:s}]'.format( diff --git a/src/device/service/drivers/openconfig/templates/RoutingPolicy.py b/src/device/service/drivers/openconfig/templates/RoutingPolicy.py index 369732de3fe58c52a2e9ab2227899160d091ff68..068ca5430d9135e784dbe9a07f80d81472cbf5cc 100644 --- a/src/device/service/drivers/openconfig/templates/RoutingPolicy.py +++ b/src/device/service/drivers/openconfig/templates/RoutingPolicy.py @@ -74,7 +74,7 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]: resource_key = '/routing_policy/bgp_defined_set[{:s}]'.format(bgp_ext_community_set['ext_community_set_name']) response.append((resource_key, copy.deepcopy(bgp_ext_community_set))) - ext_community_member = xml_bgp_ext_community_set.find('ocbp:ext-community-member', namespaces=NAMESPACES) + ext_community_member = xml_bgp_ext_community_set.find('ocbp:config/ocbp:ext-community-member', namespaces=NAMESPACES) if ext_community_member is not None and ext_community_member.text is not None: add_value_from_tag(bgp_ext_community_set, 'ext_community_member', ext_community_member) diff --git a/src/device/service/drivers/openconfig/templates/interface/edit_config.xml b/src/device/service/drivers/openconfig/templates/interface/edit_config.xml index ff15d1d682ea910208237c32adcc93029fb036d8..4bc53ff1ddfbebbdcef2a0b4c37770210726676b 100644 --- a/src/device/service/drivers/openconfig/templates/interface/edit_config.xml +++ b/src/device/service/drivers/openconfig/templates/interface/edit_config.xml @@ -1,14 +1,12 @@ <interfaces xmlns="http://openconfig.net/yang/interfaces"> - <interface{% if operation is defined and operation != 'delete' %} xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="{{operation}}"{% endif %}> + <interface{% if operation is defined %} xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="{{operation}}"{% endif %}> <name>{{name}}</name> + {% if operation is defined and operation != 'delete' %} <config> <name>{{name}}</name> - {% if operation is defined and operation == 'delete' %} <description></description> - {% else %} - <description>{{description}}</description> <mtu>{{mtu}}</mtu> - {% endif %} </config> + {% endif %} </interface> </interfaces> diff --git a/src/device/service/drivers/openconfig/templates/interface/subinterface/edit_config.xml b/src/device/service/drivers/openconfig/templates/interface/subinterface/edit_config.xml index d266f819c41355ba8a30086415f2bba3b68f1f3d..f172c167672cf660c89393cf333fa3e9241655fb 100644 --- a/src/device/service/drivers/openconfig/templates/interface/subinterface/edit_config.xml +++ b/src/device/service/drivers/openconfig/templates/interface/subinterface/edit_config.xml @@ -1,37 +1,45 @@ -<interfaces xmlns="http://openconfig.net/yang/interfaces"> - <interface> - <name>{{name}}</name> - {% if operation is not defined or operation != 'delete' %} +<interfaces xmlns="http://openconfig.net/yang/interfaces" + xmlns:oc-ip="http://openconfig.net/yang/interfaces/ip" > + <interface> + <name>{{name}}</name> + <config> + <name>{{name}}</name> + <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:l3ipvlan</type> + <mtu>{{mtu}}</mtu> + <enabled>true</enabled> + </config> + <subinterfaces> + <subinterface> + <index>{{index}}</index> <config> - <name>{{name}}</name> + <index>{{index}}</index> + <description>{{description}}</description> </config> - {% endif %} - <subinterfaces> - <subinterface{% if operation is defined %} xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="{{operation}}"{% endif %}> - <index>{{index}}</index> - {% if operation is not defined or operation != 'delete' %} - <config> - <index>{{index}}</index> - <enabled>true</enabled> - </config> - <vlan xmlns="http://openconfig.net/yang/vlan"> - <config> - <vlan-id>{{vlan_id}}</vlan-id> - </config> - </vlan> - <ipv4 xmlns="http://openconfig.net/yang/interfaces/ip"> - <addresses> - <address> - <ip>{{address_ip}}</ip> - <config> - <ip>{{address_ip}}</ip> - <prefix-length>{{address_prefix}}</prefix-length> - </config> - </address> - </addresses> - </ipv4> - {% endif %} - </subinterface> - </subinterfaces> - </interface> + <vlan xmlns="http://openconfig.net/yang/vlan"> + <match> + <single-tagged> + <config> + <vlan-id>{{vlan_id}}</vlan-id> + </config> + </single-tagged> + </match> + </vlan> + <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> + + </subinterface> + </subinterfaces> + </interface> </interfaces> + + + diff --git a/src/device/service/drivers/openconfig/templates/network_instance/edit_config.xml b/src/device/service/drivers/openconfig/templates/network_instance/edit_config.xml index 9362c09c6cfebcd1f83b05002f58eda51724b911..74424cea948dc01c2bcf68538aafe674a9d336c5 100644 --- a/src/device/service/drivers/openconfig/templates/network_instance/edit_config.xml +++ b/src/device/service/drivers/openconfig/templates/network_instance/edit_config.xml @@ -5,7 +5,7 @@ <config> <name>{{name}}</name> <type xmlns:oc-ni-types="http://openconfig.net/yang/network-instance-types">oc-ni-types:{{type}}</type> - <description>{{description}}</description> + {% if description is defined %}<description>{{description}}</description>{% endif %} {% if router_id is defined %}<router-id>{{router_id}}</router-id>{% endif %} <route-distinguisher>{{route_distinguisher}}</route-distinguisher> <enabled>true</enabled> @@ -13,6 +13,7 @@ <encapsulation> <config> <encapsulation-type xmlns:oc-ni-types="http://openconfig.net/yang/network-instance-types">oc-ni-types:MPLS</encapsulation-type> + <label-allocation-mode xmlns:oc-ni-types="http://openconfig.net/yang/network-instance-types">oc-ni-types:INSTANCE_LABEL</label-allocation-mode> </config> </encapsulation> {% endif %} diff --git a/src/device/service/drivers/openconfig/templates/network_instance/interface/edit_config.xml b/src/device/service/drivers/openconfig/templates/network_instance/interface/edit_config.xml index d5c33d31a6d671216db55c0eded94dc15a56bec8..bf8c0c0770f9344fbed16f3a6b09f7fa99a978ef 100644 --- a/src/device/service/drivers/openconfig/templates/network_instance/interface/edit_config.xml +++ b/src/device/service/drivers/openconfig/templates/network_instance/interface/edit_config.xml @@ -2,15 +2,13 @@ <network-instance> <name>{{name}}</name> <interfaces> - <interface{% if operation is defined %} xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="{{operation}}"{% endif %}> + <interface> <id>{{id}}</id> - {% if operation is not defined or operation != 'delete' %} <config> <id>{{id}}</id> <interface>{{interface}}</interface> <subinterface>{{subinterface}}</subinterface> </config> - {% endif %} </interface> </interfaces> </network-instance> diff --git a/src/device/service/drivers/openconfig/templates/network_instance/protocols/edit_config.xml b/src/device/service/drivers/openconfig/templates/network_instance/protocols/edit_config.xml index da05d0467605e6cec0c3448cc325ff60dfc7cfc9..c9c068e480c0569cfe5f97b78b28fbe03e2595f8 100644 --- a/src/device/service/drivers/openconfig/templates/network_instance/protocols/edit_config.xml +++ b/src/device/service/drivers/openconfig/templates/network_instance/protocols/edit_config.xml @@ -3,19 +3,19 @@ <name>{{name}}</name> <protocols> <protocol{% if operation is defined %} xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="{{operation}}"{% endif %}> - <identifier>{{identifier}}</identifier> + <identifier xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:{{identifier}}</identifier> <name>{{protocol_name}}</name> {% if operation is not defined or operation != 'delete' %} <config> - <identifier>{{identifier}}</identifier> + <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> <global> <config> <as>{{as}}</as> + <router-id>{{router_id}}</router-id> </config> </global> </bgp> @@ -23,5 +23,18 @@ {% endif %} </protocol> </protocols> + {% if operation is not defined or operation != 'delete' %} + + <tables> + <table> + <protocol xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:{{identifier}}</protocol> + <address-family xmlns:oc-types="http://openconfig.net/yang/openconfig-types">oc-types:IPV4</address-family> + <config> + <protocol xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:{{identifier}}</protocol> + <address-family xmlns:oc-types="http://openconfig.net/yang/openconfig-types">oc-types:IPV4</address-family> + </config> + </table> + </tables> + {% endif %} </network-instance> </network-instances> diff --git a/src/device/service/drivers/openconfig/templates/routing_policy/bgp_defined_set/edit_config.xml b/src/device/service/drivers/openconfig/templates/routing_policy/bgp_defined_set/edit_config.xml index df64606ae5ab434e5e3453f7294db02bb749bdce..6843c2dcbd306b149a4168565447d11174eceadc 100644 --- a/src/device/service/drivers/openconfig/templates/routing_policy/bgp_defined_set/edit_config.xml +++ b/src/device/service/drivers/openconfig/templates/routing_policy/bgp_defined_set/edit_config.xml @@ -5,7 +5,10 @@ <ext-community-set{% if operation is defined %} xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="{{operation}}"{% endif %}> <ext-community-set-name>{{ext_community_set_name}}</ext-community-set-name> {% if operation is not defined or operation != 'delete' %} - {% if ext_community_member is defined %} <ext-community-member>{{ext_community_member}}</ext-community-member>{% endif %} + <config> + <ext-community-set-name>{{ext_community_set_name}}</ext-community-set-name> + <ext-community-member>{{ext_community_member}}</ext-community-member> + </config> {% endif %} </ext-community-set> </ext-community-sets> diff --git a/src/device/service/drivers/openconfig/templates/routing_policy/policy_definition/statement/edit_config.xml b/src/device/service/drivers/openconfig/templates/routing_policy/policy_definition/statement/edit_config.xml index 711067f424b68da0e69913ce01f5133c5cbbfe02..eda2d99c9f6299f7345767db8bed8e8cc58284ae 100644 --- a/src/device/service/drivers/openconfig/templates/routing_policy/policy_definition/statement/edit_config.xml +++ b/src/device/service/drivers/openconfig/templates/routing_policy/policy_definition/statement/edit_config.xml @@ -1,8 +1,11 @@ -{% if operation is not defined or operation != 'delete' %} <routing-policy xmlns="http://openconfig.net/yang/routing-policy"> <policy-definitions> - <policy-definition> + <policy-definition {% if operation is defined %} xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="{{operation}}"{% endif %}> <name>{{policy_name}}</name> + {% if operation is not defined or operation != 'delete' %} + <config> + <name>{{policy_name}}</name> + </config> <statements> <statement> <name>{{statement_name}}</name> @@ -10,11 +13,13 @@ <name>{{statement_name}}</name> </config> <conditions> + <config> + <install-protocol-eq xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:DIRECTLY_CONNECTED</install-protocol-eq> + </config> <bgp-conditions xmlns="http://openconfig.net/yang/bgp-policy"> - <match-ext-community-set> + <config> <ext-community-set>{{ext_community_set_name}}</ext-community-set> - <match-set-options>{{match_set_options}}</match-set-options> - </match-ext-community-set> + </config> </bgp-conditions> </conditions> <actions> @@ -24,7 +29,7 @@ </actions> </statement> </statements> + {% endif %} </policy-definition> </policy-definitions> </routing-policy> -{% endif %}