From c4eca8da38222c2811ecb6dc5c37a69aa0494e7c Mon Sep 17 00:00:00 2001 From: gifrerenom <lluis.gifre@cttc.es> Date: Thu, 25 May 2023 17:24:04 +0000 Subject: [PATCH] Context component: - Updated link_set to add the link to admin/admin context/topology by default --- src/context/service/database/Link.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/context/service/database/Link.py b/src/context/service/database/Link.py index f5bfc9dea..76db07a9e 100644 --- a/src/context/service/database/Link.py +++ b/src/context/service/database/Link.py @@ -18,9 +18,10 @@ from sqlalchemy.engine import Engine from sqlalchemy.orm import Session, selectinload, sessionmaker from sqlalchemy_cockroachdb import run_transaction from typing import Dict, List, Optional, Set, Tuple -from common.proto.context_pb2 import Link, LinkId +from common.proto.context_pb2 import Link, LinkId, TopologyId from common.method_wrappers.ServiceExceptions import NotFoundException from common.tools.object_factory.Link import json_link_id +from context.service.database.uuids.Topology import topology_get_uuid from .models.LinkModel import LinkModel, LinkEndPointModel from .models.TopologyModel import TopologyLinkModel from .uuids.EndPoint import endpoint_get_uuid @@ -67,6 +68,15 @@ def link_set(db_engine : Engine, request : Link) -> Tuple[Dict, bool]: topology_uuids : Set[str] = set() related_topologies : List[Dict] = list() + + # By default, always add link to default Context/Topology + _,topology_uuid = topology_get_uuid(TopologyId(), allow_random=False, allow_default=True) + related_topologies.append({ + 'topology_uuid': topology_uuid, + 'link_uuid' : link_uuid, + }) + topology_uuids.add(topology_uuid) + link_endpoints_data : List[Dict] = list() for i,endpoint_id in enumerate(request.link_endpoint_ids): endpoint_topology_uuid, _, endpoint_uuid = endpoint_get_uuid( -- GitLab