Commit d5d975d9 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Interdomain component:

- Migrated logic to Release 2.0 and used new common Interdomain methods.
- Improvements detection of remote domain settings and instantiation of interdomain clients.
- Updated Topology Abstractor to consider abstract device and link names and uuids.
- Improved logging messages of Topology Abstractor
- Corrected local topology retrieval in Topology Abstractor
- Implemented DeleteSlice RPC method
- Updated helper methods to improve detection of slice owner and store it as parameter of the slice.
- Added new unitary tests
- Added new dependency on service component's client
parent 38fd7f22
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ COPY src/dlt/. dlt/
COPY src/interdomain/. interdomain/
#COPY src/monitoring/. monitoring/
COPY src/pathcomp/. pathcomp/
#COPY src/service/. service/
COPY src/service/. service/
COPY src/slice/. slice/

# Start the service
+212 −62

File changed.

Preview size limit exceeded, changes collapsed.

+22 −16

File changed.

Preview size limit exceeded, changes collapsed.

+27 −14
Original line number Diff line number Diff line
@@ -13,10 +13,11 @@
# limitations under the License.

import json, logging
from typing import List, Optional, Tuple
from typing import List, Optional, Set
from common.Constants import DEFAULT_CONTEXT_NAME, DEFAULT_TOPOLOGY_NAME, INTERDOMAIN_TOPOLOGY_NAME
from common.DeviceTypes import DeviceTypeEnum
from common.proto.context_pb2 import (
    ConfigRule, Constraint, ContextId, Device, Empty, EndPointId, Slice, SliceStatusEnum)
    ConfigRule, Constraint, ContextId, Empty, EndPointId, Slice, SliceStatusEnum)
from common.tools.context_queries.CheckType import device_type_is_network, endpoint_type_is_border
from common.tools.context_queries.InterDomain import get_local_device_uuids
from common.tools.grpc.ConfigRules import copy_config_rules
@@ -28,26 +29,31 @@ from context.client.ContextClient import ContextClient
LOGGER = logging.getLogger(__name__)

def compute_slice_owner(
    context_client : ContextClient, traversed_domains : List[Tuple[str, Device, bool, List[EndPointId]]]
    context_client : ContextClient, traversed_domain_uuids : Set[str]
) -> Optional[str]:
    traversed_domain_uuids = {traversed_domain[0] for traversed_domain in traversed_domains}

    existing_topologies = context_client.ListTopologies(ContextId(**json_context_id(DEFAULT_CONTEXT_NAME)))
    existing_topology_uuids_names = set()
    domain_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)
        domain_uuids_names.add(topology_uuid)
        domain_uuids_names.add(topology_name)

    for topology in existing_topologies.topologies:
        topology_details = context_client.GetTopologyDetails(topology.topology_id)
        for device in topology_details.devices:
            if device.device_type != DeviceTypeEnum.NETWORK.value: continue
            domain_uuids_names.discard(device.device_id.device_uuid.uuid)
            domain_uuids_names.discard(device.name)

    candidate_owner_uuids = traversed_domain_uuids.intersection(existing_topology_uuids_names)
    candidate_owner_uuids = traversed_domain_uuids.intersection(domain_uuids_names)
    if len(candidate_owner_uuids) != 1:
        data = {
            '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],
            'domain_uuids_names'    : [et_uuid for et_uuid in domain_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)))
@@ -56,17 +62,24 @@ def compute_slice_owner(
    return candidate_owner_uuids.pop()

def compose_slice(
    context_uuid : str, slice_uuid : str, endpoint_ids : List[EndPointId], constraints : List[Constraint] = [],
    config_rules : List[ConfigRule] = [], owner_uuid : Optional[str] = None
    context_uuid : str, slice_uuid : str, endpoint_ids : List[EndPointId], slice_name : Optional[str] = None,
    constraints : List[Constraint] = [], config_rules : List[ConfigRule] = [], owner_uuid : Optional[str] = None,
    owner_string : Optional[str] = None
) -> Slice:
    slice_ = Slice()
    slice_.slice_id.context_id.context_uuid.uuid = context_uuid             # pylint: disable=no-member
    slice_.slice_id.slice_uuid.uuid = slice_uuid                            # pylint: disable=no-member
    slice_.slice_status.slice_status = SliceStatusEnum.SLICESTATUS_PLANNED  # pylint: disable=no-member

    if slice_name is not None:
        slice_.name = slice_name

    if owner_uuid is not None:
        slice_.slice_owner.owner_uuid.uuid = owner_uuid                     # pylint: disable=no-member

    if owner_string is not None:
        slice_.slice_owner.owner_string = owner_string                      # pylint: disable=no-member

    if len(endpoint_ids) >= 2:
        slice_.slice_endpoint_ids.add().CopyFrom(endpoint_ids[0])           # pylint: disable=no-member
        slice_.slice_endpoint_ids.add().CopyFrom(endpoint_ids[-1])          # pylint: disable=no-member
+42 −9

File changed.

Preview size limit exceeded, changes collapsed.

Loading