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

Context component:

- add device to default context/topology by default
parent ba0565e7
No related branches found
No related tags found
2 merge requests!54Release 2.0.0,!45Bug fixes and improvements related to device configuration and monitoring
...@@ -19,9 +19,10 @@ from sqlalchemy.orm import Session, sessionmaker ...@@ -19,9 +19,10 @@ from sqlalchemy.orm import Session, sessionmaker
from sqlalchemy_cockroachdb import run_transaction from sqlalchemy_cockroachdb import run_transaction
from typing import Dict, List, Optional, Set, Tuple from typing import Dict, List, Optional, Set, Tuple
from common.method_wrappers.ServiceExceptions import InvalidArgumentException, NotFoundException from common.method_wrappers.ServiceExceptions import InvalidArgumentException, NotFoundException
from common.proto.context_pb2 import Device, DeviceId from common.proto.context_pb2 import Device, DeviceId, TopologyId
from common.tools.grpc.Tools import grpc_message_to_json_string from common.tools.grpc.Tools import grpc_message_to_json_string
from common.tools.object_factory.Device import json_device_id from common.tools.object_factory.Device import json_device_id
from context.service.database.uuids.Topology import topology_get_uuid
from .models.DeviceModel import DeviceModel from .models.DeviceModel import DeviceModel
from .models.EndPointModel import EndPointModel from .models.EndPointModel import EndPointModel
from .models.TopologyModel import TopologyDeviceModel from .models.TopologyModel import TopologyDeviceModel
...@@ -73,6 +74,15 @@ def device_set(db_engine : Engine, request : Device) -> Tuple[Dict, bool]: ...@@ -73,6 +74,15 @@ def device_set(db_engine : Engine, request : Device) -> Tuple[Dict, bool]:
topology_uuids : Set[str] = set() topology_uuids : Set[str] = set()
related_topologies : List[Dict] = list() related_topologies : List[Dict] = list()
# By default, always add device to default Context/Topology
_,topology_uuid = topology_get_uuid(TopologyId(), allow_random=False, allow_default=True)
related_topologies.append({
'topology_uuid': topology_uuid,
'device_uuid' : device_uuid,
})
topology_uuids.add(topology_uuid)
endpoints_data : List[Dict] = list() endpoints_data : List[Dict] = list()
for i, endpoint in enumerate(request.device_endpoints): for i, endpoint in enumerate(request.device_endpoints):
endpoint_device_uuid = endpoint.endpoint_id.device_id.device_uuid.uuid endpoint_device_uuid = endpoint.endpoint_id.device_id.device_uuid.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