Commit 0ae442f6 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

DLT Connector component:

- Added name to automatic creation of context for remote domains.
parent 33abdf49
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -13,11 +13,11 @@
# limitations under the License.

import grpc, json, logging, threading
from typing import Any, Dict, Set
from typing import Set
from common.Constants import DEFAULT_CONTEXT_NAME, DEFAULT_TOPOLOGY_NAME, INTERDOMAIN_TOPOLOGY_NAME
from common.proto.context_pb2 import ContextId, Device, EventTypeEnum, Link, Slice, TopologyId
from common.proto.dlt_connector_pb2 import DltSliceId
from common.proto.dlt_gateway_pb2 import DltRecordEvent, DltRecordOperationEnum, DltRecordTypeEnum
from common.proto.dlt_gateway_pb2 import DltRecordEvent, DltRecordTypeEnum
from common.tools.context_queries.Context import create_context
from common.tools.context_queries.Device import add_device_to_topology
from common.tools.context_queries.Link import add_link_to_topology
@@ -117,9 +117,10 @@ class DltEventDispatcher(threading.Thread):
            record = clients.dlt_gateway_client.GetFromDlt(event.record_id)
            LOGGER.info('[_dispatch_device] record={:s}'.format(grpc_message_to_json_string(record)))

            create_context(clients.context_client, domain_uuid)
            create_topology(clients.context_client, domain_uuid, DEFAULT_TOPOLOGY_NAME)
            device = Device(**json.loads(record.data_json))
            device_name = None if len(device.name) == 0 else device.name
            create_context(clients.context_client, domain_uuid, name=device_name)
            create_topology(clients.context_client, domain_uuid, DEFAULT_TOPOLOGY_NAME)
            clients.context_client.SetDevice(device)
            device_uuid = device.device_id.device_uuid.uuid # pylint: disable=no-member
            add_device_to_topology(clients.context_client, ADMIN_CONTEXT_ID, INTERDOMAIN_TOPOLOGY_NAME, device_uuid)