Commit f3bbb2dd authored by Waleed Akbar's avatar Waleed Akbar
Browse files

feat: Add NETCONF OC Pluggable Driver and Mock Server

- Introduced NETCONF_OC_PLUGGABLE driver in ORM_DeviceDriverEnum.
- Enhanced TelemetryBackendService to log device driver and type information.
- Improved DriverInstanceCache to handle connection failures more gracefully.
- Added new telemetry data structure and mock server for optical-channel telemetry.
- Created Dockerfile, docker-compose, and Kubernetes manifests for the NETCONF mock server.
- Implemented test scripts for running and validating the mock server.
- Updated telemetry.json with example optical-channel metrics.
- Refactored existing tests to integrate with the new mock server.
parent 104339b6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ class ORM_DeviceDriverEnum(enum.Enum):
    GNMI_NOKIA_SRLINUX    = DeviceDriverEnum.DEVICEDRIVER_GNMI_NOKIA_SRLINUX
    OPENROADM             = DeviceDriverEnum.DEVICEDRIVER_OPENROADM
    RESTCONF_OPENCONFIG   = DeviceDriverEnum.DEVICEDRIVER_RESTCONF_OPENCONFIG
    NETCONF_OC_PLUGGABLE  = DeviceDriverEnum.DEVICEDRIVER_NETCONF_OC_PLUGGABLE

grpc_to_enum__device_driver = functools.partial(
    grpc_to_enum, DeviceDriverEnum, ORM_DeviceDriverEnum)
+1 −0
Original line number Diff line number Diff line
@@ -164,6 +164,7 @@ class TelemetryBackendService(GenericGrpcService):
            device_driver = collector.get('device_driver', None)  # int: DeviceDriverEnum value
            device_type   = collector.get('device_type',   None)  # str: e.g. 'packet-router'
            if device_driver and device_type:
                LOGGER.info(f"Getting collector by meta info for KPI ID: {kpi_id} - Device Type: {device_type} - Device Driver: {device_driver}")
                self.device_collector = get_collector_by_meta_info(
                    kpi_id, device_type, device_driver,
                    self.kpi_manager_client, self.context_client, self.driver_instance_cache
+8 −2
Original line number Diff line number Diff line
@@ -60,7 +60,6 @@ class DriverInstanceCache:
                driver_instance : _Collector = driver_class(address, port, **settings)

            self._device_uuid__to__driver_instance[device_uuid] = driver_instance
            # LOGGER.info('get method finished.')
            return driver_instance

    def get_by_meta_info(
@@ -120,14 +119,21 @@ def get_driver(driver_instance_cache : DriverInstanceCache, device : Device) ->
    driver : _Collector = driver_instance_cache.get(
        device_uuid, filter_fields=driver_filter_fields, address=address, port=port, settings=settings)

    connected = False
    try:
        driver.Connect()
        connected = driver.Connect()
    except Exception as e:
        driver_instance_cache.delete(device_uuid)
        raise OperationFailedException(
            'Driver({:s}) connection to device({:s})'.format(driver.__class__.__name__, device_uuid),
            extra_details=str(e)
        ) from e
    if not connected:
        driver_instance_cache.delete(device_uuid)
        raise OperationFailedException(
            'Driver({:s}) connection to device({:s})'.format(driver.__class__.__name__, device_uuid),
            extra_details='Connect() returned False'
        )

    return driver

+2 −2
Original line number Diff line number Diff line
@@ -27,8 +27,8 @@ COLLECTOR_RECEIVED_POWER_UUID = str(uuid.uuid4())
COLLECTOR_PRE_FEC_BER_UUID    = str(uuid.uuid4())

# Router Device UUID (used in KPI Descriptor creation)
ROUTER_HUB_DEVICE_UUID  = "a79e0852-a603-5200-8de4-aeef1059c27f" # Confirm the order of the device (which one is hub/leaf?) IP1
ROUTER_LEAF_DEVICE_UUID = "ad768743-bafd-598e-b256-de435bee50c2" # Confirm the order of the device (which one is hub/leaf?) IP2
ROUTER_HUB_DEVICE_UUID  = "a79e0852-a603-5200-8de4-aeef1059c27f" # IP1
ROUTER_LEAF_DEVICE_UUID = "ad768743-bafd-598e-b256-de435bee50c2" # IP2

def create_kpi_descriptor_PRE_FEC_BER_request():
    _create_kpi_request                                = kpi_manager_pb2.KpiDescriptor()
+5 −5
Original line number Diff line number Diff line
@@ -21,13 +21,13 @@
        },
        {
            "device_id": {"device_uuid": {"uuid": "IP2"}}, "device_type": "packet-router",
            "device_drivers": ["DEVICEDRIVER_GNMI_OPENCONFIG"], "device_operational_status": "DEVICEOPERATIONALSTATUS_UNDEFINED",
            "device_drivers": ["DEVICEDRIVER_NETCONF_OC_PLUGGABLE"], "device_operational_status": "DEVICEOPERATIONALSTATUS_UNDEFINED",
            "device_config": {"config_rules": [
                {"action": "CONFIGACTION_SET", "custom": {"resource_key": "_connect/address",  "resource_value": "172.30.20.102"}},
                {"action": "CONFIGACTION_SET", "custom": {"resource_key": "_connect/port",     "resource_value": "6030"      }},
                {"action": "CONFIGACTION_SET", "custom": {"resource_key": "_connect/address",  "resource_value": "netconf-oc-optical-mock.netconf-mock.svc.cluster.local"}},
                {"action": "CONFIGACTION_SET", "custom": {"resource_key": "_connect/port",     "resource_value": "830"      }},
                {"action": "CONFIGACTION_SET", "custom": {"resource_key": "_connect/settings", "resource_value": {
                    "username": "admin",
                    "password": "admin",
                    "username": "netconf",
                    "password": "netconf",
                    "hostkey_verify": false
                }}}
            ]}
Loading