diff --git a/src/nbi/service/rest_server/nbi_plugins/ietf_hardware/YangHandler.py b/src/nbi/service/rest_server/nbi_plugins/ietf_hardware/YangHandler.py index 7662261e97b35958f036dc0e69913af7947b9403..0b857ab832a05c8523c743277947ff2b5ef8a6ff 100644 --- a/src/nbi/service/rest_server/nbi_plugins/ietf_hardware/YangHandler.py +++ b/src/nbi/service/rest_server/nbi_plugins/ietf_hardware/YangHandler.py @@ -12,21 +12,19 @@ # See the License for the specific language governing permissions and # limitations under the License. +import libyang, os from common.proto.context_pb2 import Device from typing import Dict, Optional -import datetime import json import logging -import libyang -import os import re +import datetime LOGGER = logging.getLogger(__name__) YANG_DIR = os.path.join(os.path.dirname(__file__), 'yang') YANG_MODULES = [ 'iana-hardware', - 'ietf-hardware', - 'ietf-network-hardware-inventory' + 'ietf-hardware' ] class YangHandler: @@ -37,7 +35,7 @@ class YangHandler: self._yang_context.load_module(yang_module_name).feature_enable_all() def parse_to_dict(self, message : Dict) -> Dict: - yang_module = self._yang_context.get_module('ietf-network-hardware-inventory') + yang_module = self._yang_context.get_module('ietf-hardware') dnode : Optional[libyang.DNode] = yang_module.parse_data_dict( message, validate_present=True, validate=True, strict=True ) @@ -79,7 +77,6 @@ class YangHandler: component_type = "module" if component_type == "FRU" : component_type = "slack" - component_type = component_type.replace("_", "-").lower() component_type = 'iana-hardware:' + component_type component_new.create_path('class', component_type) @@ -94,6 +91,7 @@ class YangHandler: break if attributes["mfg-date"] != "": mfg_date = self.convert_to_iso_date(attributes["mfg-date"]) + LOGGER.info('component[name="{:s}"]'.format(attributes["mfg-date"])) component_new.create_path('mfg-date', mfg_date) component_new.create_path('hardware-rev', attributes["hardware-rev"]) @@ -109,16 +107,8 @@ class YangHandler: component_new.create_path('is-fru', False) if attributes["id"]: - try: - if "CHASSIS" in component.type : - component_new.create_path('parent-rel-pos', 0) - else: - parent_rel_pos = int(attributes["id"].replace("\"", "")) - component_new.create_path('parent-rel-pos', parent_rel_pos) - except ValueError: - LOGGER.info('ERROR:{:s} '.format(component.name )) - continue - + component_new.create_path('parent-rel-pos', attributes["id"]) + component_new.create_path('uri', component.name) component_new.create_path('uuid', component.component_uuid.uuid) for child in device.components: diff --git a/src/nbi/service/rest_server/nbi_plugins/ietf_hardware/__init__.py b/src/nbi/service/rest_server/nbi_plugins/ietf_hardware/__init__.py index ba774650e89e26609573a364be520c2d1bd6df84..7a9eec50669b212ffdb2eebce0f7f6d66e88cd10 100644 --- a/src/nbi/service/rest_server/nbi_plugins/ietf_hardware/__init__.py +++ b/src/nbi/service/rest_server/nbi_plugins/ietf_hardware/__init__.py @@ -13,7 +13,6 @@ # limitations under the License. from nbi.service.rest_server.nbi_plugins.ietf_hardware.Hardware import Hardware -from nbi.service.rest_server.nbi_plugins.ietf_hardware.HardwareMultipleDevices import HardwareMultipleDevices from nbi.service.rest_server.RestServer import RestServer URL_PREFIX_DEVICE = "/restconf/data/device=/ietf-network-hardware-inventory:network-hardware-inventory" diff --git a/src/nbi/service/rest_server/nbi_plugins/ietf_hardware/yang/ietf-network-hardware-inventory@2023-03-09.yang b/src/nbi/service/rest_server/nbi_plugins/ietf_hardware/yang/ietf-network-hardware-inventory@2023-03-09.yang deleted file mode 100644 index e074e3005e97f9657f7ef23a39741d3ce4b912b8..0000000000000000000000000000000000000000 --- a/src/nbi/service/rest_server/nbi_plugins/ietf_hardware/yang/ietf-network-hardware-inventory@2023-03-09.yang +++ /dev/null @@ -1,604 +0,0 @@ -module ietf-network-hardware-inventory { - yang-version 1.1; - namespace - "urn:ietf:params:xml:ns:yang:ietf-network-hardware-inventory"; - prefix nhi; - - import ietf-yang-types { - prefix yang; - reference - "RFC6991: Common YANG Data Types."; - } - - import iana-hardware { - prefix ianahw; - reference - "https://www.iana.org/assignments/yang-parameters"; - } - - import ietf-inet-types { - prefix inet; - reference - "RFC6991: Common YANG Data Types."; - } - - organization - "IETF CCAMP Working Group"; - contact - "WG Web: - WG List: - - Editor: Chaode Yu - - - Editor: Italo Busi - - - Editor: Aihua Guo - - - Editor: Sergio Belotti - - - Editor: Jean-Francois Bouquier - - - Editor: Fabio Peruzzini - "; - - description - "This module defines a model for retrieving network hardware - inventory. - - The model fully conforms to the Network Management - Datastore Architecture (NMDA). - Copyright (c) 2022 IETF Trust and the persons - identified as authors of the code. All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, is permitted pursuant to, and subject - to the license terms contained in, the Revised BSD License - set forth in Section 4.c of the IETF Trust's Legal Provisions - Relating to IETF Documents - (https://trustee.ietf.org/license-info). - - This version of this YANG module is part of RFC XXXX; see - the RFC itself for full legal notices. - - The key words 'MUST', 'MUST NOT', 'REQUIRED', 'SHALL', 'SHALL - NOT', 'SHOULD', 'SHOULD NOT', 'RECOMMENDED', 'NOT RECOMMENDED', - 'MAY', and 'OPTIONAL' in this document are to be interpreted as - described in BCP 14 (RFC 2119) (RFC 8174) when, and only when, - they appear in all capitals, as shown here."; - - // RFC Ed.: replace XXXX with actual RFC number and remove this - // note. - // RFC Ed.: update the date below with the date of RFC publication - // and remove this note. - - revision 2023-03-09 { - description - "Initial version"; - reference - "RFC XXXX: A YANG Data Model for Network Hardware Inventory."; - //RFC Editor: replace XXXX with actual RFC number, update date - //information and remove this note - } - - container network-hardware-inventory { - config false; - description - "The top-level container for the network inventory - information."; - uses equipment-rooms-grouping; - uses network-elements-grouping; - } - - grouping common-entity-attributes { - description - "A set of attributes which are common to all the entities - (e.g., component, equipment room) defined in this module."; - leaf uuid { - type yang:uuid; - description - "Uniquely identifies an entity (e.g., component)."; - } - leaf name { - type string; - description - "A name for an entity (e.g., component), as specified by - a network manager, that provides a non-volatile 'handle' - for the entity and that can be modified anytime during the - entity lifetime. - - If no configured value exists, the server MAY set the value - of this node to a locally unique value in the operational - state."; - } - leaf description { - type string; - description "a textual description of inventory object"; - } - leaf alias { - type string; - description - "a alias name of inventory objects. This alias name can be - specified by network manager."; - } - } - - grouping network-elements-grouping { - description - "The attributes of the network elements."; - container network-elements { - description - "The container for the list of network elements."; - list network-element { - key uuid; - description - "The list of network elements within the network."; - uses common-entity-attributes; - container ne-location { - description - "The location information of this network element."; - leaf-list equipment-room-name { - type leafref { - path "/nhi:network-hardware-inventory/" + - "nhi:equipment-rooms/nhi:equipment-room/nhi:name"; - } - description - "Names of equipment rooms where the NE is located. - Please note that a NE could be located in several - equipment rooms."; - } - } - uses ne-specific-info-grouping; - uses components-grouping; - } - } - } - - grouping ne-specific-info-grouping { - description - "Attributes applicable to network elements."; - leaf hardware-rev { - type string; - description - "The vendor-specific hardware revision string for the NE."; - } - leaf software-rev { - type string; - description - "The vendor-specific software revision string for the NE."; - } - leaf mfg-name { - type string; - description "The name of the manufacturer of this NE"; - } - leaf mfg-date { - type yang:date-and-time; - description "The date of manufacturing of the NE."; - } - leaf part-number { - type string; - description - "The vendor-specific model name identifier string associated - with this NE. The preferred value is the customer-visible - part number, which may be printed on the NE itself."; - } - leaf serial-number { - type string; - description - "The vendor-specific serial number string for the NE"; - } - leaf product-name { - type string; - description - "indicates the vendor-spefic device type infomation."; - } - } - - grouping equipment-rooms-grouping { - description - "The attributes of the equipment rooms."; - container equipment-rooms { - description - "The container for the list of equipment rooms."; - list equipment-room { - key uuid; - description - "The list of equipment rooms within the network."; - uses common-entity-attributes; - leaf location { - type string; - description - "compared with the location information of the other - inventory objects, a GIS address is preferred for - equipment room"; - } - container racks { - description - "Top level container for the list of racks."; - list rack { - key uuid; - description - "The list of racks within an equipment room."; - uses common-entity-attributes; - uses rack-specific-info-grouping; - list contained-chassis { - key "ne-ref component-ref"; - description - "The list of chassis within a rack."; - leaf ne-ref { - type leafref { - path "/nhi:network-hardware-inventory" - + "/nhi:network-elements/nhi:network-element" - + "/nhi:uuid"; - } - description - "The reference to the network element containing - the chassis component."; - } - leaf component-ref { - type leafref { - path "/nhi:network-hardware-inventory" - + "/nhi:network-elements/nhi:network-element" - + "[nhi:uuid=current()/../ne-ref]/nhi:components" - + "/nhi:component/nhi:uuid"; - } - description - "The reference to the chassis component within - the network element and contained by the rack."; - } - leaf relative-position { - type uint8; - description "A relative position of chassis within - the rack"; - } - } - } - } - } - } - } - - grouping rack-specific-info-grouping { - description - "Attributes applicable to racks only."; - container rack-location { - description - "The location information of the rack, which comprises the - name of the equipment room, row number, and column number."; - leaf equipment-room-name { - type leafref { - path "/nhi:network-hardware-inventory/nhi:equipment-rooms" - + "/nhi:equipment-room/nhi:name"; - } - description - "Name of equipment room where this rack is located."; - } - leaf row-number { - type uint32; - description - "Identifies the row within the equipment room where - the rack is located."; - } - leaf column-number { - type uint32; - description - "Identifies the physical location of the rack within - the column."; - } - } - leaf height { - type uint16; - units millimeter; - description - "Rack height."; - } - leaf width { - type uint16; - units millimeter; - description - "Rack width."; - } - leaf depth { - type uint16; - units millimeter; - description - "Rack depth."; - } - leaf max-voltage { - type uint16; - units volt; - description - "The maximum voltage could be supported by the rack."; - } - } - - grouping components-grouping { - description - "The attributes of the hardware components."; - container components { - description - "The container for the list of components."; - list component { - key uuid; - description - "The list of components within a network element."; - uses common-entity-attributes; - leaf location { - type string; - description - "A relative location information of this component. - In optical transport network, the location string is - using the following pattern: - '/ne=[/r=][/sh= - [/s_sh= ...]][[/sl= - [/s_sl= ...]][/p= …]]' - "; - } - leaf class { - type identityref { - base ianahw:hardware-class; - } - description - "An indication of the general hardware type of the - component."; - reference - "RFC 8348: A YANG Data Model for Hardware Management."; - } - leaf-list contained-child { - type leafref { - path "../nhi:uuid"; - } - description - "The list of the identifiers of the child components - physically contained within this component."; - } - leaf parent-rel-pos { - type int32 { - range "0 .. 2147483647"; - } - description - "The relative position with respect to the parent - component among all the sibling components."; - reference - "RFC 6933: Entity MIB (Version 4) - - entPhysicalParentRelPos"; - } - - container parent-component-references { - description - "The top level container for the list of the - identifiers of the parents of this component in a - hierarchy."; - list component-reference { - key index; - description - "The list of the identifiers of the parents of this - component in a hierarchy. - - The index parameter defines the hierarchy: the topmost - parent has an index of 0."; - leaf index { - type uint8; - description - "The index of the parent with respect to the - hierarchy."; - } - leaf class { - type leafref { - path "../../../nhi:class"; - } - description - "Class of the hierarchial parent component."; - } - leaf uuid { - type leafref { - path "../../../nhi:uuid"; - } - description - "The identifier of the parent's component in the - hierarchy."; - } - } - } - - leaf hardware-rev { - type string; - description - "The vendor-specific hardware revision string for the - component. The preferred value is the hardware revision - identifier actually printed on the component itself (if - present)."; - reference - "RFC 6933: Entity MIB (Version 4) - - entPhysicalHardwareRev"; - } - leaf firmware-rev { - type string; - description - "The vendor-specific firmware revision string for the - component."; - reference - "RFC 6933: Entity MIB (Version 4) - - entPhysicalFirmwareRev"; - } - leaf software-rev { - type string; - description - "The vendor-specific software revision string for the - component."; - reference - "RFC 6933: Entity MIB (Version 4) - - entPhysicalSoftwareRev"; - } - leaf serial-num { - type string; - description - "The vendor-specific serial number string for the - component. The preferred value is the serial number - string actually printed on the component itself (if - present)."; - reference - "RFC 6933: Entity MIB (Version 4) - - entPhysicalSerialNum"; - } - leaf mfg-name { - type string; - description - "The name of the manufacturer of this physical component. - The preferred value is the manufacturer name string - actually printed on the component itself (if present). - - Note that comparisons between instances of the - 'model-name', 'firmware-rev', 'software-rev', and - 'serial-num' nodes are only meaningful amongst - components with the same value of 'mfg-name'. - - If the manufacturer name string associated with the - physical component is unknown to the server, then this - node is not instantiated."; - reference - "RFC 6933: Entity MIB (Version 4) - entPhysicalMfgName"; - } - leaf part-number { - type string; - description - "The vendor-specific model name identifier string - associated with this physical component. The preferred - value is the customer-visible part number, which may be - printed on the component itself. - - If the model name string associated with the physical - component is unknown to the server, then this node is - not instantiated."; - reference - "RFC 6933: Entity MIB (Version 4) - - entPhysicalModelName"; - } - leaf asset-id { - type string; - description - "This node is a user-assigned asset tracking identifier - for the component. - - A server implementation MAY map this leaf to the - entPhysicalAssetID MIB object. Such an implementation - needs to use some mechanism to handle the differences in - size and characters allowed between this leaf and - entPhysicalAssetID. The definition of such a mechanism - is outside the scope of this document."; - reference - "RFC 6933: Entity MIB (Version 4) - entPhysicalAssetID"; - } - leaf is-fru { - type boolean; - description - "This node indicates whether or not this component is - considered a 'field-replaceable unit' by the vendor. If - this node contains the value 'true', then this component - identifies a field-replaceable unit. For all components - that are permanently contained within a - field-replaceable unit, the value 'false' should be - returned for this node."; - reference - "RFC 6933: Entity MIB (Version 4) - entPhysicalIsFRU"; - } - leaf mfg-date { - type yang:date-and-time; - description - "The date of manufacturing of the managed component."; - reference - "RFC 6933: Entity MIB (Version 4) - entPhysicalMfgDate"; - } - leaf-list uri { - type inet:uri; - description - "This node contains identification information about the - component."; - reference - "RFC 6933: Entity MIB (Version 4) - entPhysicalUris"; - } - uses component-specific-info-grouping; - } - } - } - - grouping component-specific-info-grouping { - description - "In case if there are some missing attributes of component not - defined by RFC8348. These attributes could be - component-specific. - Here we provide a extension structure for all the components - we recognized. We will enrich these component specifc - containers in the future."; - choice component-class { - description - "This extension differs between different component - classes."; - case chassis { - when "./class = 'ianahw:chassis'"; - container chassis-specific-info { - description - "This container contains some attributes belong to - chassis only."; - uses chassis-specific-info-grouping; - } - } - case container { - when "./class = 'ianahw:container'"; - container slot-specific-info { - description - "This container contains some attributes belong to - slot or sub-slot only."; - uses slot-specific-info-grouping; - } - } - case module { - when "./nhi:class = 'ianahw:module'"; - container board-specific-info { - description - "This container contains some attributes belong to - board only."; - uses board-specific-info-grouping; - } - } - case port { - when "./nhi:class = 'ianahw:port'"; - container port-specific-info { - description - "This container contains some attributes belong to - port only."; - uses port-specific-info-grouping; - } - } - //TO BE ADDED: transceiver - } - } - - grouping chassis-specific-info-grouping { - //To be enriched in the future. - description - "Specific attributes applicable to chassis only."; - } - - grouping slot-specific-info-grouping { - //To be enriched in the future. - description - "Specific attributes applicable to slots only."; - } - - grouping board-specific-info-grouping { - //To be enriched in the future. - description - "Specific attributes applicable to boards only."; - } - - grouping port-specific-info-grouping { - //To be enriched in the future. - description - "Specific attributes applicable to ports only."; - } -} diff --git a/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/NameMapping.py b/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/NameMapping.py new file mode 100644 index 0000000000000000000000000000000000000000..94e4723a5c7ca83fb382bb70cb241cb69b66ce0e --- /dev/null +++ b/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/NameMapping.py @@ -0,0 +1,46 @@ +# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from typing import Dict, Tuple +from common.proto.context_pb2 import Device, DeviceId, EndPoint, EndPointId + +class NameMappings: + def __init__(self) -> None: + self._device_uuid_to_name : Dict[str, str] = dict() + self._endpoint_uuid_to_name : Dict[Tuple[str, str], str] = dict() + + def store_device_name(self, device : Device) -> None: + device_uuid = device.device_id.device_uuid.uuid + device_name = device.name + self._device_uuid_to_name[device_uuid] = device_name + self._device_uuid_to_name[device_name] = device_name + + def store_endpoint_name(self, device : Device, endpoint : EndPoint) -> None: + device_uuid = device.device_id.device_uuid.uuid + device_name = device.name + endpoint_uuid = endpoint.endpoint_id.endpoint_uuid.uuid + endpoint_name = endpoint.name + self._endpoint_uuid_to_name[(device_uuid, endpoint_uuid)] = endpoint_name + self._endpoint_uuid_to_name[(device_name, endpoint_uuid)] = endpoint_name + self._endpoint_uuid_to_name[(device_uuid, endpoint_name)] = endpoint_name + self._endpoint_uuid_to_name[(device_name, endpoint_name)] = endpoint_name + + def get_device_name(self, device_id : DeviceId) -> str: + device_uuid = device_id.device_uuid.uuid + return self._device_uuid_to_name.get(device_uuid, device_uuid) + + def get_endpoint_name(self, endpoint_id : EndPointId) -> str: + device_uuid = endpoint_id.device_id.device_uuid.uuid + endpoint_uuid = endpoint_id.endpoint_uuid.uuid + return self._endpoint_uuid_to_name.get((device_uuid, endpoint_uuid), endpoint_uuid) diff --git a/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/Networks.py b/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/Networks.py new file mode 100644 index 0000000000000000000000000000000000000000..fb97168ab58ad44c986509a03179dbce1de95eb4 --- /dev/null +++ b/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/Networks.py @@ -0,0 +1,63 @@ +# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import logging +from flask import request +from flask.json import jsonify +from flask_restful import Resource +from common.proto.context_pb2 import ContextId, Empty +from common.tools.context_queries.Topology import get_topology_details +from common.tools.object_factory.Context import json_context_id +from context.client.ContextClient import ContextClient +from nbi.service.rest_server.nbi_plugins.tools.Authentication import HTTP_AUTH +from nbi.service.rest_server.nbi_plugins.tools.HttpStatusCodes import HTTP_OK, HTTP_SERVERERROR +from .YangHandler import YangHandler + +LOGGER = logging.getLogger(__name__) + +class Networks(Resource): + @HTTP_AUTH.login_required + def get(self): + LOGGER.info(f'Request: {request}') + try: + context_client = ContextClient() + yang_handler = YangHandler() + network_list_reply = [] + + contexts = context_client.ListContexts(Empty()).contexts + context_names = [context.name for context in contexts] + LOGGER.info(f'Contexts detected: {context_names}') + + for context_name in context_names: + topologies = context_client.ListTopologies(ContextId(**json_context_id(context_name))).topologies + topology_names = [topology.name for topology in topologies] + LOGGER.info(f'Topologies detected for context {context_name}: {topology_names}') + + for topology_name in topology_names: + topology_details = get_topology_details(context_client, topology_name, context_name) + if topology_details is None: + raise Exception(f'Topology({context_name}/{topology_name}) not found') + + network_reply = yang_handler.compose_network(topology_name, topology_details) + network_list_reply.append(network_reply) + + yang_handler.destroy() + response = jsonify(network_list_reply) + response.status_code = HTTP_OK + + except Exception as e: + LOGGER.exception(f'Error retrieving topologies: {e}') + response = jsonify({'error': str(e)}) + response.status_code = HTTP_SERVERERROR + return response diff --git a/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/YangHandler.py b/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/YangHandler.py new file mode 100644 index 0000000000000000000000000000000000000000..a5dda280c98c060c2f872df5ab17152880b522d5 --- /dev/null +++ b/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/YangHandler.py @@ -0,0 +1,117 @@ +# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import json +import libyang, logging, os +from typing import Any +from common.proto.context_pb2 import TopologyDetails, Device, Link +from .NameMapping import NameMappings +from context.client.ContextClient import ContextClient +from common.tools.object_factory.Device import json_device_id +from common.proto.context_pb2 import DeviceId + +LOGGER = logging.getLogger(__name__) + +YANG_DIR = os.path.join(os.path.dirname(__file__), 'yang') +YANG_MODULES = ['ietf-network', 'ietf-network-topology', 'ietf-l3-unicast-topology'] + +class YangHandler: + def __init__(self) -> None: + self._yang_context = libyang.Context(YANG_DIR) + for yang_module_name in YANG_MODULES: + LOGGER.info('Loading module: {:s}'.format(str(yang_module_name))) + self._yang_context.load_module(yang_module_name).feature_enable_all() + + def compose_network(self, te_topology_name: str, topology_details: TopologyDetails) -> dict: + networks = self._yang_context.create_data_path('/ietf-network:networks') + network = networks.create_path(f'network[network-id="{te_topology_name}"]') + network.create_path('network-id', te_topology_name) + + network_types = network.create_path('network-types') + network_types.create_path('ietf-l3-unicast-topology:l3-unicast-topology') + + name_mappings = NameMappings() + + for device in topology_details.devices: + self.compose_node(device, name_mappings, network) + + for link in topology_details.links: + self.compose_link(link, name_mappings, network) + + return json.loads(networks.print_mem('json')) + + def compose_node(self, dev: Device, name_mappings: NameMappings, network: Any) -> None: + device_name = dev.name + name_mappings.store_device_name(dev) + + node = network.create_path(f'node[node-id="{device_name}"]') + node.create_path('node-id', device_name) + node_attributes = node.create_path('ietf-l3-unicast-topology:l3-node-attributes') + node_attributes.create_path('name', device_name) + + context_client = ContextClient() + device = context_client.GetDevice(DeviceId(**json_device_id(device_name))) + + for endpoint in device.device_endpoints: + name_mappings.store_endpoint_name(dev, endpoint) + + self._process_device_config(device, node) + + def _process_device_config(self, device: Device, node: Any) -> None: + for config in device.device_config.config_rules: + if config.WhichOneof('config_rule') != 'custom' or '/interface[' not in config.custom.resource_key: + continue + + for endpoint in device.device_endpoints: + endpoint_name = endpoint.name + if f'/interface[{endpoint_name}]' in config.custom.resource_key or f'/interface[{endpoint_name}.' in config.custom.resource_key: + interface_name = config.custom.resource_key.split('interface[')[1].split(']')[0] + self._create_termination_point(node, interface_name, endpoint_name, config.custom.resource_value) + + def _create_termination_point(self, node: Any, interface_name: str, endpoint_name: str, resource_value: str) -> None: + ip_addresses = self._extract_ip_addresses(json.loads(resource_value)) + if ip_addresses: + tp = node.create_path(f'ietf-network-topology:termination-point[tp-id="{interface_name}"]') + tp.create_path('tp-id', interface_name) + tp_attributes = tp.create_path('ietf-l3-unicast-topology:l3-termination-point-attributes') + + for ip in ip_addresses: + tp_attributes.create_path('ip-address', ip) + tp_attributes.create_path('interface-name', endpoint_name) + + @staticmethod + def _extract_ip_addresses(resource_value: dict) -> list: + ip_addresses = [] + if 'address_ip' in resource_value: + ip_addresses.append(resource_value['address_ip']) + if 'address_ipv6' in resource_value: + ip_addresses.append(resource_value['address_ipv6']) + return ip_addresses + + def compose_link(self, link_specs: Link, name_mappings: NameMappings, network: Any) -> None: + link_name = link_specs.name + links = network.create_path(f'ietf-network-topology:link[link-id="{link_name}"]') + links.create_path('link-id', link_name) + + self._create_link_endpoint(links, 'source', link_specs.link_endpoint_ids[0], name_mappings) + self._create_link_endpoint(links, 'destination', link_specs.link_endpoint_ids[-1], name_mappings) + + def _create_link_endpoint(self, links: Any, endpoint_type: str, endpoint_id: Any, name_mappings: NameMappings) -> None: + endpoint = links.create_path(endpoint_type) + if endpoint_type == 'destination': endpoint_type = 'dest' + endpoint.create_path(f'{endpoint_type}-node', name_mappings.get_device_name(endpoint_id.device_id)) + endpoint.create_path(f'{endpoint_type}-tp', name_mappings.get_endpoint_name(endpoint_id)) + + def destroy(self) -> None: + self._yang_context.destroy() diff --git a/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/__init__.py b/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..4503c22d502b71ddbfbb96b35534d24d3fac1426 --- /dev/null +++ b/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/__init__.py @@ -0,0 +1,39 @@ +# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# RFC 8795 - YANG Data Model for Traffic Engineering (TE) Topologies +# Ref: https://datatracker.ietf.org/doc/html/rfc8795 + +# RFC 8776 - Common YANG Data Types for Traffic Engineering +# Ref: https://datatracker.ietf.org/doc/html/rfc8776 + +# RFC 8345 - A YANG Data Model for Network Topologies +# Ref: https://datatracker.ietf.org/doc/html/rfc8345 + +# RFC 6991 - Common YANG Data Types +# Ref: https://datatracker.ietf.org/doc/html/rfc6991 + +# RFC draft-ietf-ccamp-eth-client-te-topo-yang-05 - A YANG Data Model for Ethernet TE Topology +# Ref: https://datatracker.ietf.org/doc/draft-ietf-ccamp-eth-client-te-topo-yang/ + +# RFC draft-ietf-ccamp-client-signal-yang-10 - A YANG Data Model for Transport Network Client Signals +# Ref: https://datatracker.ietf.org/doc/draft-ietf-ccamp-client-signal-yang/ + +from nbi.service.rest_server.RestServer import RestServer +from nbi.service.rest_server.nbi_plugins.ietf_network_new.Networks import Networks + +URL_PREFIX = '/restconf/data/ietf-network:networks' + +def register_ietf_network(rest_server : RestServer): + rest_server.add_resource(Networks, URL_PREFIX) diff --git a/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/yang/iana-routing-types@2017-12-04.yang b/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/yang/iana-routing-types@2017-12-04.yang new file mode 100644 index 0000000000000000000000000000000000000000..250cba4b695e269116e181b46226bae7dab7604d --- /dev/null +++ b/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/yang/iana-routing-types@2017-12-04.yang @@ -0,0 +1,473 @@ + module iana-routing-types { + namespace "urn:ietf:params:xml:ns:yang:iana-routing-types"; + prefix iana-rt-types; + + organization + "IANA"; + contact + "Internet Assigned Numbers Authority + + Postal: ICANN + 12025 Waterfront Drive, Suite 300 + Los Angeles, CA 90094-2536 + United States of America + Tel: +1 310 301 5800 + "; + + description + "This module contains a collection of YANG data types + considered defined by IANA and used for routing + protocols. + + Copyright (c) 2017 IETF Trust and the persons + identified as authors of the code. All rights reserved. + + Redistribution and use in source and binary forms, with or + without modification, is permitted pursuant to, and subject + to the license terms contained in, the Simplified BSD License + set forth in Section 4.c of the IETF Trust's Legal Provisions + Relating to IETF Documents + (https://trustee.ietf.org/license-info). + + This version of this YANG module is part of RFC 8294; see + the RFC itself for full legal notices."; + + revision 2017-12-04 { + description "Initial revision."; + reference + "RFC 8294: Common YANG Data Types for the Routing Area. + Section 4."; + } + + /*** Collection of IANA types related to routing ***/ + /*** IANA Address Family enumeration ***/ + + typedef address-family { + type enumeration { + enum ipv4 { + value 1; + description + "IPv4 Address Family."; + } + + enum ipv6 { + value 2; + description + "IPv6 Address Family."; + } + + enum nsap { + value 3; + description + "OSI Network Service Access Point (NSAP) Address Family."; + } + + enum hdlc { + value 4; + description + "High-Level Data Link Control (HDLC) Address Family."; + } + + enum bbn1822 { + value 5; + description + "Bolt, Beranek, and Newman Report 1822 (BBN 1822) + Address Family."; + } + + enum ieee802 { + value 6; + description + "IEEE 802 Committee Address Family + (aka Media Access Control (MAC) address)."; + } + + enum e163 { + value 7; + description + "ITU-T E.163 Address Family."; + } + + enum e164 { + value 8; + description + "ITU-T E.164 (Switched Multimegabit Data Service (SMDS), + Frame Relay, ATM) Address Family."; + } + + enum f69 { + value 9; + description + "ITU-T F.69 (Telex) Address Family."; + } + + enum x121 { + value 10; + description + "ITU-T X.121 (X.25, Frame Relay) Address Family."; + } + + enum ipx { + value 11; + description + "Novell Internetwork Packet Exchange (IPX) + Address Family."; + } + + enum appletalk { + value 12; + description + "Apple AppleTalk Address Family."; + } + + enum decnet-iv { + value 13; + description + "Digital Equipment DECnet Phase IV Address Family."; + } + + enum vines { + value 14; + description + "Banyan Vines Address Family."; + } + + enum e164-nsap { + value 15; + description + "ITU-T E.164 with NSAP sub-address Address Family."; + } + + enum dns { + value 16; + description + "Domain Name System (DNS) Address Family."; + } + + enum distinguished-name { + value 17; + description + "Distinguished Name Address Family."; + } + + enum as-num { + value 18; + description + "Autonomous System (AS) Number Address Family."; + } + + enum xtp-v4 { + value 19; + description + "Xpress Transport Protocol (XTP) over IPv4 + Address Family."; + } + + enum xtp-v6 { + value 20; + description + "XTP over IPv6 Address Family."; + } + + enum xtp-native { + value 21; + description + "XTP native mode Address Family."; + } + + enum fc-port { + value 22; + description + "Fibre Channel (FC) World-Wide Port Name Address Family."; + } + + enum fc-node { + value 23; + description + "FC World-Wide Node Name Address Family."; + } + + enum gwid { + value 24; + description + "ATM Gateway Identifier (GWID) Number Address Family."; + } + + enum l2vpn { + value 25; + description + "Layer 2 VPN (L2VPN) Address Family."; + } + + enum mpls-tp-section-eid { + value 26; + description + "MPLS Transport Profile (MPLS-TP) Section Endpoint + Identifier Address Family."; + } + + enum mpls-tp-lsp-eid { + value 27; + description + "MPLS-TP Label Switched Path (LSP) Endpoint Identifier + Address Family."; + } + + enum mpls-tp-pwe-eid { + value 28; + description + "MPLS-TP Pseudowire Endpoint Identifier Address Family."; + } + + enum mt-v4 { + value 29; + description + "Multi-Topology IPv4 Address Family."; + } + + enum mt-v6 { + value 30; + description + "Multi-Topology IPv6 Address Family."; + } + + enum eigrp-common-sf { + value 16384; + description + "Enhanced Interior Gateway Routing Protocol (EIGRP) + Common Service Family Address Family."; + } + + enum eigrp-v4-sf { + value 16385; + description + "EIGRP IPv4 Service Family Address Family."; + } + + enum eigrp-v6-sf { + value 16386; + description + "EIGRP IPv6 Service Family Address Family."; + } + + enum lcaf { + value 16387; + description + "Locator/ID Separation Protocol (LISP) + Canonical Address Format (LCAF) Address Family."; + } + + enum bgp-ls { + value 16388; + description + "Border Gateway Protocol - Link State (BGP-LS) + Address Family."; + } + + enum mac-48 { + value 16389; + description + "IEEE 48-bit MAC Address Family."; + } + + enum mac-64 { + value 16390; + description + "IEEE 64-bit MAC Address Family."; + } + + enum trill-oui { + value 16391; + description + "Transparent Interconnection of Lots of Links (TRILL) + IEEE Organizationally Unique Identifier (OUI) + Address Family."; + } + + enum trill-mac-24 { + value 16392; + description + "TRILL final 3 octets of 48-bit MAC Address Family."; + } + + enum trill-mac-40 { + value 16393; + description + "TRILL final 5 octets of 64-bit MAC Address Family."; + } + + enum ipv6-64 { + value 16394; + description + "First 8 octets (64 bits) of IPv6 address + Address Family."; + } + + enum trill-rbridge-port-id { + value 16395; + description + "TRILL Routing Bridge (RBridge) Port ID Address Family."; + } + + enum trill-nickname { + value 16396; + description + "TRILL Nickname Address Family."; + } + } + + description + "Enumeration containing all the IANA-defined + Address Families."; + + } + + /*** Subsequent Address Family Identifiers (SAFIs) ***/ + /*** for multiprotocol BGP enumeration ***/ + + typedef bgp-safi { + type enumeration { + enum unicast-safi { + value 1; + description + "Unicast SAFI."; + } + + enum multicast-safi { + value 2; + description + "Multicast SAFI."; + } + + enum labeled-unicast-safi { + value 4; + description + "Labeled Unicast SAFI."; + } + + enum multicast-vpn-safi { + value 5; + description + "Multicast VPN SAFI."; + } + + enum pseudowire-safi { + value 6; + description + "Multi-segment Pseudowire VPN SAFI."; + } + + enum tunnel-encap-safi { + value 7; + description + "Tunnel Encap SAFI."; + } + + enum mcast-vpls-safi { + value 8; + description + "Multicast Virtual Private LAN Service (VPLS) SAFI."; + } + + enum tunnel-safi { + value 64; + description + "Tunnel SAFI."; + } + + enum vpls-safi { + value 65; + description + "VPLS SAFI."; + } + + enum mdt-safi { + value 66; + description + "Multicast Distribution Tree (MDT) SAFI."; + } + + enum v4-over-v6-safi { + value 67; + description + "IPv4 over IPv6 SAFI."; + } + + enum v6-over-v4-safi { + value 68; + description + "IPv6 over IPv4 SAFI."; + } + + enum l1-vpn-auto-discovery-safi { + value 69; + description + "Layer 1 VPN Auto-Discovery SAFI."; + } + + enum evpn-safi { + value 70; + description + "Ethernet VPN (EVPN) SAFI."; + } + + enum bgp-ls-safi { + value 71; + description + "BGP-LS SAFI."; + } + + enum bgp-ls-vpn-safi { + value 72; + description + "BGP-LS VPN SAFI."; + } + + enum sr-te-safi { + value 73; + description + "Segment Routing - Traffic Engineering (SR-TE) SAFI."; + } + + enum labeled-vpn-safi { + value 128; + description + "MPLS Labeled VPN SAFI."; + } + + enum multicast-mpls-vpn-safi { + value 129; + description + "Multicast for BGP/MPLS IP VPN SAFI."; + } + + enum route-target-safi { + value 132; + description + "Route Target SAFI."; + } + + enum ipv4-flow-spec-safi { + value 133; + description + "IPv4 Flow Specification SAFI."; + } + + enum vpnv4-flow-spec-safi { + value 134; + description + "IPv4 VPN Flow Specification SAFI."; + } + + enum vpn-auto-discovery-safi { + value 140; + description + "VPN Auto-Discovery SAFI."; + } + } + description + "Enumeration for BGP SAFI."; + reference + "RFC 4760: Multiprotocol Extensions for BGP-4."; + } + } diff --git a/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/yang/ietf-inet-types@2013-07-15.yang b/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/yang/ietf-inet-types@2013-07-15.yang new file mode 100644 index 0000000000000000000000000000000000000000..790bafc31dd7dc3582ef1c765fe104145b8a6016 --- /dev/null +++ b/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/yang/ietf-inet-types@2013-07-15.yang @@ -0,0 +1,459 @@ + module ietf-inet-types { + + namespace "urn:ietf:params:xml:ns:yang:ietf-inet-types"; + prefix "inet"; + + organization + "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; + + contact + "WG Web: + WG List: + + WG Chair: David Kessens + + + WG Chair: Juergen Schoenwaelder + + + Editor: Juergen Schoenwaelder + "; + + description + "This module contains a collection of generally useful derived + YANG data types for Internet addresses and related things. + + Copyright (c) 2013 IETF Trust and the persons identified as + authors of the code. All rights reserved. + + Redistribution and use in source and binary forms, with or + without modification, is permitted pursuant to, and subject + to the license terms contained in, the Simplified BSD License + set forth in Section 4.c of the IETF Trust's Legal Provisions + Relating to IETF Documents + (http://trustee.ietf.org/license-info). + + This version of this YANG module is part of RFC 6991; see + the RFC itself for full legal notices."; + + revision 2013-07-15 { + description + "This revision adds the following new data types: + - ip-address-no-zone + - ipv4-address-no-zone + - ipv6-address-no-zone"; + reference + "RFC 6991: Common YANG Data Types"; + } + + revision 2010-09-24 { + description + "Initial revision."; + reference + "RFC 6021: Common YANG Data Types"; + } + + /*** collection of types related to protocol fields ***/ + + typedef ip-version { + type enumeration { + enum unknown { + value "0"; + description + "An unknown or unspecified version of the Internet + protocol."; + } + enum ipv4 { + value "1"; + description + "The IPv4 protocol as defined in RFC 791."; + } + enum ipv6 { + value "2"; + description + "The IPv6 protocol as defined in RFC 2460."; + } + } + description + "This value represents the version of the IP protocol. + + In the value set and its semantics, this type is equivalent + to the InetVersion textual convention of the SMIv2."; + reference + "RFC 791: Internet Protocol + RFC 2460: Internet Protocol, Version 6 (IPv6) Specification + RFC 4001: Textual Conventions for Internet Network Addresses"; + } + + typedef dscp { + type uint8 { + range "0..63"; + } + description + "The dscp type represents a Differentiated Services Code Point + that may be used for marking packets in a traffic stream. + + In the value set and its semantics, this type is equivalent + to the Dscp textual convention of the SMIv2."; + reference + "RFC 3289: Management Information Base for the Differentiated + Services Architecture + RFC 2474: Definition of the Differentiated Services Field + (DS Field) in the IPv4 and IPv6 Headers + RFC 2780: IANA Allocation Guidelines For Values In + the Internet Protocol and Related Headers"; + } + + typedef ipv6-flow-label { + type uint32 { + range "0..1048575"; + } + description + "The ipv6-flow-label type represents the flow identifier or Flow + Label in an IPv6 packet header that may be used to + discriminate traffic flows. + + In the value set and its semantics, this type is equivalent + to the IPv6FlowLabel textual convention of the SMIv2."; + reference + "RFC 3595: Textual Conventions for IPv6 Flow Label + RFC 2460: Internet Protocol, Version 6 (IPv6) Specification"; + } + + typedef port-number { + type uint16 { + range "0..65535"; + } + description + "The port-number type represents a 16-bit port number of an + Internet transport-layer protocol such as UDP, TCP, DCCP, or + SCTP. Port numbers are assigned by IANA. A current list of + all assignments is available from . + + Note that the port number value zero is reserved by IANA. In + situations where the value zero does not make sense, it can + be excluded by subtyping the port-number type. + In the value set and its semantics, this type is equivalent + to the InetPortNumber textual convention of the SMIv2."; + reference + "RFC 768: User Datagram Protocol + RFC 793: Transmission Control Protocol + RFC 4960: Stream Control Transmission Protocol + RFC 4340: Datagram Congestion Control Protocol (DCCP) + RFC 4001: Textual Conventions for Internet Network Addresses"; + } + + /*** collection of types related to autonomous systems ***/ + + typedef as-number { + type uint32; + description + "The as-number type represents autonomous system numbers + which identify an Autonomous System (AS). An AS is a set + of routers under a single technical administration, using + an interior gateway protocol and common metrics to route + packets within the AS, and using an exterior gateway + protocol to route packets to other ASes. IANA maintains + the AS number space and has delegated large parts to the + regional registries. + + Autonomous system numbers were originally limited to 16 + bits. BGP extensions have enlarged the autonomous system + number space to 32 bits. This type therefore uses an uint32 + base type without a range restriction in order to support + a larger autonomous system number space. + + In the value set and its semantics, this type is equivalent + to the InetAutonomousSystemNumber textual convention of + the SMIv2."; + reference + "RFC 1930: Guidelines for creation, selection, and registration + of an Autonomous System (AS) + RFC 4271: A Border Gateway Protocol 4 (BGP-4) + RFC 4001: Textual Conventions for Internet Network Addresses + RFC 6793: BGP Support for Four-Octet Autonomous System (AS) + Number Space"; + } + + /*** collection of types related to IP addresses and hostnames ***/ + + typedef ip-address { + type union { + type inet:ipv4-address; + type inet:ipv6-address; + } + description + "The ip-address type represents an IP address and is IP + version neutral. The format of the textual representation + implies the IP version. This type supports scoped addresses + by allowing zone identifiers in the address format."; + reference + "RFC 4007: IPv6 Scoped Address Architecture"; + } + + typedef ipv4-address { + type string { + pattern + '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}' + + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])' + + '(%[\p{N}\p{L}]+)?'; + } + description + "The ipv4-address type represents an IPv4 address in + dotted-quad notation. The IPv4 address may include a zone + index, separated by a % sign. + + The zone index is used to disambiguate identical address + values. For link-local addresses, the zone index will + typically be the interface index number or the name of an + interface. If the zone index is not present, the default + zone of the device will be used. + + The canonical format for the zone index is the numerical + format"; + } + + typedef ipv6-address { + type string { + pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}' + + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|' + + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}' + + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))' + + '(%[\p{N}\p{L}]+)?'; + pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|' + + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)' + + '(%.+)?'; + } + description + "The ipv6-address type represents an IPv6 address in full, + mixed, shortened, and shortened-mixed notation. The IPv6 + address may include a zone index, separated by a % sign. + + The zone index is used to disambiguate identical address + values. For link-local addresses, the zone index will + typically be the interface index number or the name of an + interface. If the zone index is not present, the default + zone of the device will be used. + + The canonical format of IPv6 addresses uses the textual + representation defined in Section 4 of RFC 5952. The + canonical format for the zone index is the numerical + format as described in Section 11.2 of RFC 4007."; + reference + "RFC 4291: IP Version 6 Addressing Architecture + RFC 4007: IPv6 Scoped Address Architecture + RFC 5952: A Recommendation for IPv6 Address Text + Representation"; + } + + typedef ip-address-no-zone { + type union { + type inet:ipv4-address-no-zone; + type inet:ipv6-address-no-zone; + } + description + "The ip-address-no-zone type represents an IP address and is + IP version neutral. The format of the textual representation + implies the IP version. This type does not support scoped + addresses since it does not allow zone identifiers in the + address format."; + reference + "RFC 4007: IPv6 Scoped Address Architecture"; + } + + typedef ipv4-address-no-zone { + type inet:ipv4-address { + pattern '[0-9\.]*'; + } + description + "An IPv4 address without a zone index. This type, derived from + ipv4-address, may be used in situations where the zone is + known from the context and hence no zone index is needed."; + } + + typedef ipv6-address-no-zone { + type inet:ipv6-address { + pattern '[0-9a-fA-F:\.]*'; + } + description + "An IPv6 address without a zone index. This type, derived from + ipv6-address, may be used in situations where the zone is + known from the context and hence no zone index is needed."; + reference + "RFC 4291: IP Version 6 Addressing Architecture + RFC 4007: IPv6 Scoped Address Architecture + RFC 5952: A Recommendation for IPv6 Address Text + Representation"; + } + + typedef ip-prefix { + type union { + type inet:ipv4-prefix; + type inet:ipv6-prefix; + } + description + "The ip-prefix type represents an IP prefix and is IP + version neutral. The format of the textual representations + implies the IP version."; + } + + typedef ipv4-prefix { + type string { + pattern + '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}' + + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])' + + '/(([0-9])|([1-2][0-9])|(3[0-2]))'; + } + description + "The ipv4-prefix type represents an IPv4 address prefix. + The prefix length is given by the number following the + slash character and must be less than or equal to 32. + + A prefix length value of n corresponds to an IP address + mask that has n contiguous 1-bits from the most + significant bit (MSB) and all other bits set to 0. + + The canonical format of an IPv4 prefix has all bits of + the IPv4 address set to zero that are not part of the + IPv4 prefix."; + } + + typedef ipv6-prefix { + type string { + pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}' + + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|' + + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}' + + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))' + + '(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'; + pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|' + + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)' + + '(/.+)'; + } + + description + "The ipv6-prefix type represents an IPv6 address prefix. + The prefix length is given by the number following the + slash character and must be less than or equal to 128. + + A prefix length value of n corresponds to an IP address + mask that has n contiguous 1-bits from the most + significant bit (MSB) and all other bits set to 0. + + The IPv6 address should have all bits that do not belong + to the prefix set to zero. + + The canonical format of an IPv6 prefix has all bits of + the IPv6 address set to zero that are not part of the + IPv6 prefix. Furthermore, the IPv6 address is represented + as defined in Section 4 of RFC 5952."; + reference + "RFC 5952: A Recommendation for IPv6 Address Text + Representation"; + } + + /*** collection of domain name and URI types ***/ + + typedef domain-name { + type string { + pattern + '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*' + + '([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?)' + + '|\.'; + length "1..253"; + } + description + "The domain-name type represents a DNS domain name. The + name SHOULD be fully qualified whenever possible. + + Internet domain names are only loosely specified. Section + 3.5 of RFC 1034 recommends a syntax (modified in Section + 2.1 of RFC 1123). The pattern above is intended to allow + for current practice in domain name use, and some possible + future expansion. It is designed to hold various types of + domain names, including names used for A or AAAA records + (host names) and other records, such as SRV records. Note + that Internet host names have a stricter syntax (described + in RFC 952) than the DNS recommendations in RFCs 1034 and + 1123, and that systems that want to store host names in + schema nodes using the domain-name type are recommended to + adhere to this stricter standard to ensure interoperability. + + The encoding of DNS names in the DNS protocol is limited + to 255 characters. Since the encoding consists of labels + prefixed by a length bytes and there is a trailing NULL + byte, only 253 characters can appear in the textual dotted + notation. + + The description clause of schema nodes using the domain-name + type MUST describe when and how these names are resolved to + IP addresses. Note that the resolution of a domain-name value + may require to query multiple DNS records (e.g., A for IPv4 + and AAAA for IPv6). The order of the resolution process and + which DNS record takes precedence can either be defined + explicitly or may depend on the configuration of the + resolver. + + Domain-name values use the US-ASCII encoding. Their canonical + format uses lowercase US-ASCII characters. Internationalized + domain names MUST be A-labels as per RFC 5890."; + reference + "RFC 952: DoD Internet Host Table Specification + RFC 1034: Domain Names - Concepts and Facilities + RFC 1123: Requirements for Internet Hosts -- Application + and Support + RFC 2782: A DNS RR for specifying the location of services + (DNS SRV) + RFC 5890: Internationalized Domain Names in Applications + (IDNA): Definitions and Document Framework"; + } + + typedef host { + type union { + type inet:ip-address; + type inet:domain-name; + } + description + "The host type represents either an IP address or a DNS + domain name."; + } + + typedef uri { + type string; + description + "The uri type represents a Uniform Resource Identifier + (URI) as defined by STD 66. + + Objects using the uri type MUST be in US-ASCII encoding, + and MUST be normalized as described by RFC 3986 Sections + 6.2.1, 6.2.2.1, and 6.2.2.2. All unnecessary + percent-encoding is removed, and all case-insensitive + characters are set to lowercase except for hexadecimal + digits, which are normalized to uppercase as described in + Section 6.2.2.1. + + The purpose of this normalization is to help provide + unique URIs. Note that this normalization is not + sufficient to provide uniqueness. Two URIs that are + textually distinct after this normalization may still be + equivalent. + + Objects using the uri type may restrict the schemes that + they permit. For example, 'data:' and 'urn:' schemes + might not be appropriate. + + A zero-length URI is not a valid URI. This can be used to + express 'URI absent' where required. + + In the value set and its semantics, this type is equivalent + to the Uri SMIv2 textual convention defined in RFC 5017."; + reference + "RFC 3986: Uniform Resource Identifier (URI): Generic Syntax + RFC 3305: Report from the Joint W3C/IETF URI Planning Interest + Group: Uniform Resource Identifiers (URIs), URLs, + and Uniform Resource Names (URNs): Clarifications + and Recommendations + RFC 5017: MIB Textual Conventions for Uniform Resource + Identifiers (URIs)"; + } + + } diff --git a/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/yang/ietf-l3-unicast-topology@2018-02-26.yang b/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/yang/ietf-l3-unicast-topology@2018-02-26.yang new file mode 100644 index 0000000000000000000000000000000000000000..39fcebd767bf7ea687de523b0dd0ba731d3c80e7 --- /dev/null +++ b/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/yang/ietf-l3-unicast-topology@2018-02-26.yang @@ -0,0 +1,359 @@ +module ietf-l3-unicast-topology { + yang-version 1.1; + namespace + "urn:ietf:params:xml:ns:yang:ietf-l3-unicast-topology"; + prefix "l3t"; + import ietf-network { + prefix "nw"; + } + import ietf-network-topology { + prefix "nt"; + } + import ietf-inet-types { + prefix "inet"; + } + import ietf-routing-types { + prefix "rt-types"; + } + organization + "IETF I2RS (Interface to the Routing System) Working Group"; + contact + "WG Web: + WG List: + Editor: Alexander Clemm + + Editor: Jan Medved + + Editor: Robert Varga + + Editor: Xufeng Liu + + Editor: Nitin Bahadur + + Editor: Hariharan Ananthakrishnan + "; + description + "This module defines a model for Layer 3 Unicast + topologies. + + Copyright (c) 2018 IETF Trust and the persons identified as + authors of the code. All rights reserved. + + Redistribution and use in source and binary forms, with or + without modification, is permitted pursuant to, and subject + to the license terms contained in, the Simplified BSD License + set forth in Section 4.c of the IETF Trust's Legal Provisions + Relating to IETF Documents + (https://trustee.ietf.org/license-info). + + This version of this YANG module is part of + RFC 8346; see the RFC itself for full legal notices."; + revision "2018-02-26" { + description + "Initial revision."; + reference + "RFC 8346: A YANG Data Model for Layer 3 Topologies"; + } + + identity flag-identity { + description "Base type for flags"; + } + + typedef l3-event-type { + type enumeration { + enum "add" { + description + "A Layer 3 node, link, prefix, or termination point has + been added"; + } + enum "remove" { + description + "A Layer 3 node, link, prefix, or termination point has + been removed"; + } + enum "update" { + description + "A Layer 3 node, link, prefix, or termination point has + been updated"; + } + } + description "Layer 3 event type for notifications"; + } + + typedef prefix-flag-type { + type identityref { + base "flag-identity"; + } + description "Prefix flag attributes"; + } + + typedef node-flag-type { + type identityref { + base "flag-identity"; + } + description "Node flag attributes"; + } + + typedef link-flag-type { + type identityref { + base "flag-identity"; + } + description "Link flag attributes"; + } + + typedef l3-flag-type { + type identityref { + base "flag-identity"; + } + description "L3 flag attributes"; + } + + grouping l3-prefix-attributes { + description + "L3 prefix attributes"; + leaf prefix { + type inet:ip-prefix; + description + "IP prefix value"; + } + leaf metric { + type uint32; + description + "Prefix metric"; + } + leaf-list flag { + type prefix-flag-type; + description + "Prefix flags"; + } + } + grouping l3-unicast-topology-type { + description "Identifies the topology type to be L3 Unicast."; + container l3-unicast-topology { + presence "indicates L3 Unicast topology"; + description + "The presence of the container node indicates L3 Unicast + topology"; + } + } + grouping l3-topology-attributes { + description "Topology scope attributes"; + container l3-topology-attributes { + description "Contains topology attributes"; + leaf name { + type string; + description + "Name of the topology"; + } + leaf-list flag { + type l3-flag-type; + description + "Topology flags"; + } + } + } + grouping l3-node-attributes { + description "L3 node scope attributes"; + container l3-node-attributes { + description + "Contains node attributes"; + leaf name { + type inet:domain-name; + description + "Node name"; + } + leaf-list flag { + type node-flag-type; + description + "Node flags"; + } + leaf-list router-id { + type rt-types:router-id; + description + "Router-id for the node"; + } + list prefix { + key "prefix"; + description + "A list of prefixes along with their attributes"; + uses l3-prefix-attributes; + } + } + } + grouping l3-link-attributes { + description + "L3 link scope attributes"; + container l3-link-attributes { + description + "Contains link attributes"; + leaf name { + type string; + description + "Link Name"; + } + leaf-list flag { + type link-flag-type; + description + "Link flags"; + } + leaf metric1 { + type uint64; + description + "Link Metric 1"; + } + leaf metric2 { + type uint64; + description + "Link Metric 2"; + } + } + } + grouping l3-termination-point-attributes { + description "L3 termination point scope attributes"; + container l3-termination-point-attributes { + description + "Contains termination point attributes"; + choice termination-point-type { + description + "Indicates the termination point type"; + case ip { + leaf-list ip-address { + type inet:ip-address; + description + "IPv4 or IPv6 address."; + } + } + case unnumbered { + leaf unnumbered-id { + type uint32; + description + "Unnumbered interface identifier. + The identifier will correspond to the ifIndex value + of the interface, i.e., the ifIndex value of the + ifEntry that represents the interface in + implementations where the Interfaces Group MIB + (RFC 2863) is supported."; + reference + "RFC 2863: The Interfaces Group MIB"; + } + } + case interface-name { + leaf interface-name { + type string; + description + "Name of the interface. The name can (but does not + have to) correspond to an interface reference of a + containing node's interface, i.e., the path name of a + corresponding interface data node on the containing + node reminiscent of data type interface-ref defined + in RFC 8343. It should be noted that data type + interface-ref of RFC 8343 cannot be used directly, + + as this data type is used to reference an interface + in a datastore of a single node in the network, not + to uniquely reference interfaces across a network."; + reference + "RFC 8343: A YANG Data Model for Interface Management"; + } + } + } + } + } + augment "/nw:networks/nw:network/nw:network-types" { + description + "Introduces new network type for L3 Unicast topology"; + uses l3-unicast-topology-type; + } + augment "/nw:networks/nw:network" { + when "nw:network-types/l3t:l3-unicast-topology" { + description + "Augmentation parameters apply only for networks with + L3 Unicast topology"; + } + description + "L3 Unicast for the network as a whole"; + uses l3-topology-attributes; + } + augment "/nw:networks/nw:network/nw:node" { + when "../nw:network-types/l3t:l3-unicast-topology" { + description + "Augmentation parameters apply only for networks with + L3 Unicast topology"; + } + description + "L3 Unicast node-level attributes "; + uses l3-node-attributes; + } + augment "/nw:networks/nw:network/nt:link" { + when "../nw:network-types/l3t:l3-unicast-topology" { + description + "Augmentation parameters apply only for networks with + L3 Unicast topology"; + } + description + "Augments topology link attributes"; + uses l3-link-attributes; + } + augment "/nw:networks/nw:network/nw:node/" + +"nt:termination-point" { + when "../../nw:network-types/l3t:l3-unicast-topology" { + description + "Augmentation parameters apply only for networks with + L3 Unicast topology"; + } + description "Augments topology termination point configuration"; + uses l3-termination-point-attributes; + } + notification l3-node-event { + description + "Notification event for L3 node"; + leaf l3-event-type { + type l3-event-type; + description + "Event type"; + } + uses nw:node-ref; + uses l3-unicast-topology-type; + uses l3-node-attributes; + } + notification l3-link-event { + description + "Notification event for L3 link"; + leaf l3-event-type { + type l3-event-type; + description + "Event type"; + } + uses nt:link-ref; + uses l3-unicast-topology-type; + uses l3-link-attributes; + } + notification l3-prefix-event { + description + "Notification event for L3 prefix"; + leaf l3-event-type { + type l3-event-type; + description + "Event type"; + } + uses nw:node-ref; + uses l3-unicast-topology-type; + container prefix { + description + "Contains L3 prefix attributes"; + uses l3-prefix-attributes; + } + } + notification termination-point-event { + description + "Notification event for L3 termination point"; + leaf l3-event-type { + type l3-event-type; + description + "Event type"; + } + uses nt:tp-ref; + uses l3-unicast-topology-type; + uses l3-termination-point-attributes; + } +} diff --git a/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/yang/ietf-network-topology@2018-02-26.yang b/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/yang/ietf-network-topology@2018-02-26.yang new file mode 100644 index 0000000000000000000000000000000000000000..0538ac01b629e80db37bd66a3128ac5e04dfbcef --- /dev/null +++ b/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/yang/ietf-network-topology@2018-02-26.yang @@ -0,0 +1,294 @@ + module ietf-network-topology { + yang-version 1.1; + namespace "urn:ietf:params:xml:ns:yang:ietf-network-topology"; + prefix nt; + + import ietf-inet-types { + prefix inet; + reference + "RFC 6991: Common YANG Data Types"; + } + import ietf-network { + prefix nw; + reference + "RFC 8345: A YANG Data Model for Network Topologies"; + } + + organization + "IETF I2RS (Interface to the Routing System) Working Group"; + + contact + "WG Web: + WG List: + + Editor: Alexander Clemm + + + Editor: Jan Medved + + + Editor: Robert Varga + + + Editor: Nitin Bahadur + + + Editor: Hariharan Ananthakrishnan + + + Editor: Xufeng Liu + "; + + description + "This module defines a common base model for a network topology, + augmenting the base network data model with links to connect + nodes, as well as termination points to terminate links + on nodes. + + Copyright (c) 2018 IETF Trust and the persons identified as + authors of the code. All rights reserved. + + Redistribution and use in source and binary forms, with or + without modification, is permitted pursuant to, and subject + to the license terms contained in, the Simplified BSD License + set forth in Section 4.c of the IETF Trust's Legal Provisions + Relating to IETF Documents + (https://trustee.ietf.org/license-info). + + This version of this YANG module is part of RFC 8345; + see the RFC itself for full legal notices."; + + revision 2018-02-26 { + description + "Initial revision."; + reference + "RFC 8345: A YANG Data Model for Network Topologies"; + } + + typedef link-id { + type inet:uri; + description + "An identifier for a link in a topology. The precise + structure of the link-id will be up to the implementation. + The identifier SHOULD be chosen such that the same link in a + real network topology will always be identified through the + same identifier, even if the data model is instantiated in + separate datastores. An implementation MAY choose to capture + semantics in the identifier -- for example, to indicate the + type of link and/or the type of topology of which the link is + a part."; + } + + typedef tp-id { + type inet:uri; + description + "An identifier for termination points on a node. The precise + structure of the tp-id will be up to the implementation. + The identifier SHOULD be chosen such that the same termination + point in a real network topology will always be identified + through the same identifier, even if the data model is + instantiated in separate datastores. An implementation MAY + choose to capture semantics in the identifier -- for example, + to indicate the type of termination point and/or the type of + node that contains the termination point."; + } + + grouping link-ref { + description + "This grouping can be used to reference a link in a specific + network. Although it is not used in this module, it is + defined here for the convenience of augmenting modules."; + leaf link-ref { + type leafref { + path "/nw:networks/nw:network[nw:network-id=current()/../"+ + "network-ref]/nt:link/nt:link-id"; + require-instance false; + } + description + "A type for an absolute reference to a link instance. + (This type should not be used for relative references. + In such a case, a relative path should be used instead.)"; + } + uses nw:network-ref; + } + + grouping tp-ref { + description + "This grouping can be used to reference a termination point + in a specific node. Although it is not used in this module, + it is defined here for the convenience of augmenting + modules."; + leaf tp-ref { + type leafref { + path "/nw:networks/nw:network[nw:network-id=current()/../"+ + "network-ref]/nw:node[nw:node-id=current()/../"+ + "node-ref]/nt:termination-point/nt:tp-id"; + require-instance false; + } + description + "A type for an absolute reference to a termination point. + (This type should not be used for relative references. + In such a case, a relative path should be used instead.)"; + } + uses nw:node-ref; + } + + augment "/nw:networks/nw:network" { + description + "Add links to the network data model."; + list link { + key "link-id"; + description + "A network link connects a local (source) node and + a remote (destination) node via a set of the respective + node's termination points. It is possible to have several + links between the same source and destination nodes. + Likewise, a link could potentially be re-homed between + termination points. Therefore, in order to ensure that we + would always know to distinguish between links, every link + is identified by a dedicated link identifier. Note that a + link models a point-to-point link, not a multipoint link."; + leaf link-id { + type link-id; + description + "The identifier of a link in the topology. + A link is specific to a topology to which it belongs."; + } + container source { + description + "This container holds the logical source of a particular + link."; + leaf source-node { + type leafref { + path "../../../nw:node/nw:node-id"; + require-instance false; + } + description + "Source node identifier. Must be in the same topology."; + } + leaf source-tp { + type leafref { + path "../../../nw:node[nw:node-id=current()/../"+ + "source-node]/termination-point/tp-id"; + require-instance false; + } + description + "This termination point is located within the source node + and terminates the link."; + } + } + + container destination { + description + "This container holds the logical destination of a + particular link."; + leaf dest-node { + type leafref { + path "../../../nw:node/nw:node-id"; + require-instance false; + } + description + "Destination node identifier. Must be in the same + network."; + } + leaf dest-tp { + type leafref { + path "../../../nw:node[nw:node-id=current()/../"+ + "dest-node]/termination-point/tp-id"; + require-instance false; + } + description + "This termination point is located within the + destination node and terminates the link."; + } + } + list supporting-link { + key "network-ref link-ref"; + description + "Identifies the link or links on which this link depends."; + leaf network-ref { + type leafref { + path "../../../nw:supporting-network/nw:network-ref"; + require-instance false; + } + description + "This leaf identifies in which underlay topology + the supporting link is present."; + } + + leaf link-ref { + type leafref { + path "/nw:networks/nw:network[nw:network-id=current()/"+ + "../network-ref]/link/link-id"; + require-instance false; + } + description + "This leaf identifies a link that is a part + of this link's underlay. Reference loops in which + a link identifies itself as its underlay, either + directly or transitively, are not allowed."; + } + } + } + } + augment "/nw:networks/nw:network/nw:node" { + description + "Augments termination points that terminate links. + Termination points can ultimately be mapped to interfaces."; + list termination-point { + key "tp-id"; + description + "A termination point can terminate a link. + Depending on the type of topology, a termination point + could, for example, refer to a port or an interface."; + leaf tp-id { + type tp-id; + description + "Termination point identifier."; + } + list supporting-termination-point { + key "network-ref node-ref tp-ref"; + description + "This list identifies any termination points on which a + given termination point depends or onto which it maps. + Those termination points will themselves be contained + in a supporting node. This dependency information can be + inferred from the dependencies between links. Therefore, + this item is not separately configurable. Hence, no + corresponding constraint needs to be articulated. + The corresponding information is simply provided by the + implementing system."; + + leaf network-ref { + type leafref { + path "../../../nw:supporting-node/nw:network-ref"; + require-instance false; + } + description + "This leaf identifies in which topology the + supporting termination point is present."; + } + leaf node-ref { + type leafref { + path "../../../nw:supporting-node/nw:node-ref"; + require-instance false; + } + description + "This leaf identifies in which node the supporting + termination point is present."; + } + leaf tp-ref { + type leafref { + path "/nw:networks/nw:network[nw:network-id=current()/"+ + "../network-ref]/nw:node[nw:node-id=current()/../"+ + "node-ref]/termination-point/tp-id"; + require-instance false; + } + description + "Reference to the underlay node (the underlay node must + be in a different topology)."; + } + } + } + } + } diff --git a/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/yang/ietf-network@2018-02-26.yang b/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/yang/ietf-network@2018-02-26.yang new file mode 100644 index 0000000000000000000000000000000000000000..d9da81eeebefad9054a43af552de3d51f20bcd56 --- /dev/null +++ b/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/yang/ietf-network@2018-02-26.yang @@ -0,0 +1,193 @@ + module ietf-network { + yang-version 1.1; + namespace "urn:ietf:params:xml:ns:yang:ietf-network"; + prefix nw; + + import ietf-inet-types { + prefix inet; + reference + "RFC 6991: Common YANG Data Types"; + } + + organization + "IETF I2RS (Interface to the Routing System) Working Group"; + + contact + "WG Web: + WG List: + + Editor: Alexander Clemm + + + Editor: Jan Medved + + + Editor: Robert Varga + + + Editor: Nitin Bahadur + + + Editor: Hariharan Ananthakrishnan + + + Editor: Xufeng Liu + "; + + description + "This module defines a common base data model for a collection + of nodes in a network. Node definitions are further used + in network topologies and inventories. + + Copyright (c) 2018 IETF Trust and the persons identified as + authors of the code. All rights reserved. + + Redistribution and use in source and binary forms, with or + without modification, is permitted pursuant to, and subject + to the license terms contained in, the Simplified BSD License + set forth in Section 4.c of the IETF Trust's Legal Provisions + Relating to IETF Documents + (https://trustee.ietf.org/license-info). + + This version of this YANG module is part of RFC 8345; + see the RFC itself for full legal notices."; + + revision 2018-02-26 { + description + "Initial revision."; + reference + "RFC 8345: A YANG Data Model for Network Topologies"; + } + + typedef node-id { + type inet:uri; + description + "Identifier for a node. The precise structure of the node-id + will be up to the implementation. For example, some + implementations MAY pick a URI that includes the network-id + as part of the path. The identifier SHOULD be chosen + such that the same node in a real network topology will + always be identified through the same identifier, even if + the data model is instantiated in separate datastores. An + implementation MAY choose to capture semantics in the + identifier -- for example, to indicate the type of node."; + } + + typedef network-id { + type inet:uri; + description + "Identifier for a network. The precise structure of the + network-id will be up to the implementation. The identifier + SHOULD be chosen such that the same network will always be + identified through the same identifier, even if the data model + is instantiated in separate datastores. An implementation MAY + choose to capture semantics in the identifier -- for example, + to indicate the type of network."; + } + + grouping network-ref { + description + "Contains the information necessary to reference a network -- + for example, an underlay network."; + leaf network-ref { + type leafref { + path "/nw:networks/nw:network/nw:network-id"; + require-instance false; + } + description + "Used to reference a network -- for example, an underlay + network."; + } + } + + grouping node-ref { + description + "Contains the information necessary to reference a node."; + leaf node-ref { + type leafref { + path "/nw:networks/nw:network[nw:network-id=current()/../"+ + "network-ref]/nw:node/nw:node-id"; + require-instance false; + } + description + "Used to reference a node. + Nodes are identified relative to the network that + contains them."; + } + uses network-ref; + } + + container networks { + description + "Serves as a top-level container for a list of networks."; + list network { + key "network-id"; + description + "Describes a network. + A network typically contains an inventory of nodes, + topological information (augmented through the + network-topology data model), and layering information."; + leaf network-id { + type network-id; + description + "Identifies a network."; + } + container network-types { + description + "Serves as an augmentation target. + The network type is indicated through corresponding + presence containers augmented into this container."; + } + list supporting-network { + key "network-ref"; + description + "An underlay network, used to represent layered network + topologies."; + leaf network-ref { + type leafref { + path "/nw:networks/nw:network/nw:network-id"; + require-instance false; + } + description + "References the underlay network."; + } + } + + list node { + key "node-id"; + description + "The inventory of nodes of this network."; + leaf node-id { + type node-id; + description + "Uniquely identifies a node within the containing + network."; + } + list supporting-node { + key "network-ref node-ref"; + description + "Represents another node that is in an underlay network + and that supports this node. Used to represent layering + structure."; + leaf network-ref { + type leafref { + path "../../../nw:supporting-network/nw:network-ref"; + require-instance false; + } + description + "References the underlay network of which the + underlay node is a part."; + } + leaf node-ref { + type leafref { + path "/nw:networks/nw:network/nw:node/nw:node-id"; + require-instance false; + } + description + "References the underlay node itself."; + } + } + } + } + } + } diff --git a/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/yang/ietf-routing-types@2017-12-04.yang b/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/yang/ietf-routing-types@2017-12-04.yang new file mode 100644 index 0000000000000000000000000000000000000000..695d9eaeb9e771b945397c8b1c817ce91b0414af --- /dev/null +++ b/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/yang/ietf-routing-types@2017-12-04.yang @@ -0,0 +1,774 @@ + module ietf-routing-types { + namespace "urn:ietf:params:xml:ns:yang:ietf-routing-types"; + prefix rt-types; + + import ietf-yang-types { + prefix yang; + } + import ietf-inet-types { + prefix inet; + } + + organization + "IETF RTGWG - Routing Area Working Group"; + contact + "WG Web: + WG List: + + Editors: Xufeng Liu + + Yingzhen Qu + + Acee Lindem + + Christian Hopps + + Lou Berger + "; + + description + "This module contains a collection of YANG data types + considered generally useful for routing protocols. + + Copyright (c) 2017 IETF Trust and the persons + identified as authors of the code. All rights reserved. + + Redistribution and use in source and binary forms, with or + without modification, is permitted pursuant to, and subject + to the license terms contained in, the Simplified BSD License + set forth in Section 4.c of the IETF Trust's Legal Provisions + Relating to IETF Documents + (https://trustee.ietf.org/license-info). + + This version of this YANG module is part of RFC 8294; see + the RFC itself for full legal notices."; + + revision 2017-12-04 { + description "Initial revision."; + reference + "RFC 8294: Common YANG Data Types for the Routing Area. + Section 3."; + } + + /*** Identities related to MPLS/GMPLS ***/ + + identity mpls-label-special-purpose-value { + description + "Base identity for deriving identities describing + special-purpose Multiprotocol Label Switching (MPLS) label + values."; + reference + "RFC 7274: Allocating and Retiring Special-Purpose MPLS + Labels."; + } + + identity ipv4-explicit-null-label { + base mpls-label-special-purpose-value; + description + "This identity represents the IPv4 Explicit NULL Label."; + reference + "RFC 3032: MPLS Label Stack Encoding. Section 2.1."; + } + + identity router-alert-label { + base mpls-label-special-purpose-value; + description + "This identity represents the Router Alert Label."; + reference + "RFC 3032: MPLS Label Stack Encoding. Section 2.1."; + } + + identity ipv6-explicit-null-label { + base mpls-label-special-purpose-value; + description + "This identity represents the IPv6 Explicit NULL Label."; + reference + "RFC 3032: MPLS Label Stack Encoding. Section 2.1."; + } + + identity implicit-null-label { + base mpls-label-special-purpose-value; + description + "This identity represents the Implicit NULL Label."; + reference + "RFC 3032: MPLS Label Stack Encoding. Section 2.1."; + } + + identity entropy-label-indicator { + base mpls-label-special-purpose-value; + description + "This identity represents the Entropy Label Indicator."; + reference + "RFC 6790: The Use of Entropy Labels in MPLS Forwarding. + Sections 3 and 10.1."; + } + + identity gal-label { + base mpls-label-special-purpose-value; + description + "This identity represents the Generic Associated Channel + (G-ACh) Label (GAL)."; + reference + "RFC 5586: MPLS Generic Associated Channel. + Sections 4 and 10."; + } + + identity oam-alert-label { + base mpls-label-special-purpose-value; + description + "This identity represents the OAM Alert Label."; + reference + "RFC 3429: Assignment of the 'OAM Alert Label' for + Multiprotocol Label Switching Architecture (MPLS) + Operation and Maintenance (OAM) Functions. + Sections 3 and 6."; + } + + identity extension-label { + base mpls-label-special-purpose-value; + description + "This identity represents the Extension Label."; + reference + "RFC 7274: Allocating and Retiring Special-Purpose MPLS + Labels. Sections 3.1 and 5."; + } + + /*** Collection of types related to routing ***/ + + typedef router-id { + type yang:dotted-quad; + description + "A 32-bit number in the dotted-quad format assigned to each + router. This number uniquely identifies the router within + an Autonomous System."; + } + + /*** Collection of types related to VPNs ***/ + + typedef route-target { + type string { + pattern + '(0:(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|' + + '6[0-4][0-9]{3}|' + + '[1-5][0-9]{4}|[1-9][0-9]{0,3}|0):(429496729[0-5]|' + + '42949672[0-8][0-9]|' + + '4294967[01][0-9]{2}|429496[0-6][0-9]{3}|' + + '42949[0-5][0-9]{4}|' + + '4294[0-8][0-9]{5}|429[0-3][0-9]{6}|' + + '42[0-8][0-9]{7}|4[01][0-9]{8}|' + + '[1-3][0-9]{9}|[1-9][0-9]{0,8}|0))|' + + '(1:((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|' + + '25[0-5])\.){3}([0-9]|[1-9][0-9]|' + + '1[0-9]{2}|2[0-4][0-9]|25[0-5])):(6553[0-5]|' + + '655[0-2][0-9]|' + + '65[0-4][0-9]{2}|6[0-4][0-9]{3}|' + + '[1-5][0-9]{4}|[1-9][0-9]{0,3}|0))|' + + '(2:(429496729[0-5]|42949672[0-8][0-9]|' + + '4294967[01][0-9]{2}|' + + '429496[0-6][0-9]{3}|42949[0-5][0-9]{4}|' + + '4294[0-8][0-9]{5}|' + + '429[0-3][0-9]{6}|42[0-8][0-9]{7}|4[01][0-9]{8}|' + + '[1-3][0-9]{9}|[1-9][0-9]{0,8}|0):' + + '(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|' + + '6[0-4][0-9]{3}|' + + '[1-5][0-9]{4}|[1-9][0-9]{0,3}|0))|' + + '(6(:[a-fA-F0-9]{2}){6})|' + + '(([3-57-9a-fA-F]|[1-9a-fA-F][0-9a-fA-F]{1,3}):' + + '[0-9a-fA-F]{1,12})'; + } + + description + "A Route Target is an 8-octet BGP extended community + initially identifying a set of sites in a BGP VPN + (RFC 4364). However, it has since taken on a more general + role in BGP route filtering. A Route Target consists of two + or three fields: a 2-octet Type field, an administrator + field, and, optionally, an assigned number field. + + According to the data formats for types 0, 1, 2, and 6 as + defined in RFC 4360, RFC 5668, and RFC 7432, the encoding + pattern is defined as: + + 0:2-octet-asn:4-octet-number + 1:4-octet-ipv4addr:2-octet-number + 2:4-octet-asn:2-octet-number + 6:6-octet-mac-address + + Additionally, a generic pattern is defined for future + Route Target types: + + 2-octet-other-hex-number:6-octet-hex-number + + Some valid examples are 0:100:100, 1:1.1.1.1:100, + 2:1234567890:203, and 6:26:00:08:92:78:00."; + reference + "RFC 4360: BGP Extended Communities Attribute. + RFC 4364: BGP/MPLS IP Virtual Private Networks (VPNs). + RFC 5668: 4-Octet AS Specific BGP Extended Community. + RFC 7432: BGP MPLS-Based Ethernet VPN."; + } + + typedef ipv6-route-target { + type string { + pattern + '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}' + + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|' + + '(((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\.){3}' + + '(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])))' + + ':' + + '(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|' + + '6[0-4][0-9]{3}|' + + '[1-5][0-9]{4}|[1-9][0-9]{0,3}|0)'; + pattern '((([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|' + + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?))' + + ':' + + '(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|' + + '6[0-4][0-9]{3}|' + + '[1-5][0-9]{4}|[1-9][0-9]{0,3}|0)'; + } + description + "An IPv6 Route Target is a 20-octet BGP IPv6 Address + Specific Extended Community serving the same function + as a standard 8-octet Route Target, except that it only + allows an IPv6 address as the global administrator. + The format is . + + Two valid examples are 2001:db8::1:6544 and + 2001:db8::5eb1:791:6b37:17958."; + reference + "RFC 5701: IPv6 Address Specific BGP Extended Community + Attribute."; + } + + typedef route-target-type { + type enumeration { + enum import { + value 0; + description + "The Route Target applies to route import."; + } + enum export { + value 1; + description + "The Route Target applies to route export."; + } + + enum both { + value 2; + description + "The Route Target applies to both route import and + route export."; + } + } + description + "Indicates the role a Route Target takes in route filtering."; + reference + "RFC 4364: BGP/MPLS IP Virtual Private Networks (VPNs)."; + } + + typedef route-distinguisher { + type string { + pattern + '(0:(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|' + + '6[0-4][0-9]{3}|' + + '[1-5][0-9]{4}|[1-9][0-9]{0,3}|0):(429496729[0-5]|' + + '42949672[0-8][0-9]|' + + '4294967[01][0-9]{2}|429496[0-6][0-9]{3}|' + + '42949[0-5][0-9]{4}|' + + '4294[0-8][0-9]{5}|429[0-3][0-9]{6}|' + + '42[0-8][0-9]{7}|4[01][0-9]{8}|' + + '[1-3][0-9]{9}|[1-9][0-9]{0,8}|0))|' + + '(1:((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|' + + '25[0-5])\.){3}([0-9]|[1-9][0-9]|' + + '1[0-9]{2}|2[0-4][0-9]|25[0-5])):(6553[0-5]|' + + '655[0-2][0-9]|' + + '65[0-4][0-9]{2}|6[0-4][0-9]{3}|' + + '[1-5][0-9]{4}|[1-9][0-9]{0,3}|0))|' + + '(2:(429496729[0-5]|42949672[0-8][0-9]|' + + '4294967[01][0-9]{2}|' + + '429496[0-6][0-9]{3}|42949[0-5][0-9]{4}|' + + '4294[0-8][0-9]{5}|' + + '429[0-3][0-9]{6}|42[0-8][0-9]{7}|4[01][0-9]{8}|' + + '[1-3][0-9]{9}|[1-9][0-9]{0,8}|0):' + + '(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|' + + '6[0-4][0-9]{3}|' + + '[1-5][0-9]{4}|[1-9][0-9]{0,3}|0))|' + + '(6(:[a-fA-F0-9]{2}){6})|' + + '(([3-57-9a-fA-F]|[1-9a-fA-F][0-9a-fA-F]{1,3}):' + + '[0-9a-fA-F]{1,12})'; + } + + description + "A Route Distinguisher is an 8-octet value used to + distinguish routes from different BGP VPNs (RFC 4364). + A Route Distinguisher will have the same format as a + Route Target as per RFC 4360 and will consist of + two or three fields: a 2-octet Type field, an administrator + field, and, optionally, an assigned number field. + + According to the data formats for types 0, 1, 2, and 6 as + defined in RFC 4360, RFC 5668, and RFC 7432, the encoding + pattern is defined as: + + 0:2-octet-asn:4-octet-number + 1:4-octet-ipv4addr:2-octet-number + 2:4-octet-asn:2-octet-number + 6:6-octet-mac-address + + Additionally, a generic pattern is defined for future + route discriminator types: + + 2-octet-other-hex-number:6-octet-hex-number + + Some valid examples are 0:100:100, 1:1.1.1.1:100, + 2:1234567890:203, and 6:26:00:08:92:78:00."; + reference + "RFC 4360: BGP Extended Communities Attribute. + RFC 4364: BGP/MPLS IP Virtual Private Networks (VPNs). + RFC 5668: 4-Octet AS Specific BGP Extended Community. + RFC 7432: BGP MPLS-Based Ethernet VPN."; + } + + typedef route-origin { + type string { + pattern + '(0:(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|' + + '6[0-4][0-9]{3}|' + + '[1-5][0-9]{4}|[1-9][0-9]{0,3}|0):(429496729[0-5]|' + + '42949672[0-8][0-9]|' + + '4294967[01][0-9]{2}|429496[0-6][0-9]{3}|' + + '42949[0-5][0-9]{4}|' + + '4294[0-8][0-9]{5}|429[0-3][0-9]{6}|' + + '42[0-8][0-9]{7}|4[01][0-9]{8}|' + + '[1-3][0-9]{9}|[1-9][0-9]{0,8}|0))|' + + '(1:((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|' + + '25[0-5])\.){3}([0-9]|[1-9][0-9]|' + + '1[0-9]{2}|2[0-4][0-9]|25[0-5])):(6553[0-5]|' + + '655[0-2][0-9]|' + + '65[0-4][0-9]{2}|6[0-4][0-9]{3}|' + + '[1-5][0-9]{4}|[1-9][0-9]{0,3}|0))|' + + '(2:(429496729[0-5]|42949672[0-8][0-9]|' + + '4294967[01][0-9]{2}|' + + '429496[0-6][0-9]{3}|42949[0-5][0-9]{4}|' + + '4294[0-8][0-9]{5}|' + + '429[0-3][0-9]{6}|42[0-8][0-9]{7}|4[01][0-9]{8}|' + + '[1-3][0-9]{9}|[1-9][0-9]{0,8}|0):' + + '(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|' + + '6[0-4][0-9]{3}|' + + '[1-5][0-9]{4}|[1-9][0-9]{0,3}|0))|' + + '(6(:[a-fA-F0-9]{2}){6})|' + + '(([3-57-9a-fA-F]|[1-9a-fA-F][0-9a-fA-F]{1,3}):' + + '[0-9a-fA-F]{1,12})'; + } + description + "A Route Origin is an 8-octet BGP extended community + identifying the set of sites where the BGP route + originated (RFC 4364). A Route Origin will have the same + format as a Route Target as per RFC 4360 and will consist + of two or three fields: a 2-octet Type field, an + administrator field, and, optionally, an assigned number + field. + + According to the data formats for types 0, 1, 2, and 6 as + defined in RFC 4360, RFC 5668, and RFC 7432, the encoding + pattern is defined as: + + 0:2-octet-asn:4-octet-number + 1:4-octet-ipv4addr:2-octet-number + 2:4-octet-asn:2-octet-number + 6:6-octet-mac-address + + Additionally, a generic pattern is defined for future + Route Origin types: + + 2-octet-other-hex-number:6-octet-hex-number + + Some valid examples are 0:100:100, 1:1.1.1.1:100, + 2:1234567890:203, and 6:26:00:08:92:78:00."; + reference + "RFC 4360: BGP Extended Communities Attribute. + RFC 4364: BGP/MPLS IP Virtual Private Networks (VPNs). + RFC 5668: 4-Octet AS Specific BGP Extended Community. + RFC 7432: BGP MPLS-Based Ethernet VPN."; + } + + typedef ipv6-route-origin { + type string { + pattern + '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}' + + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|' + + '(((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\.){3}' + + '(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])))' + + ':' + + '(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|' + + '6[0-4][0-9]{3}|' + + '[1-5][0-9]{4}|[1-9][0-9]{0,3}|0)'; + pattern '((([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|' + + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?))' + + ':' + + '(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|' + + '6[0-4][0-9]{3}|' + + '[1-5][0-9]{4}|[1-9][0-9]{0,3}|0)'; + } + description + "An IPv6 Route Origin is a 20-octet BGP IPv6 Address + Specific Extended Community serving the same function + as a standard 8-octet route, except that it only allows + an IPv6 address as the global administrator. The format + is . + + Two valid examples are 2001:db8::1:6544 and + 2001:db8::5eb1:791:6b37:17958."; + reference + "RFC 5701: IPv6 Address Specific BGP Extended Community + Attribute."; + } + + /*** Collection of types common to multicast ***/ + + typedef ipv4-multicast-group-address { + type inet:ipv4-address { + pattern '(2((2[4-9])|(3[0-9]))\.).*'; + } + description + "This type represents an IPv4 multicast group address, + which is in the range of 224.0.0.0 to 239.255.255.255."; + reference + "RFC 1112: Host Extensions for IP Multicasting."; + } + + typedef ipv6-multicast-group-address { + type inet:ipv6-address { + pattern '(([fF]{2}[0-9a-fA-F]{2}):).*'; + } + description + "This type represents an IPv6 multicast group address, + which is in the range of ff00::/8."; + reference + "RFC 4291: IP Version 6 Addressing Architecture. Section 2.7. + RFC 7346: IPv6 Multicast Address Scopes."; + } + + typedef ip-multicast-group-address { + type union { + type ipv4-multicast-group-address; + type ipv6-multicast-group-address; + } + description + "This type represents a version-neutral IP multicast group + address. The format of the textual representation implies + the IP version."; + } + + typedef ipv4-multicast-source-address { + type union { + type enumeration { + enum * { + description + "Any source address."; + } + } + type inet:ipv4-address; + } + description + "Multicast source IPv4 address type."; + } + + typedef ipv6-multicast-source-address { + type union { + type enumeration { + enum * { + description + "Any source address."; + } + } + type inet:ipv6-address; + } + description + "Multicast source IPv6 address type."; + } + + /*** Collection of types common to protocols ***/ + + typedef bandwidth-ieee-float32 { + type string { + pattern + '0[xX](0((\.0?)?[pP](\+)?0?|(\.0?))|' + + '1(\.([0-9a-fA-F]{0,5}[02468aAcCeE]?)?)?[pP](\+)?(12[0-7]|' + + '1[01][0-9]|0?[0-9]?[0-9])?)'; + } + description + "Bandwidth in IEEE 754 floating-point 32-bit binary format: + (-1)**(S) * 2**(Exponent-127) * (1 + Fraction), + where Exponent uses 8 bits and Fraction uses 23 bits. + The units are octets per second. + The encoding format is the external hexadecimal-significant + character sequences specified in IEEE 754 and ISO/IEC C99. + The format is restricted to be normalized, non-negative, and + non-fraction: 0x1.hhhhhhp{+}d, 0X1.HHHHHHP{+}D, or 0x0p0, + where 'h' and 'H' are hexadecimal digits and 'd' and 'D' are + integers in the range of [0..127]. + + When six hexadecimal digits are used for 'hhhhhh' or + 'HHHHHH', the least significant digit must be an even + number. 'x' and 'X' indicate hexadecimal; 'p' and 'P' + indicate a power of two. Some examples are 0x0p0, 0x1p10, + and 0x1.abcde2p+20."; + reference + "IEEE Std 754-2008: IEEE Standard for Floating-Point + Arithmetic. + ISO/IEC C99: Information technology - Programming + Languages - C."; + } + + typedef link-access-type { + type enumeration { + enum broadcast { + description + "Specify broadcast multi-access network."; + } + enum non-broadcast-multiaccess { + description + "Specify Non-Broadcast Multi-Access (NBMA) network."; + } + enum point-to-multipoint { + description + "Specify point-to-multipoint network."; + } + enum point-to-point { + description + "Specify point-to-point network."; + } + } + description + "Link access type."; + } + + typedef timer-multiplier { + type uint8; + description + "The number of timer value intervals that should be + interpreted as a failure."; + } + + typedef timer-value-seconds16 { + type union { + type uint16 { + range "1..65535"; + } + type enumeration { + enum infinity { + description + "The timer is set to infinity."; + } + enum not-set { + description + "The timer is not set."; + } + } + } + units "seconds"; + description + "Timer value type, in seconds (16-bit range)."; + } + + typedef timer-value-seconds32 { + type union { + type uint32 { + range "1..4294967295"; + } + type enumeration { + enum infinity { + description + "The timer is set to infinity."; + } + enum not-set { + description + "The timer is not set."; + } + } + } + units "seconds"; + description + "Timer value type, in seconds (32-bit range)."; + } + + typedef timer-value-milliseconds { + type union { + type uint32 { + range "1..4294967295"; + } + type enumeration { + enum infinity { + description + "The timer is set to infinity."; + } + enum not-set { + description + "The timer is not set."; + } + } + } + units "milliseconds"; + description + "Timer value type, in milliseconds."; + } + + typedef percentage { + type uint8 { + range "0..100"; + } + description + "Integer indicating a percentage value."; + } + + typedef timeticks64 { + type uint64; + description + "This type is based on the timeticks type defined in + RFC 6991, but with 64-bit width. It represents the time, + modulo 2^64, in hundredths of a second between two epochs."; + reference + "RFC 6991: Common YANG Data Types."; + } + + typedef uint24 { + type uint32 { + range "0..16777215"; + } + description + "24-bit unsigned integer."; + } + + /*** Collection of types related to MPLS/GMPLS ***/ + + typedef generalized-label { + type binary; + description + "Generalized Label. Nodes sending and receiving the + Generalized Label are aware of the link-specific + label context and type."; + reference + "RFC 3471: Generalized Multi-Protocol Label Switching (GMPLS) + Signaling Functional Description. Section 3.2."; + } + + typedef mpls-label-special-purpose { + type identityref { + base mpls-label-special-purpose-value; + } + description + "This type represents the special-purpose MPLS label values."; + reference + "RFC 3032: MPLS Label Stack Encoding. + RFC 7274: Allocating and Retiring Special-Purpose MPLS + Labels."; + } + + typedef mpls-label-general-use { + type uint32 { + range "16..1048575"; + } + description + "The 20-bit label value in an MPLS label stack as specified + in RFC 3032. This label value does not include the + encodings of Traffic Class and TTL (Time to Live). + The label range specified by this type is for general use, + with special-purpose MPLS label values excluded."; + reference + "RFC 3032: MPLS Label Stack Encoding."; + } + + typedef mpls-label { + type union { + type mpls-label-special-purpose; + type mpls-label-general-use; + } + description + "The 20-bit label value in an MPLS label stack as specified + in RFC 3032. This label value does not include the + encodings of Traffic Class and TTL."; + reference + "RFC 3032: MPLS Label Stack Encoding."; + } + + /*** Groupings **/ + + grouping mpls-label-stack { + description + "This grouping specifies an MPLS label stack. The label + stack is encoded as a list of label stack entries. The + list key is an identifier that indicates the relative + ordering of each entry, with the lowest-value identifier + corresponding to the top of the label stack."; + container mpls-label-stack { + description + "Container for a list of MPLS label stack entries."; + list entry { + key "id"; + description + "List of MPLS label stack entries."; + leaf id { + type uint8; + description + "Identifies the entry in a sequence of MPLS label + stack entries. An entry with a smaller identifier + value precedes an entry with a larger identifier + value in the label stack. The value of this ID has + no semantic meaning other than relative ordering + and referencing the entry."; + } + leaf label { + type rt-types:mpls-label; + description + "Label value."; + } + + leaf ttl { + type uint8; + description + "Time to Live (TTL)."; + reference + "RFC 3032: MPLS Label Stack Encoding."; + } + leaf traffic-class { + type uint8 { + range "0..7"; + } + description + "Traffic Class (TC)."; + reference + "RFC 5462: Multiprotocol Label Switching (MPLS) Label + Stack Entry: 'EXP' Field Renamed to 'Traffic Class' + Field."; + } + } + } + } + + grouping vpn-route-targets { + description + "A grouping that specifies Route Target import-export rules + used in BGP-enabled VPNs."; + reference + "RFC 4364: BGP/MPLS IP Virtual Private Networks (VPNs). + RFC 4664: Framework for Layer 2 Virtual Private Networks + (L2VPNs)."; + list vpn-target { + key "route-target"; + description + "List of Route Targets."; + leaf route-target { + type rt-types:route-target; + description + "Route Target value."; + } + leaf route-target-type { + type rt-types:route-target-type; + mandatory true; + description + "Import/export type of the Route Target."; + } + } + } + } diff --git a/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/yang/ietf-yang-types@2013-07-15.yang b/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/yang/ietf-yang-types@2013-07-15.yang new file mode 100644 index 0000000000000000000000000000000000000000..956562a7b342055127961732d8bde4be21c80d7d --- /dev/null +++ b/src/nbi/service/rest_server/nbi_plugins/ietf_network_new/yang/ietf-yang-types@2013-07-15.yang @@ -0,0 +1,475 @@ + module ietf-yang-types { + + namespace "urn:ietf:params:xml:ns:yang:ietf-yang-types"; + prefix "yang"; + + organization + "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; + + contact + "WG Web: + WG List: + + WG Chair: David Kessens + + + WG Chair: Juergen Schoenwaelder + + + Editor: Juergen Schoenwaelder + "; + + description + "This module contains a collection of generally useful derived + YANG data types. + + Copyright (c) 2013 IETF Trust and the persons identified as + authors of the code. All rights reserved. + + Redistribution and use in source and binary forms, with or + without modification, is permitted pursuant to, and subject + to the license terms contained in, the Simplified BSD License + set forth in Section 4.c of the IETF Trust's Legal Provisions + Relating to IETF Documents + (http://trustee.ietf.org/license-info). + + This version of this YANG module is part of RFC 6991; see + the RFC itself for full legal notices."; + + revision 2013-07-15 { + description + "This revision adds the following new data types: + - yang-identifier + - hex-string + - uuid + - dotted-quad"; + reference + "RFC 6991: Common YANG Data Types"; + } + + revision 2010-09-24 { + description + "Initial revision."; + reference + "RFC 6021: Common YANG Data Types"; + } + + /*** collection of counter and gauge types ***/ + + typedef counter32 { + type uint32; + description + "The counter32 type represents a non-negative integer + that monotonically increases until it reaches a + maximum value of 2^32-1 (4294967295 decimal), when it + wraps around and starts increasing again from zero. + + Counters have no defined 'initial' value, and thus, a + single value of a counter has (in general) no information + content. Discontinuities in the monotonically increasing + value normally occur at re-initialization of the + management system, and at other times as specified in the + description of a schema node using this type. If such + other times can occur, for example, the creation of + a schema node of type counter32 at times other than + re-initialization, then a corresponding schema node + should be defined, with an appropriate type, to indicate + the last discontinuity. + + The counter32 type should not be used for configuration + schema nodes. A default statement SHOULD NOT be used in + combination with the type counter32. + + In the value set and its semantics, this type is equivalent + to the Counter32 type of the SMIv2."; + reference + "RFC 2578: Structure of Management Information Version 2 + (SMIv2)"; + } + + typedef zero-based-counter32 { + type yang:counter32; + default "0"; + description + "The zero-based-counter32 type represents a counter32 + that has the defined 'initial' value zero. + + A schema node of this type will be set to zero (0) on creation + and will thereafter increase monotonically until it reaches + a maximum value of 2^32-1 (4294967295 decimal), when it + wraps around and starts increasing again from zero. + + Provided that an application discovers a new schema node + of this type within the minimum time to wrap, it can use the + 'initial' value as a delta. It is important for a management + station to be aware of this minimum time and the actual time + between polls, and to discard data if the actual time is too + long or there is no defined minimum time. + + In the value set and its semantics, this type is equivalent + to the ZeroBasedCounter32 textual convention of the SMIv2."; + reference + "RFC 4502: Remote Network Monitoring Management Information + Base Version 2"; + } + + typedef counter64 { + type uint64; + description + "The counter64 type represents a non-negative integer + that monotonically increases until it reaches a + maximum value of 2^64-1 (18446744073709551615 decimal), + when it wraps around and starts increasing again from zero. + + Counters have no defined 'initial' value, and thus, a + single value of a counter has (in general) no information + content. Discontinuities in the monotonically increasing + value normally occur at re-initialization of the + management system, and at other times as specified in the + description of a schema node using this type. If such + other times can occur, for example, the creation of + a schema node of type counter64 at times other than + re-initialization, then a corresponding schema node + should be defined, with an appropriate type, to indicate + the last discontinuity. + + The counter64 type should not be used for configuration + schema nodes. A default statement SHOULD NOT be used in + combination with the type counter64. + + In the value set and its semantics, this type is equivalent + to the Counter64 type of the SMIv2."; + reference + "RFC 2578: Structure of Management Information Version 2 + (SMIv2)"; + } + + typedef zero-based-counter64 { + type yang:counter64; + default "0"; + description + "The zero-based-counter64 type represents a counter64 that + has the defined 'initial' value zero. + + A schema node of this type will be set to zero (0) on creation + and will thereafter increase monotonically until it reaches + a maximum value of 2^64-1 (18446744073709551615 decimal), + when it wraps around and starts increasing again from zero. + + Provided that an application discovers a new schema node + of this type within the minimum time to wrap, it can use the + 'initial' value as a delta. It is important for a management + station to be aware of this minimum time and the actual time + between polls, and to discard data if the actual time is too + long or there is no defined minimum time. + + In the value set and its semantics, this type is equivalent + to the ZeroBasedCounter64 textual convention of the SMIv2."; + reference + "RFC 2856: Textual Conventions for Additional High Capacity + Data Types"; + } + + typedef gauge32 { + type uint32; + description + "The gauge32 type represents a non-negative integer, which + may increase or decrease, but shall never exceed a maximum + value, nor fall below a minimum value. The maximum value + cannot be greater than 2^32-1 (4294967295 decimal), and + the minimum value cannot be smaller than 0. The value of + a gauge32 has its maximum value whenever the information + being modeled is greater than or equal to its maximum + value, and has its minimum value whenever the information + being modeled is smaller than or equal to its minimum value. + If the information being modeled subsequently decreases + below (increases above) the maximum (minimum) value, the + gauge32 also decreases (increases). + + In the value set and its semantics, this type is equivalent + to the Gauge32 type of the SMIv2."; + reference + "RFC 2578: Structure of Management Information Version 2 + (SMIv2)"; + } + + typedef gauge64 { + type uint64; + description + "The gauge64 type represents a non-negative integer, which + may increase or decrease, but shall never exceed a maximum + value, nor fall below a minimum value. The maximum value + cannot be greater than 2^64-1 (18446744073709551615), and + the minimum value cannot be smaller than 0. The value of + a gauge64 has its maximum value whenever the information + being modeled is greater than or equal to its maximum + value, and has its minimum value whenever the information + being modeled is smaller than or equal to its minimum value. + If the information being modeled subsequently decreases + below (increases above) the maximum (minimum) value, the + gauge64 also decreases (increases). + + In the value set and its semantics, this type is equivalent + to the CounterBasedGauge64 SMIv2 textual convention defined + in RFC 2856"; + reference + "RFC 2856: Textual Conventions for Additional High Capacity + Data Types"; + } + + /*** collection of identifier-related types ***/ + + typedef object-identifier { + type string { + pattern '(([0-1](\.[1-3]?[0-9]))|(2\.(0|([1-9]\d*))))' + + '(\.(0|([1-9]\d*)))*'; + } + description + "The object-identifier type represents administratively + assigned names in a registration-hierarchical-name tree. + + Values of this type are denoted as a sequence of numerical + non-negative sub-identifier values. Each sub-identifier + value MUST NOT exceed 2^32-1 (4294967295). Sub-identifiers + are separated by single dots and without any intermediate + whitespace. + + The ASN.1 standard restricts the value space of the first + sub-identifier to 0, 1, or 2. Furthermore, the value space + of the second sub-identifier is restricted to the range + 0 to 39 if the first sub-identifier is 0 or 1. Finally, + the ASN.1 standard requires that an object identifier + has always at least two sub-identifiers. The pattern + captures these restrictions. + + Although the number of sub-identifiers is not limited, + module designers should realize that there may be + implementations that stick with the SMIv2 limit of 128 + sub-identifiers. + + This type is a superset of the SMIv2 OBJECT IDENTIFIER type + since it is not restricted to 128 sub-identifiers. Hence, + this type SHOULD NOT be used to represent the SMIv2 OBJECT + IDENTIFIER type; the object-identifier-128 type SHOULD be + used instead."; + reference + "ISO9834-1: Information technology -- Open Systems + Interconnection -- Procedures for the operation of OSI + Registration Authorities: General procedures and top + arcs of the ASN.1 Object Identifier tree"; + } + + typedef object-identifier-128 { + type object-identifier { + pattern '\d*(\.\d*){1,127}'; + } + description + "This type represents object-identifiers restricted to 128 + sub-identifiers. + + In the value set and its semantics, this type is equivalent + to the OBJECT IDENTIFIER type of the SMIv2."; + reference + "RFC 2578: Structure of Management Information Version 2 + (SMIv2)"; + } + + typedef yang-identifier { + type string { + length "1..max"; + pattern '[a-zA-Z_][a-zA-Z0-9\-_.]*'; + pattern '.|..|[^xX].*|.[^mM].*|..[^lL].*'; + } + description + "A YANG identifier string as defined by the 'identifier' + rule in Section 12 of RFC 6020. An identifier must + start with an alphabetic character or an underscore + followed by an arbitrary sequence of alphabetic or + numeric characters, underscores, hyphens, or dots. + + A YANG identifier MUST NOT start with any possible + combination of the lowercase or uppercase character + sequence 'xml'."; + reference + "RFC 6020: YANG - A Data Modeling Language for the Network + Configuration Protocol (NETCONF)"; + } + + /*** collection of types related to date and time***/ + + typedef date-and-time { + type string { + pattern '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?' + + '(Z|[\+\-]\d{2}:\d{2})'; + } + description + "The date-and-time type is a profile of the ISO 8601 + standard for representation of dates and times using the + Gregorian calendar. The profile is defined by the + date-time production in Section 5.6 of RFC 3339. + + The date-and-time type is compatible with the dateTime XML + schema type with the following notable exceptions: + + (a) The date-and-time type does not allow negative years. + + (b) The date-and-time time-offset -00:00 indicates an unknown + time zone (see RFC 3339) while -00:00 and +00:00 and Z + all represent the same time zone in dateTime. + + (c) The canonical format (see below) of data-and-time values + differs from the canonical format used by the dateTime XML + schema type, which requires all times to be in UTC using + the time-offset 'Z'. + + This type is not equivalent to the DateAndTime textual + convention of the SMIv2 since RFC 3339 uses a different + separator between full-date and full-time and provides + higher resolution of time-secfrac. + + The canonical format for date-and-time values with a known time + zone uses a numeric time zone offset that is calculated using + the device's configured known offset to UTC time. A change of + the device's offset to UTC time will cause date-and-time values + to change accordingly. Such changes might happen periodically + in case a server follows automatically daylight saving time + (DST) time zone offset changes. The canonical format for + date-and-time values with an unknown time zone (usually + referring to the notion of local time) uses the time-offset + -00:00."; + reference + "RFC 3339: Date and Time on the Internet: Timestamps + RFC 2579: Textual Conventions for SMIv2 + XSD-TYPES: XML Schema Part 2: Datatypes Second Edition"; + } + + typedef timeticks { + type uint32; + description + "The timeticks type represents a non-negative integer that + represents the time, modulo 2^32 (4294967296 decimal), in + hundredths of a second between two epochs. When a schema + node is defined that uses this type, the description of + the schema node identifies both of the reference epochs. + + In the value set and its semantics, this type is equivalent + to the TimeTicks type of the SMIv2."; + reference + "RFC 2578: Structure of Management Information Version 2 + (SMIv2)"; + } + + typedef timestamp { + type yang:timeticks; + description + "The timestamp type represents the value of an associated + timeticks schema node at which a specific occurrence + happened. The specific occurrence must be defined in the + description of any schema node defined using this type. When + the specific occurrence occurred prior to the last time the + associated timeticks attribute was zero, then the timestamp + value is zero. Note that this requires all timestamp values + to be reset to zero when the value of the associated timeticks + attribute reaches 497+ days and wraps around to zero. + + The associated timeticks schema node must be specified + in the description of any schema node using this type. + + In the value set and its semantics, this type is equivalent + to the TimeStamp textual convention of the SMIv2."; + reference + "RFC 2579: Textual Conventions for SMIv2"; + } + + /*** collection of generic address types ***/ + + typedef phys-address { + type string { + pattern '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?'; + } + + description + "Represents media- or physical-level addresses represented + as a sequence octets, each octet represented by two hexadecimal + numbers. Octets are separated by colons. The canonical + representation uses lowercase characters. + + In the value set and its semantics, this type is equivalent + to the PhysAddress textual convention of the SMIv2."; + reference + "RFC 2579: Textual Conventions for SMIv2"; + } + + typedef mac-address { + type string { + pattern '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'; + } + description + "The mac-address type represents an IEEE 802 MAC address. + The canonical representation uses lowercase characters. + + In the value set and its semantics, this type is equivalent + to the MacAddress textual convention of the SMIv2."; + reference + "IEEE 802: IEEE Standard for Local and Metropolitan Area + Networks: Overview and Architecture + RFC 2579: Textual Conventions for SMIv2"; + } + + /*** collection of XML-specific types ***/ + + typedef xpath1.0 { + type string; + description + "This type represents an XPATH 1.0 expression. + + When a schema node is defined that uses this type, the + description of the schema node MUST specify the XPath + context in which the XPath expression is evaluated."; + reference + "XPATH: XML Path Language (XPath) Version 1.0"; + } + + /*** collection of string types ***/ + + typedef hex-string { + type string { + pattern '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?'; + } + + description + "A hexadecimal string with octets represented as hex digits + separated by colons. The canonical representation uses + lowercase characters."; + } + + typedef uuid { + type string { + pattern '[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-' + + '[0-9a-fA-F]{4}-[0-9a-fA-F]{12}'; + } + description + "A Universally Unique IDentifier in the string representation + defined in RFC 4122. The canonical representation uses + lowercase characters. + + The following is an example of a UUID in string representation: + f81d4fae-7dec-11d0-a765-00a0c91e6bf6 + "; + reference + "RFC 4122: A Universally Unique IDentifier (UUID) URN + Namespace"; + } + + typedef dotted-quad { + type string { + pattern + '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}' + + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'; + } + description + "An unsigned 32-bit number expressed in the dotted-quad + notation, i.e., four octets written as decimal numbers + and separated with the '.' (full stop) character."; + } + } diff --git a/src/nbi/service/rest_server/nbi_plugins/tfs_api/__init__.py b/src/nbi/service/rest_server/nbi_plugins/tfs_api/__init__.py index 41e8ff1ea634869e69258c20f81f7c3db9767eb5..47e6095f092008ae9b03287d01d6c555ea7ef77f 100644 --- a/src/nbi/service/rest_server/nbi_plugins/tfs_api/__init__.py +++ b/src/nbi/service/rest_server/nbi_plugins/tfs_api/__init__.py @@ -62,6 +62,8 @@ RESOURCES = [ ('api.policyrule_ids', PolicyRuleIds, '/policyrule_ids'), ('api.policyrules', PolicyRules, '/policyrules'), ('api.policyrule', PolicyRule, '/policyrule/'), + + ('api.networksl3' , Networks, '/networks') ] def register_tfs_api(rest_server : RestServer): diff --git a/src/webui/service/templates/main/debug.html b/src/webui/service/templates/main/debug.html index 8956856699dc022b826a9384a2df6ac7b28a3e87..e6965cb55fff28794cf8e240be871d82dd021980 100644 --- a/src/webui/service/templates/main/debug.html +++ b/src/webui/service/templates/main/debug.html @@ -24,6 +24,7 @@
  • Dummy Contexts
  • Devices
  • Links
  • +
  • Networks
  • {% endblock %}