Commit 1b2eef22 authored by Carlos Manso's avatar Carlos Manso
Browse files

Update scalability

parent c47c372f
Loading
Loading
Loading
Loading
+178 −132
Original line number Diff line number Diff line
@@ -13,91 +13,122 @@
# limitations under the License.

import logging, operator
from enum import Enum
from typing import Dict, List, Optional, Tuple, Type, Union
from common.orm.Database import Database
from common.orm.HighLevel import get_object, get_or_create_object, update_or_create_object
from common.orm.backend.Tools import key_to_str
from common.orm.fields.BooleanField import BooleanField
from common.orm.fields.EnumeratedField import EnumeratedField
from common.orm.fields.FloatField import FloatField
from common.orm.fields.ForeignKeyField import ForeignKeyField
from common.orm.fields.IntegerField import IntegerField
from common.orm.fields.PrimaryKeyField import PrimaryKeyField
from common.orm.fields.StringField import StringField
from common.orm.model.Model import Model
from common.proto.context_pb2 import Constraint
from common.tools.grpc.Tools import grpc_message_to_json_string
from .EndPointModel import EndPointModel, get_endpoint
from .EndPointModel import EndPointModel
from .Tools import fast_hasher, remove_dict_key
from sqlalchemy import Column, ForeignKey, String, Float, CheckConstraint, Integer, Boolean, Enum
from sqlalchemy.dialects.postgresql import UUID
from context.service.database.Base import Base
import enum

LOGGER = logging.getLogger(__name__)

class ConstraintsModel(Model): # pylint: disable=abstract-method
    pk = PrimaryKeyField()

    def delete(self) -> None:
        db_constraint_pks = self.references(ConstraintModel)
        for pk,_ in db_constraint_pks: ConstraintModel(self.database, pk).delete()
        super().delete()
class ConstraintsModel(Base): # pylint: disable=abstract-method
    __tablename__ = 'Constraints'
    constraints_uuid = Column(UUID(as_uuid=False), primary_key=True, unique=True)

    def dump(self) -> List[Dict]:
        db_constraint_pks = self.references(ConstraintModel)
        constraints = [ConstraintModel(self.database, pk).dump(include_position=True) for pk,_ in db_constraint_pks]
    @staticmethod
    def main_pk_name():
        return 'constraints_uuid'


    def dump(self, constraints) -> List[Dict]:
        constraints = sorted(constraints, key=operator.itemgetter('position'))
        return [remove_dict_key(constraint, 'position') for constraint in constraints]

class ConstraintCustomModel(Model): # pylint: disable=abstract-method
    constraint_type = StringField(required=True, allow_empty=False)
    constraint_value = StringField(required=True, allow_empty=False)

class ConstraintCustomModel(Base): # pylint: disable=abstract-method
    __tablename__ = 'ConstraintCustom'
    constraint_uuid = Column(UUID(as_uuid=False), primary_key=True, unique=True)
    constraint_type = Column(String, nullable=False)
    constraint_value = Column(String, nullable=False)

    @staticmethod
    def main_pk_name():
        return 'constraint_uuid'


    def dump(self) -> Dict: # pylint: disable=arguments-differ
        return {'custom': {'constraint_type': self.constraint_type, 'constraint_value': self.constraint_value}}


Union_ConstraintEndpoint = Union[
    'ConstraintEndpointLocationGpsPositionModel', 'ConstraintEndpointLocationRegionModel',
    'ConstraintEndpointPriorityModel'
]
def dump_endpoint_id(endpoint_constraint : Union_ConstraintEndpoint):
    db_endpoints_pks = list(endpoint_constraint.references(EndPointModel))
    num_endpoints = len(db_endpoints_pks)
    if num_endpoints != 1:
        raise Exception('Wrong number({:d}) of associated Endpoints with constraint'.format(num_endpoints))
    db_endpoint = EndPointModel(endpoint_constraint.database, db_endpoints_pks[0])
    return db_endpoint.dump_id()

class ConstraintEndpointLocationRegionModel(Model): # pylint: disable=abstract-method
    endpoint_fk = ForeignKeyField(EndPointModel)
    region = StringField(required=True, allow_empty=False)

    def dump(self) -> Dict: # pylint: disable=arguments-differ
        return {'endpoint_location': {'endpoint_id': dump_endpoint_id(self), 'region': self.region}}

class ConstraintEndpointLocationGpsPositionModel(Model): # pylint: disable=abstract-method
    endpoint_fk = ForeignKeyField(EndPointModel)
    latitude = FloatField(required=True, min_value=-90.0, max_value=90.0)
    longitude = FloatField(required=True, min_value=-180.0, max_value=180.0)
# def dump_endpoint_id(endpoint_constraint: Union_ConstraintEndpoint):
#     db_endpoints_pks = list(endpoint_constraint.references(EndPointModel))
#     num_endpoints = len(db_endpoints_pks)
#     if num_endpoints != 1:
#         raise Exception('Wrong number({:d}) of associated Endpoints with constraint'.format(num_endpoints))
#     db_endpoint = EndPointModel(endpoint_constraint.database, db_endpoints_pks[0])
#     return db_endpoint.dump_id()

    def dump(self) -> Dict: # pylint: disable=arguments-differ
        gps_position = {'latitude': self.latitude, 'longitude': self.longitude}
        return {'endpoint_location': {'endpoint_id': dump_endpoint_id(self), 'gps_position': gps_position}}

class ConstraintEndpointPriorityModel(Model): # pylint: disable=abstract-method
    endpoint_fk = ForeignKeyField(EndPointModel)
    priority = FloatField(required=True)
class ConstraintEndpointLocationRegionModel(Base): # pylint: disable=abstract-method
    __tablename__ = 'ConstraintEndpointLocationRegion'
    constraint_uuid = Column(UUID(as_uuid=False), primary_key=True, unique=True)
    endpoint_uuid = Column(UUID(as_uuid=False), ForeignKey("EndPoint.endpoint_uuid"))
    region = Column(String, nullable=False)

    @staticmethod
    def main_pk_name():
        return 'constraint_uuid'

    def dump(self, endpoint) -> Dict: # pylint: disable=arguments-differ
        return {'endpoint_location': {'endpoint_id': endpoint.dump_id(), 'region': self.region}}

    def dump(self) -> Dict: # pylint: disable=arguments-differ
        return {'endpoint_priority': {'endpoint_id': dump_endpoint_id(self), 'priority': self.priority}}

class ConstraintSlaAvailabilityModel(Model): # pylint: disable=abstract-method
    num_disjoint_paths = IntegerField(required=True, min_value=1)
    all_active = BooleanField(required=True)
class ConstraintEndpointLocationGpsPositionModel(Base): # pylint: disable=abstract-method
    __tablename__ = 'ConstraintEndpointLocationGpsPosition'
    constraint_uuid = Column(UUID(as_uuid=False), primary_key=True, unique=True)
    endpoint_uuid = Column(UUID(as_uuid=False), ForeignKey("EndPoint.endpoint_uuid"))
    latitude = Column(Float, CheckConstraint('latitude > -90.0 AND latitude < 90.0'), nullable=False)
    longitude = Column(Float, CheckConstraint('longitude > -90.0 AND longitude < 90.0'), nullable=False)

    def dump(self, endpoint) -> Dict: # pylint: disable=arguments-differ
        gps_position = {'latitude': self.latitude, 'longitude': self.longitude}
        return {'endpoint_location': {'endpoint_id': endpoint.dump_id(), 'gps_position': gps_position}}


class ConstraintEndpointPriorityModel(Base): # pylint: disable=abstract-method
    __tablename__ = 'ConstraintEndpointPriority'
    constraint_uuid = Column(UUID(as_uuid=False), primary_key=True, unique=True)
    endpoint_uuid = Column(UUID(as_uuid=False), ForeignKey("EndPoint.endpoint_uuid"))
    # endpoint_fk = ForeignKeyField(EndPointModel)
    # priority = FloatField(required=True)
    priority = Column(Float, nullable=False)
    @staticmethod
    def main_pk_name():
        return 'constraint_uuid'

    def dump(self, endpoint) -> Dict: # pylint: disable=arguments-differ
        return {'endpoint_priority': {'endpoint_id': endpoint.dump_id(), 'priority': self.priority}}


class ConstraintSlaAvailabilityModel(Base): # pylint: disable=abstract-method
    __tablename__ = 'ConstraintSlaAvailability'
    constraint_uuid = Column(UUID(as_uuid=False), primary_key=True, unique=True)
    # num_disjoint_paths = IntegerField(required=True, min_value=1)
    num_disjoint_paths = Column(Integer, CheckConstraint('num_disjoint_paths > 1'), nullable=False)
    # all_active = BooleanField(required=True)
    all_active = Column(Boolean, nullable=False)
    @staticmethod
    def main_pk_name():
        return 'constraint_uuid'

    def dump(self) -> Dict: # pylint: disable=arguments-differ
        return {'sla_availability': {'num_disjoint_paths': self.num_disjoint_paths, 'all_active': self.all_active}}

# enum values should match name of field in ConstraintModel
class ConstraintKindEnum(Enum):
class ConstraintKindEnum(enum.Enum):
    CUSTOM                        = 'custom'
    ENDPOINT_LOCATION_REGION      = 'ep_loc_region'
    ENDPOINT_LOCATION_GPSPOSITION = 'ep_loc_gpspos'
@@ -109,41 +140,56 @@ Union_SpecificConstraint = Union[
    ConstraintEndpointPriorityModel, ConstraintSlaAvailabilityModel,
]

class ConstraintModel(Model): # pylint: disable=abstract-method
    pk = PrimaryKeyField()
    constraints_fk = ForeignKeyField(ConstraintsModel)
    kind = EnumeratedField(ConstraintKindEnum)
    position = IntegerField(min_value=0, required=True)
    constraint_custom_fk        = ForeignKeyField(ConstraintCustomModel, required=False)
    constraint_ep_loc_region_fk = ForeignKeyField(ConstraintEndpointLocationRegionModel, required=False)
    constraint_ep_loc_gpspos_fk = ForeignKeyField(ConstraintEndpointLocationGpsPositionModel, required=False)
    constraint_ep_priority_fk   = ForeignKeyField(ConstraintEndpointPriorityModel, required=False)
    constraint_sla_avail_fk     = ForeignKeyField(ConstraintSlaAvailabilityModel, required=False)

    def delete(self) -> None:
        field_name = 'constraint_{:s}_fk'.format(str(self.kind.value))
        specific_fk_value : Optional[ForeignKeyField] = getattr(self, field_name, None)
        if specific_fk_value is None:
            raise Exception('Unable to find constraint key for field_name({:s})'.format(field_name))
        specific_fk_class = getattr(ConstraintModel, field_name, None)
        foreign_model_class : Model = specific_fk_class.foreign_model
        super().delete()
        get_object(self.database, foreign_model_class, str(specific_fk_value)).delete()
class ConstraintModel(Base): # pylint: disable=abstract-method
    __tablename__ = 'Constraint'
    # pk = PrimaryKeyField()
    # constraints_fk = ForeignKeyField(ConstraintsModel)
    constraints_uuid = Column(UUID(as_uuid=False), ForeignKey("Constraints.constraints_uuid"), primary_key=True)
    # kind = EnumeratedField(ConstraintKindEnum)
    kind = Column(Enum(ConstraintKindEnum, create_constraint=False, native_enum=False))
    # position = IntegerField(min_value=0, required=True)
    position = Column(Integer, CheckConstraint('position >= 0'), nullable=False)
    # constraint_custom_fk        = ForeignKeyField(ConstraintCustomModel, required=False)
    constraint_custom = Column(UUID(as_uuid=False), ForeignKey("ConstraintCustom.constraint_uuid"))
    # constraint_ep_loc_region_fk = ForeignKeyField(ConstraintEndpointLocationRegionModel, required=False)
    constraint_ep_loc_region = Column(UUID(as_uuid=False), ForeignKey("ConstraintEndpointLocationRegion.constraint_uuid"))
    # constraint_ep_loc_gpspos_fk = ForeignKeyField(ConstraintEndpointLocationGpsPositionModel, required=False)
    constraint_ep_loc_gpspos = Column(UUID(as_uuid=False), ForeignKey("ConstraintEndpointLocationGpsPosition.constraint_uuid"))
    # constraint_ep_priority_fk   = ForeignKeyField(ConstraintEndpointPriorityModel, required=False)
    constraint_ep_priority = Column(UUID(as_uuid=False), ForeignKey("ConstraintEndpointPriority.constraint_uuid"),)
    # constraint_sla_avail_fk     = ForeignKeyField(ConstraintSlaAvailabilityModel, required=False)
    constraint_sla_avail = Column(UUID(as_uuid=False), ForeignKey("ConstraintSlaAvailability.constraint_uuid"))

    @staticmethod
    def main_pk_name():
        return 'constraint_uuid'

    # def delete(self) -> None:
    #     field_name = 'constraint_{:s}_fk'.format(str(self.kind.value))
    #     specific_fk_value : Optional[ForeignKeyField] = getattr(self, field_name, None)
    #     if specific_fk_value is None:
    #         raise Exception('Unable to find constraint key for field_name({:s})'.format(field_name))
    #     specific_fk_class = getattr(ConstraintModel, field_name, None)
    #     foreign_model_class : Model = specific_fk_class.foreign_model
    #     super().delete()
    #     get_object(self.database, foreign_model_class, str(specific_fk_value)).delete()

    def dump(self, include_position=True) -> Dict: # pylint: disable=arguments-differ
        field_name = 'constraint_{:s}_fk'.format(str(self.kind.value))
        specific_fk_value : Optional[ForeignKeyField] = getattr(self, field_name, None)
        field_name = 'constraint_{:s}'.format(str(self.kind.value))
        specific_fk_value = getattr(self, field_name, None)
        if specific_fk_value is None:
            raise Exception('Unable to find constraint key for field_name({:s})'.format(field_name))
        specific_fk_class = getattr(ConstraintModel, field_name, None)
        foreign_model_class : Model = specific_fk_class.foreign_model
        foreign_model_class: Base = specific_fk_class.foreign_model
        constraint: Union_SpecificConstraint = get_object(self.database, foreign_model_class, str(specific_fk_value))
        result = constraint.dump()
        if include_position: result['position'] = self.position
        if include_position:
            result['position'] = self.position
        return result

Tuple_ConstraintSpecs = Tuple[Type, str, Dict, ConstraintKindEnum]
def parse_constraint_custom(database : Database, grpc_constraint) -> Tuple_ConstraintSpecs:

def parse_constraint_custom(grpc_constraint) -> Tuple_ConstraintSpecs:
    constraint_class = ConstraintCustomModel
    str_constraint_id = grpc_constraint.custom.constraint_type
    constraint_data = {
@@ -152,11 +198,11 @@ def parse_constraint_custom(database : Database, grpc_constraint) -> Tuple_Const
    }
    return constraint_class, str_constraint_id, constraint_data, ConstraintKindEnum.CUSTOM

def parse_constraint_endpoint_location(database : Database, grpc_constraint) -> Tuple_ConstraintSpecs:
def parse_constraint_endpoint_location(db_endpoint, grpc_constraint) -> Tuple_ConstraintSpecs:
    grpc_endpoint_id = grpc_constraint.endpoint_location.endpoint_id
    str_endpoint_key, db_endpoint = get_endpoint(database, grpc_endpoint_id)
    # str_endpoint_key, db_endpoint = get_endpoint(database, grpc_endpoint_id)

    str_constraint_id = str_endpoint_key
    str_constraint_id = db_endpoint.endpoint_uuid
    constraint_data = {'endpoint_fk': db_endpoint}

    grpc_location = grpc_constraint.endpoint_location.location
@@ -174,18 +220,18 @@ def parse_constraint_endpoint_location(database : Database, grpc_constraint) ->
        MSG = 'Location kind {:s} in Constraint of kind endpoint_location is not implemented: {:s}'
        raise NotImplementedError(MSG.format(location_kind, grpc_message_to_json_string(grpc_constraint)))

def parse_constraint_endpoint_priority(database : Database, grpc_constraint) -> Tuple_ConstraintSpecs:
def parse_constraint_endpoint_priority(db_endpoint, grpc_constraint) -> Tuple_ConstraintSpecs:
    grpc_endpoint_id = grpc_constraint.endpoint_priority.endpoint_id
    str_endpoint_key, db_endpoint = get_endpoint(database, grpc_endpoint_id)
    # str_endpoint_key, db_endpoint = get_endpoint(database, grpc_endpoint_id)

    constraint_class = ConstraintEndpointPriorityModel
    str_constraint_id = str_endpoint_key
    str_constraint_id = db_endpoint.endpoint_uuid
    priority = grpc_constraint.endpoint_priority.priority
    constraint_data = {'endpoint_fk': db_endpoint, 'priority': priority}

    return constraint_class, str_constraint_id, constraint_data, ConstraintKindEnum.ENDPOINT_PRIORITY

def parse_constraint_sla_availability(database : Database, grpc_constraint) -> Tuple_ConstraintSpecs:
def parse_constraint_sla_availability(grpc_constraint) -> Tuple_ConstraintSpecs:
    constraint_class = ConstraintSlaAvailabilityModel
    str_constraint_id = ''
    constraint_data = {
@@ -206,50 +252,50 @@ Union_ConstraintModel = Union[
    ConstraintEndpointPriorityModel, ConstraintSlaAvailabilityModel
]

def set_constraint(
    database : Database, db_constraints : ConstraintsModel, grpc_constraint : Constraint, position : int
) -> Tuple[Union_ConstraintModel, bool]:
    grpc_constraint_kind = str(grpc_constraint.WhichOneof('constraint'))

    parser = CONSTRAINT_PARSERS.get(grpc_constraint_kind)
    if parser is None:
        raise NotImplementedError('Constraint of kind {:s} is not implemented: {:s}'.format(
            grpc_constraint_kind, grpc_message_to_json_string(grpc_constraint)))

    # create specific constraint
    constraint_class, str_constraint_id, constraint_data, constraint_kind = parser(database, grpc_constraint)
    str_constraint_key_hash = fast_hasher(':'.join([constraint_kind.value, str_constraint_id]))
    str_constraint_key = key_to_str([db_constraints.pk, str_constraint_key_hash], separator=':')
    result : Tuple[Union_ConstraintModel, bool] = update_or_create_object(
        database, constraint_class, str_constraint_key, constraint_data)
    db_specific_constraint, updated = result

    # create generic constraint
    constraint_fk_field_name = 'constraint_{:s}_fk'.format(constraint_kind.value)
    constraint_data = {
        'constraints_fk': db_constraints, 'position': position, 'kind': constraint_kind,
        constraint_fk_field_name: db_specific_constraint
    }
    result : Tuple[ConstraintModel, bool] = update_or_create_object(
        database, ConstraintModel, str_constraint_key, constraint_data)
    db_constraint, updated = result

    return db_constraint, updated

def set_constraints(
    database : Database, db_parent_pk : str, constraints_name : str, grpc_constraints
) -> List[Tuple[Union[ConstraintsModel, ConstraintModel], bool]]:

    str_constraints_key = key_to_str([db_parent_pk, constraints_name], separator=':')
    result : Tuple[ConstraintsModel, bool] = get_or_create_object(database, ConstraintsModel, str_constraints_key)
    db_constraints, created = result

    db_objects = [(db_constraints, created)]

    for position,grpc_constraint in enumerate(grpc_constraints):
        result : Tuple[ConstraintModel, bool] = set_constraint(
            database, db_constraints, grpc_constraint, position)
        db_constraint, updated = result
        db_objects.append((db_constraint, updated))

    return db_objects
# def set_constraint(
#     db_constraints : ConstraintsModel, grpc_constraint : Constraint, position : int
# ) -> Tuple[Union_ConstraintModel, bool]:
#     grpc_constraint_kind = str(grpc_constraint.WhichOneof('constraint'))
#
#     parser = CONSTRAINT_PARSERS.get(grpc_constraint_kind)
#     if parser is None:
#         raise NotImplementedError('Constraint of kind {:s} is not implemented: {:s}'.format(
#             grpc_constraint_kind, grpc_message_to_json_string(grpc_constraint)))
#
#     # create specific constraint
#     constraint_class, str_constraint_id, constraint_data, constraint_kind = parser(database, grpc_constraint)
#     str_constraint_key_hash = fast_hasher(':'.join([constraint_kind.value, str_constraint_id]))
#     str_constraint_key = key_to_str([db_constraints.pk, str_constraint_key_hash], separator=':')
#     result : Tuple[Union_ConstraintModel, bool] = update_or_create_object(
#         database, constraint_class, str_constraint_key, constraint_data)
#     db_specific_constraint, updated = result
#
#     # create generic constraint
#     constraint_fk_field_name = 'constraint_{:s}_fk'.format(constraint_kind.value)
#     constraint_data = {
#         'constraints_fk': db_constraints, 'position': position, 'kind': constraint_kind,
#         constraint_fk_field_name: db_specific_constraint
#     }
#     result : Tuple[ConstraintModel, bool] = update_or_create_object(
#         database, ConstraintModel, str_constraint_key, constraint_data)
#     db_constraint, updated = result
#
#     return db_constraint, updated
#
# def set_constraints(
#     database : Database, db_parent_pk : str, constraints_name : str, grpc_constraints
# ) -> List[Tuple[Union[ConstraintsModel, ConstraintModel], bool]]:
#
#     str_constraints_key = key_to_str([db_parent_pk, constraints_name], separator=':')
#     result : Tuple[ConstraintsModel, bool] = get_or_create_object(database, ConstraintsModel, str_constraints_key)
#     db_constraints, created = result
#
#     db_objects = [(db_constraints, created)]
#
#     for position,grpc_constraint in enumerate(grpc_constraints):
#         result : Tuple[ConstraintModel, bool] = set_constraint(
#             database, db_constraints, grpc_constraint, position)
#         db_constraint, updated = result
#         db_objects.append((db_constraint, updated))
#
#     return db_objects
+27 −27
Original line number Diff line number Diff line
@@ -99,30 +99,30 @@ def set_kpi_sample_types(database : Database, db_endpoint : EndPointModel, grpc_
        db_endpoint_kpi_sample_type.kpi_sample_type = orm_kpi_sample_type
        db_endpoint_kpi_sample_type.save()
"""
def get_endpoint(
    database : Database, grpc_endpoint_id : EndPointId,
    validate_topology_exists : bool = True, validate_device_in_topology : bool = True
) -> Tuple[str, EndPointModel]:
    endpoint_uuid                  = grpc_endpoint_id.endpoint_uuid.uuid
    endpoint_device_uuid           = grpc_endpoint_id.device_id.device_uuid.uuid
    endpoint_topology_uuid         = grpc_endpoint_id.topology_id.topology_uuid.uuid
    endpoint_topology_context_uuid = grpc_endpoint_id.topology_id.context_id.context_uuid.uuid
    str_endpoint_key = key_to_str([endpoint_device_uuid, endpoint_uuid])

    if len(endpoint_topology_context_uuid) > 0 and len(endpoint_topology_uuid) > 0:
        # check topology exists
        str_topology_key = key_to_str([endpoint_topology_context_uuid, endpoint_topology_uuid])
        if validate_topology_exists:
            from .TopologyModel import TopologyModel
            get_object(database, TopologyModel, str_topology_key)

        # check device is in topology
        str_topology_device_key = key_to_str([str_topology_key, endpoint_device_uuid], separator='--')
        if validate_device_in_topology:
            from .RelationModels import TopologyDeviceModel
            get_object(database, TopologyDeviceModel, str_topology_device_key)

        str_endpoint_key = key_to_str([str_endpoint_key, str_topology_key], separator=':')

    db_endpoint : EndPointModel = get_object(database, EndPointModel, str_endpoint_key)
    return str_endpoint_key, db_endpoint
# def get_endpoint(
#     database : Database, grpc_endpoint_id : EndPointId,
#     validate_topology_exists : bool = True, validate_device_in_topology : bool = True
# ) -> Tuple[str, EndPointModel]:
#     endpoint_uuid                  = grpc_endpoint_id.endpoint_uuid.uuid
#     endpoint_device_uuid           = grpc_endpoint_id.device_id.device_uuid.uuid
#     endpoint_topology_uuid         = grpc_endpoint_id.topology_id.topology_uuid.uuid
#     endpoint_topology_context_uuid = grpc_endpoint_id.topology_id.context_id.context_uuid.uuid
#     str_endpoint_key = key_to_str([endpoint_device_uuid, endpoint_uuid])
#
#     if len(endpoint_topology_context_uuid) > 0 and len(endpoint_topology_uuid) > 0:
#         # check topology exists
#         str_topology_key = key_to_str([endpoint_topology_context_uuid, endpoint_topology_uuid])
#         if validate_topology_exists:
#             from .TopologyModel import TopologyModel
#             get_object(database, TopologyModel, str_topology_key)
#
#         # check device is in topology
#         str_topology_device_key = key_to_str([str_topology_key, endpoint_device_uuid], separator='--')
#         if validate_device_in_topology:
#             from .RelationModels import TopologyDeviceModel
#             get_object(database, TopologyDeviceModel, str_topology_device_key)
#
#         str_endpoint_key = key_to_str([str_endpoint_key, str_topology_key], separator=':')
#
#     db_endpoint : EndPointModel = get_object(database, EndPointModel, str_endpoint_key)
#     return str_endpoint_key, db_endpoint
+37 −24

File changed.

Preview size limit exceeded, changes collapsed.

+139 −68

File changed.

Preview size limit exceeded, changes collapsed.

+5 −5
Original line number Diff line number Diff line
@@ -128,11 +128,11 @@ LINK_R1_R3 = json_link(LINK_R1_R3_UUID, LINK_R1_R3_EPIDS)


# ----- Service --------------------------------------------------------------------------------------------------------
SERVICE_R1_R2_UUID  = 'SVC:R1/EP100-R2/EP100'
SERVICE_R1_R2_UUID  = 'f0432e7b-bb83-4880-9c5d-008c4925ce7d'
SERVICE_R1_R2_ID    = json_service_id(SERVICE_R1_R2_UUID, context_id=CONTEXT_ID)
SERVICE_R1_R2_EPIDS = [
    json_endpoint_id(DEVICE_R1_ID, 'EP100', topology_id=TOPOLOGY_ID),
    json_endpoint_id(DEVICE_R2_ID, 'EP100', topology_id=TOPOLOGY_ID),
    json_endpoint_id(DEVICE_R1_ID, EP100, topology_id=TOPOLOGY_ID),
    json_endpoint_id(DEVICE_R2_ID, EP100, topology_id=TOPOLOGY_ID),
]
SERVICE_R1_R2_CONST = [
    json_constraint('latency_ms', '15.2'),
@@ -148,7 +148,7 @@ SERVICE_R1_R2 = json_service_l3nm_planned(
    config_rules=SERVICE_R1_R2_RULES)


SERVICE_R1_R3_UUID  = 'SVC:R1/EP100-R3/EP100'
SERVICE_R1_R3_UUID  = 'fab21cef-542a-4948-bb4a-a0468abfa925'
SERVICE_R1_R3_ID    = json_service_id(SERVICE_R1_R3_UUID, context_id=CONTEXT_ID)
SERVICE_R1_R3_EPIDS = [
    json_endpoint_id(DEVICE_R1_ID, 'EP100', topology_id=TOPOLOGY_ID),
@@ -168,7 +168,7 @@ SERVICE_R1_R3 = json_service_l3nm_planned(
    config_rules=SERVICE_R1_R3_RULES)


SERVICE_R2_R3_UUID  = 'SVC:R2/EP100-R3/EP100'
SERVICE_R2_R3_UUID  = '1f2a808f-62bb-4eaa-94fb-448ed643e61a'
SERVICE_R2_R3_ID    = json_service_id(SERVICE_R2_R3_UUID, context_id=CONTEXT_ID)
SERVICE_R2_R3_EPIDS = [
    json_endpoint_id(DEVICE_R2_ID, 'EP100', topology_id=TOPOLOGY_ID),
Loading