Commit fe4fb4d3 authored by Pablo Armingol's avatar Pablo Armingol
Browse files

code clean up

parent 2519f1dc
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -76,7 +76,6 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]:
        if not component_location is None:
            add_value_from_tag(inventory['attributes'], 'location', component_location)

       
        component_id = xml_component.find('ocp:state/ocp:id', namespaces=NAMESPACES)
        if not component_id is None:
            add_value_from_tag(inventory['attributes'], 'id', component_id)
+2 −2
Original line number Diff line number Diff line
@@ -22,12 +22,12 @@ from common.Settings import (
from .NbiService import NbiService
from .rest_server.RestServer import RestServer
from .rest_server.nbi_plugins.etsi_bwm import register_etsi_bwm_api
from .rest_server.nbi_plugins.ietf_hardware import register_ietf_hardware
from .rest_server.nbi_plugins.ietf_l2vpn import register_ietf_l2vpn
from .rest_server.nbi_plugins.ietf_l3vpn import register_ietf_l3vpn
from .rest_server.nbi_plugins.ietf_network import register_ietf_network
from .rest_server.nbi_plugins.ietf_network_slice import register_ietf_nss
from .rest_server.nbi_plugins.tfs_api import register_tfs_api
from .rest_server.nbi_plugins.ietf_hardware import register_ietf_hardware

terminate = threading.Event()
LOGGER = None
@@ -65,12 +65,12 @@ def main():

    rest_server = RestServer()
    register_etsi_bwm_api(rest_server)
    register_ietf_hardware(rest_server)
    register_ietf_l2vpn(rest_server)  # Registering L2VPN entrypoint
    register_ietf_l3vpn(rest_server)  # Registering L3VPN entrypoint
    register_ietf_network(rest_server)
    register_ietf_nss(rest_server)  # Registering NSS entrypoint
    register_tfs_api(rest_server)
    register_ietf_hardware(rest_server)
    rest_server.start()

    # Wait for Ctrl+C or termination signal
+13 −0
Original line number Diff line number Diff line
# 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
+0 −37305

File deleted.

Preview size limit exceeded, changes collapsed.

+16 −36
Original line number Diff line number Diff line
# 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 libyang, os
from common.proto.context_pb2 import Device
from typing import Dict, Optional

import json
import logging
import re
import datetime
@@ -112,41 +126,7 @@ class YangHandler:
            
            component_new.create_path('contains-child', contains_child)

        return hardware.print_mem('json')
                                    


        '''# example methods (based on openconfig, to be adapted):
        #str_path = '/interfaces/interface[name={:s}]'.format(if_name)
        if_name = 'my-if'
        interfaces = self._yang_context.create_data_path('/openconfig-interfaces:interfaces')
        my_if = interfaces.create_path('interface[name="{:s}"]'.format(if_name))
        my_if.create_path('config/name', if_name)
        my_if.create_path('config/enabled', True)

        my_subifs = my_if.create_path('subinterfaces')

        subif_index = 3
        my_subif = my_subifs.create_path('subinterface[index="{:d}"]'.format(subif_index))
        my_subif.create_path('config/index', subif_index)
        my_subif.create_path('config/enabled', True)

        vlan_id = 123
        my_subif_vlan = my_subif.create_path('openconfig-vlan:vlan')
        my_subif_vlan.create_path('match/single-tagged/config/vlan-id', vlan_id)

        my_subif_ipv4 = my_subif.create_path('openconfig-if-ip:ipv4')
        my_subif_ipv4.create_path('config/enabled', True)

        my_subif_ipv4_addrs = my_subif_ipv4.create_path('addresses')
        my_ipv4_addr_ip = '10.0.1.10'
        my_ipv4_addr_prefix = 24
        my_subif_ipv4_addr = my_subif_ipv4_addrs.create_path('address[ip="{:s}"]'.format(my_ipv4_addr_ip))
        my_subif_ipv4_addr.create_path('config/ip', my_ipv4_addr_ip)
        my_subif_ipv4_addr.create_path('config/prefix-length', my_ipv4_addr_prefix)

        return my_if.print_mem('json')'''
    
        return json.loads(hardware.print_mem('json'))
                                    
    def destroy(self) -> None:
        self._yang_context.destroy()
 No newline at end of file
Loading