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

Multiple changes and fixes:

Common:
- renamed device type OPTICAL_LINE_SYSTEM to OPEN_LINE_SYSTEM
- added DATACENTER and EMULATED_DATACENTER device types.

Context:
- modified service constraints for test object to use nomenclature "metric[unit]"
- corrected ConstraintModel dump methods

Device:
- uncommented dump methods in database ContextModel and TopologyModel

OFC'22 / OECCPSC'22 tests:
- renamed device type OPTICAL_LINE_SYSTEM to OPEN_LINE_SYSTEM

WebUI:
OFC'22 / OECCPSC'22 tests:
- renamed device type OPTICAL_LINE_SYSTEM to OPEN_LINE_SYSTEM
parent d56e5665
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -15,12 +15,14 @@
from enum import Enum

class DeviceTypeEnum(Enum):
    EMULATED_OPTICAL_LINE_SYSTEM = 'emu-optical-line-system'
    EMULATED_DATACENTER       = 'emu-datacenter'
    EMULATED_OPEN_LINE_SYSTEM = 'emu-open-line-system'
    EMULATED_PACKET_ROUTER    = 'emu-packet-router'
    DATACENTER                = 'datacenter'
    MICROVAWE_RADIO_SYSTEM    = 'microwave-radio-system'
    OPTICAL_ROADM             = 'optical-roadm'
    OPTICAL_TRANDPONDER       = 'optical-trandponder'
    OPTICAL_LINE_SYSTEM          = 'optical-line-system'
    OPEN_LINE_SYSTEM          = 'open-line-system'
    PACKET_ROUTER             = 'packet-router'
    PACKET_SWITCH             = 'packet-switch'
    P4_SWITCH                 = 'p4-switch'
+2 −2
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ from common.tools.object_factory.ConfigRule import json_config_rule_set
DEVICE_DISABLED = DeviceOperationalStatusEnum.DEVICEOPERATIONALSTATUS_DISABLED

DEVICE_EMUDC_TYPE   = DeviceTypeEnum.EMULATED_DATACENTER.value
DEVICE_EMUOLS_TYPE  = DeviceTypeEnum.EMULATED_OPTICAL_LINE_SYSTEM.value
DEVICE_EMUOLS_TYPE  = DeviceTypeEnum.EMULATED_OPEN_LINE_SYSTEM.value
DEVICE_EMUPR_TYPE   = DeviceTypeEnum.EMULATED_PACKET_ROUTER.value
DEVICE_EMU_DRIVERS  = [DeviceDriverEnum.DEVICEDRIVER_UNDEFINED]
DEVICE_EMU_ADDRESS  = '127.0.0.1'
@@ -30,7 +30,7 @@ DEVICE_EMU_PORT = '0'
DEVICE_PR_TYPE      = DeviceTypeEnum.PACKET_ROUTER.value
DEVICE_PR_DRIVERS   = [DeviceDriverEnum.DEVICEDRIVER_OPENCONFIG]

DEVICE_TAPI_TYPE    = DeviceTypeEnum.OPTICAL_LINE_SYSTEM.value
DEVICE_TAPI_TYPE    = DeviceTypeEnum.OPEN_LINE_SYSTEM.value
DEVICE_TAPI_DRIVERS = [DeviceDriverEnum.DEVICEDRIVER_TRANSPORT_API]

# check which enum type and value assign to microwave device
+7 −16
Original line number Diff line number Diff line
@@ -54,24 +54,13 @@ class ConstraintCustomModel(Model): # pylint: disable=abstract-method
    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}}
        json_endpoint_id = EndPointModel(self.database, self.endpoint_fk).dump_id()
        return {'endpoint_location': {'endpoint_id': json_endpoint_id, 'location': {'region': self.region}}}

class ConstraintEndpointLocationGpsPositionModel(Model): # pylint: disable=abstract-method
    endpoint_fk = ForeignKeyField(EndPointModel)
@@ -80,14 +69,16 @@ class ConstraintEndpointLocationGpsPositionModel(Model): # pylint: disable=abstr

    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}}
        json_endpoint_id = EndPointModel(self.database, self.endpoint_fk).dump_id()
        return {'endpoint_location': {'endpoint_id': json_endpoint_id, 'location': {'gps_position': gps_position}}}

class ConstraintEndpointPriorityModel(Model): # pylint: disable=abstract-method
    endpoint_fk = ForeignKeyField(EndPointModel)
    priority = FloatField(required=True)
    priority = IntegerField(required=True, min_value=0)

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

class ConstraintSlaAvailabilityModel(Model): # pylint: disable=abstract-method
    num_disjoint_paths = IntegerField(required=True, min_value=1)
+1 −1
Original line number Diff line number Diff line
@@ -319,7 +319,7 @@ class ContextServiceServicerImpl(ContextServiceServicer):

                result : Tuple[EndPointModel, bool] = update_or_create_object(
                    self.database, EndPointModel, str_endpoint_key, endpoint_attributes)
                db_endpoint, endpoint_updated = result
                db_endpoint, endpoint_updated = result # pylint: disable=unused-variable

                set_kpi_sample_types(self.database, db_endpoint, endpoint.kpi_sample_types)

+6 −6
Original line number Diff line number Diff line
@@ -129,8 +129,8 @@ SERVICE_R1_R2_EPIDS = [
    json_endpoint_id(DEVICE_R2_ID, 'EP100', topology_id=TOPOLOGY_ID),
]
SERVICE_R1_R2_CONST = [
    json_constraint_custom('latency_ms', '15.2'),
    json_constraint_custom('jitter_us',  '1.2'),
    json_constraint_custom('latency[ms]', '15.2'),
    json_constraint_custom('jitter[us]',  '1.2'),
]
SERVICE_R1_R2_RULES = [
    json_config_rule_set('svc/rsrc1/value', 'value7'),
@@ -149,8 +149,8 @@ SERVICE_R1_R3_EPIDS = [
    json_endpoint_id(DEVICE_R3_ID, 'EP100', topology_id=TOPOLOGY_ID),
]
SERVICE_R1_R3_CONST = [
    json_constraint_custom('latency_ms', '5.8'),
    json_constraint_custom('jitter_us',  '0.1'),
    json_constraint_custom('latency[ms]', '5.8'),
    json_constraint_custom('jitter[us]',  '0.1'),
]
SERVICE_R1_R3_RULES = [
    json_config_rule_set('svc/rsrc1/value', 'value7'),
@@ -169,8 +169,8 @@ SERVICE_R2_R3_EPIDS = [
    json_endpoint_id(DEVICE_R3_ID, 'EP100', topology_id=TOPOLOGY_ID),
]
SERVICE_R2_R3_CONST = [
    json_constraint_custom('latency_ms', '23.1'),
    json_constraint_custom('jitter_us',  '3.4'),
    json_constraint_custom('latency[ms]', '23.1'),
    json_constraint_custom('jitter[us]',  '3.4'),
]
SERVICE_R2_R3_RULES = [
    json_config_rule_set('svc/rsrc1/value', 'value7'),
Loading