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

Interdomain component:

- Added to client method to delete slice
- Corrected computation of slice owner
parent 3afe3f8b
No related branches found
No related tags found
2 merge requests!142Release TeraFlowSDN 2.1,!119Migration of Interdomain component and OECC/PSC'22 test to Release 2
......@@ -15,7 +15,7 @@
import grpc, logging
from common.Constants import ServiceNameEnum
from common.Settings import get_service_host, get_service_port_grpc
from common.proto.context_pb2 import AuthenticationResult, Slice, SliceId, SliceStatus, TeraFlowController
from common.proto.context_pb2 import AuthenticationResult, Empty, Slice, SliceId, SliceStatus, TeraFlowController
from common.proto.interdomain_pb2_grpc import InterdomainServiceStub
from common.tools.client.RetryDecorator import retry, delay_exponential
from common.tools.grpc.Tools import grpc_message_to_json_string
......@@ -45,13 +45,6 @@ class InterdomainClient:
self.channel = None
self.stub = None
@RETRY_DECORATOR
def RequestSlice(self, request : Slice) -> SliceId:
LOGGER.debug('RequestSlice request: {:s}'.format(grpc_message_to_json_string(request)))
response = self.stub.RequestSlice(request)
LOGGER.debug('RequestSlice result: {:s}'.format(grpc_message_to_json_string(response)))
return response
@RETRY_DECORATOR
def Authenticate(self, request : TeraFlowController) -> AuthenticationResult:
LOGGER.debug('Authenticate request: {:s}'.format(grpc_message_to_json_string(request)))
......@@ -59,6 +52,13 @@ class InterdomainClient:
LOGGER.debug('Authenticate result: {:s}'.format(grpc_message_to_json_string(response)))
return response
@RETRY_DECORATOR
def RequestSlice(self, request : Slice) -> SliceId:
LOGGER.debug('RequestSlice request: {:s}'.format(grpc_message_to_json_string(request)))
response = self.stub.RequestSlice(request)
LOGGER.debug('RequestSlice result: {:s}'.format(grpc_message_to_json_string(response)))
return response
@RETRY_DECORATOR
def LookUpSlice(self, request : Slice) -> SliceId:
LOGGER.debug('LookUpSlice request: {:s}'.format(grpc_message_to_json_string(request)))
......@@ -79,3 +79,24 @@ class InterdomainClient:
response = self.stub.CreateSliceAndAddToCatalog(request)
LOGGER.debug('CreateSliceAndAddToCatalog result: {:s}'.format(grpc_message_to_json_string(response)))
return response
@RETRY_DECORATOR
def OrderSliceWithSLA(self, request : Slice) -> SliceId:
LOGGER.debug('OrderSliceWithSLA request: {:s}'.format(grpc_message_to_json_string(request)))
response = self.stub.OrderSliceWithSLA(request)
LOGGER.debug('OrderSliceWithSLA result: {:s}'.format(grpc_message_to_json_string(response)))
return response
@RETRY_DECORATOR
def UpdateSlice(self, request : Slice) -> Slice:
LOGGER.debug('UpdateSlice request: {:s}'.format(grpc_message_to_json_string(request)))
response = self.stub.UpdateSlice(request)
LOGGER.debug('UpdateSlice result: {:s}'.format(grpc_message_to_json_string(response)))
return response
@RETRY_DECORATOR
def DeleteSlice(self, request : SliceId) -> Empty:
LOGGER.debug('DeleteSlice request: {:s}'.format(grpc_message_to_json_string(request)))
response = self.stub.DeleteSlice(request)
LOGGER.debug('DeleteSlice result: {:s}'.format(grpc_message_to_json_string(response)))
return response
......@@ -32,19 +32,23 @@ def compute_slice_owner(
) -> Optional[str]:
traversed_domain_uuids = {traversed_domain[0] for traversed_domain in traversed_domains}
existing_topology_ids = context_client.ListTopologyIds(ContextId(**json_context_id(DEFAULT_CONTEXT_NAME)))
existing_topology_uuids = {
topology_id.topology_uuid.uuid for topology_id in existing_topology_ids.topology_ids
}
existing_topology_uuids.discard(DEFAULT_TOPOLOGY_NAME)
existing_topology_uuids.discard(INTERDOMAIN_TOPOLOGY_NAME)
candidate_owner_uuids = traversed_domain_uuids.intersection(existing_topology_uuids)
existing_topologies = context_client.ListTopologies(ContextId(**json_context_id(DEFAULT_CONTEXT_NAME)))
existing_topology_uuids_names = set()
DISCARD_TOPOLOGY_NAMES = {DEFAULT_TOPOLOGY_NAME, INTERDOMAIN_TOPOLOGY_NAME}
for topology in existing_topologies.topologies:
topology_uuid = topology.topology_id.topology_uuid.uuid
if topology_uuid in DISCARD_TOPOLOGY_NAMES: continue
topology_name = topology.name
if topology_name in DISCARD_TOPOLOGY_NAMES: continue
existing_topology_uuids_names.add(topology_uuid)
existing_topology_uuids_names.add(topology_name)
candidate_owner_uuids = traversed_domain_uuids.intersection(existing_topology_uuids_names)
if len(candidate_owner_uuids) != 1:
data = {
'traversed_domain_uuids' : [td_uuid for td_uuid in traversed_domain_uuids ],
'existing_topology_uuids': [et_uuid for et_uuid in existing_topology_uuids],
'candidate_owner_uuids' : [co_uuid for co_uuid in candidate_owner_uuids ],
'traversed_domain_uuids' : [td_uuid for td_uuid in traversed_domain_uuids ],
'existing_topology_uuids_names': [et_uuid for et_uuid in existing_topology_uuids_names],
'candidate_owner_uuids' : [co_uuid for co_uuid in candidate_owner_uuids ],
}
LOGGER.warning('Unable to identify slice owner: {:s}'.format(json.dumps(data)))
return None
......
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