From eab52c6b5063def9780b3e2ff41d496825f5bd56 Mon Sep 17 00:00:00 2001 From: gifrerenom <lluis.gifre@cttc.es> Date: Mon, 23 Jan 2023 09:35:44 +0000 Subject: [PATCH] PathComp component: - forced context/topology uuids in backend request for simplicity; to be elaborated - improved formatting of request to be sent to backend in logs --- .../frontend/service/algorithms/_Algorithm.py | 2 +- .../service/algorithms/tools/ComposeRequest.py | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/pathcomp/frontend/service/algorithms/_Algorithm.py b/src/pathcomp/frontend/service/algorithms/_Algorithm.py index a24ef7693..5c49a1fec 100644 --- a/src/pathcomp/frontend/service/algorithms/_Algorithm.py +++ b/src/pathcomp/frontend/service/algorithms/_Algorithm.py @@ -93,7 +93,7 @@ class _Algorithm: def execute(self, dump_request_filename : Optional[str] = None, dump_reply_filename : Optional[str] = None) -> None: request = {'serviceList': self.service_list, 'deviceList': self.device_list, 'linkList': self.link_list} - self.logger.debug('[execute] request={:s}'.format(str(request))) + self.logger.debug('[execute] request={:s}'.format(json.dumps(request, sort_keys=True, indent=4))) if dump_request_filename is not None: with open(dump_request_filename, 'w', encoding='UTF-8') as f: f.write(json.dumps(request, sort_keys=True, indent=4)) diff --git a/src/pathcomp/frontend/service/algorithms/tools/ComposeRequest.py b/src/pathcomp/frontend/service/algorithms/tools/ComposeRequest.py index 0a424bf8b..8412632ed 100644 --- a/src/pathcomp/frontend/service/algorithms/tools/ComposeRequest.py +++ b/src/pathcomp/frontend/service/algorithms/tools/ComposeRequest.py @@ -24,18 +24,24 @@ LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__) -def compose_topology_id(topology_id : TopologyId) -> Dict: - context_uuid = topology_id.context_id.context_uuid.uuid - topology_uuid = topology_id.topology_uuid.uuid +def compose_topology_id(topology_id : TopologyId) -> Dict: # pylint: disable=unused-argument + # force context_uuid and topology_uuid to be always DEFAULT_CONTEXT_NAME and DEFAULT_TOPOLOGY_NAME for simplicity + # for interdomain, contexts and topologies are managed in particular ways - if len(context_uuid) == 0: context_uuid = DEFAULT_CONTEXT_NAME - if len(topology_uuid) == 0: topology_uuid = DEFAULT_TOPOLOGY_NAME + context_uuid = DEFAULT_CONTEXT_NAME + #context_uuid = topology_id.context_id.context_uuid.uuid + #if len(context_uuid) == 0: context_uuid = DEFAULT_CONTEXT_NAME + + topology_uuid = DEFAULT_TOPOLOGY_NAME + #topology_uuid = topology_id.topology_uuid.uuid + #if len(topology_uuid) == 0: topology_uuid = DEFAULT_TOPOLOGY_NAME return {'contextId': context_uuid, 'topology_uuid': topology_uuid} def compose_service_id(service_id : ServiceId) -> Dict: # force context_uuid to be always DEFAULT_CONTEXT_NAME for simplicity - # for interdomain contexts are managed in a particular way + # for interdomain, contexts are managed in particular ways + #context_uuid = service_id.context_id.context_uuid.uuid #if len(context_uuid) == 0: context_uuid = DEFAULT_CONTEXT_NAME context_uuid = DEFAULT_CONTEXT_NAME -- GitLab