Skip to content
Snippets Groups Projects
Commit e47151d6 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Pre-merge code cleanup

parent 67e371ea
No related branches found
No related tags found
2 merge requests!294Release TeraFlowSDN 4.0,!251Resolve "(TID) Add inventory NBI to WebUI"
......@@ -50,4 +50,4 @@ class Hardware(Resource):
LOGGER.exception(MSG.format(str(device_uuid)))
response = jsonify({'error': str(e)})
response.status_code = HTTP_SERVERERROR
return response
\ No newline at end of file
return response
# 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
......@@ -33,4 +47,4 @@ class HardwareMultipleDevices(Resource):
MSG = 'Something went wrong Retrieving Hardware of Devices({:s})'
response = jsonify({'error': str(e)})
response.status_code = HTTP_SERVERERROR
return response
\ No newline at end of file
return response
......@@ -89,10 +89,9 @@ class YangHandler:
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)
#Añadir resto de atributos en IETF
......@@ -100,7 +99,7 @@ class YangHandler:
physical_index += 1
component_new.create_path('description', attributes["description"].replace('/"',""))
if "CHASSIS" not in component.type:
parent_component_references = component_new.create_path('parent-component-references')
parent = parent_component_references.create_path('component-reference[index="{:d}"]'.format(physical_index))
......@@ -124,7 +123,7 @@ class YangHandler:
component_new.create_path('is-fru', True)
elif 'false' in removable:
component_new.create_path('is-fru', False)
if attributes["id"]:
try:
if "CHASSIS" in component.type :
......@@ -137,8 +136,6 @@ class YangHandler:
continue
component_new.create_path('uri', component.name)
component_new.create_path('uuid', component.component_uuid.uuid)
for child in device.components:
......@@ -146,6 +143,6 @@ class YangHandler:
component_new.create_path('contained-child', child.component_uuid.uuid)
return json.loads(hardware.print_mem('json'))
def destroy(self) -> None:
self._yang_context.destroy()
\ No newline at end of file
self._yang_context.destroy()
......@@ -16,10 +16,9 @@ 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=<path:device_uuid>/ietf-network-hardware-inventory:network-hardware-inventory"
URL_PREFIX_hardware = "/restconf/data/ietf-network-hardware-inventory:network-hardware-inventory"
URL_PREFIX_DEVICE = "/restconf/data/device=<path:device_uuid>/ietf-network-hardware-inventory:network-hardware-inventory"
URL_PREFIX_HARDWARE = "/restconf/data/ietf-network-hardware-inventory:network-hardware-inventory"
def register_ietf_hardware(rest_server: RestServer):
rest_server.add_resource(Hardware, URL_PREFIX_device)
rest_server.add_resource(HardwareMultipleDevices, URL_PREFIX_hardware)
\ No newline at end of file
rest_server.add_resource(Hardware, URL_PREFIX_DEVICE)
rest_server.add_resource(HardwareMultipleDevices, URL_PREFIX_HARDWARE)
......@@ -49,9 +49,8 @@ RESOURCES = [
('api.slice', Slice, '/context/<path:context_uuid>/slice/<path:slice_uuid>'),
('api.device_ids', DeviceIds, '/device_ids'),
('api.devices', HardwareMultipleDevices, '/devices'),
('api.device', Hardware, '/device/<path:device_uuid>'),
('api.devices', Devices, '/devices'),
('api.device', Device, '/device/<path:device_uuid>'),
('api.link_ids', LinkIds, '/link_ids'),
('api.links', Links, '/links'),
......
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