Skip to content
Snippets Groups Projects
Commit fe4fb4d3 authored by Pablo Armingol's avatar Pablo Armingol
Browse files

code clean up

parent 2519f1dc
No related branches found
No related tags found
2 merge requests!294Release TeraFlowSDN 4.0,!237Resolve "(TID) Add support to NBI to export the device inventory items"
......@@ -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)
......
......@@ -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
......
# 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
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
# 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')
return json.loads(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')'''
def destroy(self) -> None:
self._yang_context.destroy()
\ No newline at end of file
# 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 nbi.service.rest_server.nbi_plugins.ietf_hardware.Hardware import Hardware
from nbi.service.rest_server.RestServer import RestServer
......
......@@ -23,9 +23,6 @@ from .Tools import (
format_grpc_to_json, grpc_connection_id, grpc_context_id, grpc_device_id, grpc_link_id, grpc_policy_rule_id,
grpc_service_id, grpc_service, grpc_slice_id, grpc_topology_id)
from nbi.service.rest_server.nbi_plugins.ietf_hardware import YangHandler
class _Resource(Resource):
def __init__(self) -> None:
super().__init__()
......@@ -176,15 +173,6 @@ class Devices(_Resource):
class Device(_Resource):
def get(self, device_uuid : str):
return format_grpc_to_json(self.client.GetDevice(grpc_device_id(device_uuid)))
class Deviceshw(_Resource):
def get(self, device_uuid : str):
device =format_grpc_to_json(self.client.GetDevice(grpc_device_id(device_uuid)))
yang_handler = YangHandler('ietf-hardware')
hardware_reply = yang_handler.compose(device)
device = jsonify(hardware_reply)
return device
class LinkIds(_Resource):
def get(self):
......
......@@ -16,7 +16,7 @@ from nbi.service.rest_server.RestServer import RestServer
from .Resources import (
Connection, ConnectionIds, Connections,
Context, ContextIds, Contexts,
Device, DeviceIds, Devices, Deviceshw,
Device, DeviceIds, Devices,
DummyContexts,
Link, LinkIds, Links,
PolicyRule, PolicyRuleIds, PolicyRules,
......@@ -51,8 +51,6 @@ RESOURCES = [
('api.devices', Devices, '/devices'),
('api.device', Device, '/device/<path:device_uuid>'),
('api.deviceshw', Deviceshw, '/device/<path:device_uuid>/hardware'),
('api.link_ids', LinkIds, '/link_ids'),
('api.links', Links, '/links'),
('api.link', Link, '/link/<path:link_uuid>'),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment