Improvement to show names instead of UUIDs for devices and endpoints in WebUI

Common - Proto:

  • Added gRPC method to retrieve names of endpoints and devices
  • Added gRPC method to retrieve topology details

Common - Tools - Context Query:

  • Added method to request device/endpoint names from a list of endpoint identifiers

Context component:

  • Implemented method to retrieve names of endpoints and devices
  • Implemented method to retrieve topology details

WebUI component:

  • Updated link/service/slice list/detail pages to show device/endpoint names instead of UUIDs

Merge request reports

Loading
+25 −0
Changes for proto/context.proto: 25 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ service ContextService {
  rpc ListTopologyIds    (ContextId     ) returns (       TopologyIdList  ) {}
  rpc ListTopologies     (ContextId     ) returns (       TopologyList    ) {}
  rpc GetTopology        (TopologyId    ) returns (       Topology        ) {}
  rpc GetTopologyDetails (TopologyId    ) returns (       TopologyDetails ) {}
  rpc SetTopology        (Topology      ) returns (       TopologyId      ) {}
  rpc RemoveTopology     (TopologyId    ) returns (       Empty           ) {}
  rpc GetTopologyEvents  (Empty         ) returns (stream TopologyEvent   ) {}
@@ -40,6 +41,8 @@ service ContextService {
  rpc RemoveDevice       (DeviceId      ) returns (       Empty           ) {}
  rpc GetDeviceEvents    (Empty         ) returns (stream DeviceEvent     ) {}

  rpc ListEndPointNames  (EndPointIdList) returns (       EndPointNameList) {}

  rpc ListLinkIds        (Empty         ) returns (       LinkIdList      ) {}
  rpc ListLinks          (Empty         ) returns (       LinkList        ) {}
  rpc GetLink            (LinkId        ) returns (       Link            ) {}
@@ -135,6 +138,13 @@ message Topology {
  repeated LinkId link_ids = 4;
}

message TopologyDetails {
  TopologyId topology_id = 1;
  string name = 2;
  repeated Device devices = 3;
  repeated Link links = 4;
}

message TopologyIdList {
  repeated TopologyId topology_ids = 1;
}
@@ -413,6 +423,21 @@ message EndPoint {
  Location endpoint_location = 5;
}

message EndPointName {
  EndPointId endpoint_id = 1;
  string device_name = 2;
  string endpoint_name = 3;
  string endpoint_type = 4;
}

message EndPointIdList {
  repeated EndPointId endpoint_ids = 1;
}

message EndPointNameList {
  repeated EndPointName endpoint_names = 1;
}


// ----- Configuration -------------------------------------------------------------------------------------------------
enum ConfigActionEnum {
+46 −0
Changes for src/common/tools/context_queries/EndPoint.py: 46 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/)
#
# 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 typing import Dict, List, Set, Tuple
from common.proto.context_pb2 import EndPointId, EndPointIdList
from context.client.ContextClient import ContextClient

LOGGER = logging.getLogger(__name__)

TYPE_DEVICE_NAMES   = Dict[str, str]             # device_uuid => device_name
TYPE_ENDPOINTS_DATA = Dict[str, Tuple[str, str]] # endpoint_uuid => (endpoint_name, endpoint_type)
TYPE_NAME_MAPS      = Tuple[TYPE_DEVICE_NAMES, TYPE_ENDPOINTS_DATA]

def get_endpoint_names(context_client : ContextClient, endpoint_ids : List[EndPointId]) -> TYPE_NAME_MAPS:
    endpoint_uuids_to_names : Set[str] = set()
    endpoint_id_list = EndPointIdList()
    for endpoint_id in endpoint_ids:
        endpoint_uuid = endpoint_id.endpoint_uuid.uuid
        if endpoint_uuid in endpoint_uuids_to_names: continue
        endpoint_id_list.endpoint_ids.add().CopyFrom(endpoint_id)   # pylint: disable=no-member
        endpoint_uuids_to_names.add(endpoint_uuid)

    endpoint_names = context_client.ListEndPointNames(endpoint_id_list)

    device_names   : TYPE_DEVICE_NAMES   = dict()
    endpoints_data : TYPE_ENDPOINTS_DATA = dict()
    for endpoint_name in endpoint_names.endpoint_names:
        device_uuid = endpoint_name.endpoint_id.device_id.device_uuid.uuid
        device_names[device_uuid] = endpoint_name.device_name

        endpoint_uuid = endpoint_name.endpoint_id.endpoint_uuid.uuid
        endpoints_data[endpoint_uuid] = (endpoint_name.endpoint_name, endpoint_name.endpoint_type)

    return device_names, endpoints_data
+16 −2
Changes for src/context/client/ContextClient.py: 16 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -22,11 +22,11 @@ from common.proto.context_pb2 import (
    Connection, ConnectionEvent, ConnectionId, ConnectionIdList, ConnectionList,
    Context, ContextEvent, ContextId, ContextIdList, ContextList,
    Device, DeviceEvent, DeviceId, DeviceIdList, DeviceList,
    Empty,
    Empty, EndPointIdList, EndPointNameList,
    Link, LinkEvent, LinkId, LinkIdList, LinkList,
    Service, ServiceEvent, ServiceId, ServiceIdList, ServiceList,
    Slice, SliceEvent, SliceId, SliceIdList, SliceList,
    Topology, TopologyEvent, TopologyId, TopologyIdList, TopologyList)
    Topology, TopologyDetails, TopologyEvent, TopologyId, TopologyIdList, TopologyList)
from common.proto.context_pb2_grpc import ContextServiceStub
from common.proto.context_policy_pb2_grpc import ContextPolicyServiceStub
from common.proto.policy_pb2 import PolicyRuleIdList, PolicyRuleId, PolicyRuleList, PolicyRule
@@ -143,6 +143,13 @@ class ContextClient:
        LOGGER.debug('GetTopologyEvents result: {:s}'.format(grpc_message_to_json_string(response)))
        return response

    @RETRY_DECORATOR
    def GetTopologyDetails(self, request: TopologyId) -> TopologyDetails:
        LOGGER.debug('GetTopologyDetails request: {:s}'.format(grpc_message_to_json_string(request)))
        response = self.stub.GetTopologyDetails(request)
        LOGGER.debug('GetTopologyDetails result: {:s}'.format(grpc_message_to_json_string(response)))
        return response

    @RETRY_DECORATOR
    def ListDeviceIds(self, request: Empty) -> DeviceIdList:
        LOGGER.debug('ListDeviceIds request: {:s}'.format(grpc_message_to_json_string(request)))
@@ -185,6 +192,13 @@ class ContextClient:
        LOGGER.debug('GetDeviceEvents result: {:s}'.format(grpc_message_to_json_string(response)))
        return response

    @RETRY_DECORATOR
    def ListEndPointNames(self, request: EndPointIdList) -> EndPointNameList:
        LOGGER.debug('ListEndPointNames request: {:s}'.format(grpc_message_to_json_string(request)))
        response = self.stub.ListEndPointNames(request)
        LOGGER.debug('ListEndPointNames result: {:s}'.format(grpc_message_to_json_string(response)))
        return response

    @RETRY_DECORATOR
    def ListLinkIds(self, request: Empty) -> LinkIdList:
        LOGGER.debug('ListLinkIds request: {:s}'.format(grpc_message_to_json_string(request)))
+8 −0
Changes for src/context/service/database/models/EndPointModel.py: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -51,3 +51,11 @@ class EndPointModel(_Base):
            'endpoint_type'   : self.endpoint_type,
            'kpi_sample_types': [kst.value for kst in self.kpi_sample_types],
        }

    def dump_name(self) -> Dict:
        return {
            'endpoint_id'  : self.dump_id(),
            'device_name'  : self.device.device_name,
            'endpoint_name': self.name,
            'endpoint_type': self.endpoint_type,
        }
+8 −0
Changes for src/context/service/database/models/TopologyModel.py: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -45,6 +45,14 @@ class TopologyModel(_Base):
            'link_ids'   : [{'link_uuid'  : {'uuid': tl.link_uuid  }} for tl in self.topology_links  ],
        }

    def dump_details(self) -> Dict:
        return {
            'topology_id': self.dump_id(),
            'name'       : self.topology_name,
            'devices'    : [td.device.dump() for td in self.topology_devices],
            'links'      : [tl.link.dump()   for tl in self.topology_links  ],
        }

class TopologyDeviceModel(_Base):
    __tablename__ = 'topology_device'

Loading
Loading