Commit 2d7b16ca authored by Carlos Manso's avatar Carlos Manso
Browse files

first functional version e2e_orchestrator

parent c3e31051
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -43,10 +43,10 @@ spec:
              key: REDIS_PASSWORD
        readinessProbe:
          exec:
            command: ["/bin/grpc_health_probe", "-addr=:10009"]
            command: ["/bin/grpc_health_probe", "-addr=:10040"]
        livenessProbe:
          exec:
            command: ["/bin/grpc_health_probe", "-addr=:10009"]
            command: ["/bin/grpc_health_probe", "-addr=:10040"]
        resources:
          requests:
            cpu: 250m
+1 −0
Original line number Diff line number Diff line
@@ -201,6 +201,7 @@ enum DeviceDriverEnum {
  DEVICEDRIVER_XR = 6;
  DEVICEDRIVER_IETF_L2VPN = 7;
  DEVICEDRIVER_GNMI_OPENCONFIG = 8;
  DEVICEDRIVER_FLEXSCALE = 9;
}

enum DeviceOperationalStatusEnum {
+1 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ class ORM_DeviceDriverEnum(enum.Enum):
    XR                    = DeviceDriverEnum.DEVICEDRIVER_XR
    IETF_L2VPN            = DeviceDriverEnum.DEVICEDRIVER_IETF_L2VPN
    GNMI_OPENCONFIG       = DeviceDriverEnum.DEVICEDRIVER_GNMI_OPENCONFIG
    FLEXSCALE             = DeviceDriverEnum.DEVICEDRIVER_FLEXSCALE

grpc_to_enum__device_driver = functools.partial(
    grpc_to_enum, DeviceDriverEnum, ORM_DeviceDriverEnum)
+10 −0
Original line number Diff line number Diff line
@@ -148,3 +148,13 @@ if LOAD_ALL_DEVICE_DRIVERS:
                FilterFieldEnum.DRIVER     : DeviceDriverEnum.DEVICEDRIVER_XR,
            }
        ]))

if LOAD_ALL_DEVICE_DRIVERS:
    from .flexscale.FlexScaleDriver import FlexScaleDriver # pylint: disable=wrong-import-position
    DRIVERS.append(
        (FlexScaleDriver, [
            {
                FilterFieldEnum.DEVICE_TYPE: DeviceTypeEnum.OPEN_LINE_SYSTEM,
                FilterFieldEnum.DRIVER: DeviceDriverEnum.DEVICEDRIVER_FLEXSCALE,
            }
        ]))
+24 −5
Original line number Diff line number Diff line
@@ -20,6 +20,9 @@ from common.type_checkers.Checkers import chk_string, chk_type
from device.service.driver_api._Driver import _Driver
from . import ALL_RESOURCE_KEYS
from .Tools import find_key, add_lightpath, del_lightpath, get_lightpaths
from device.service.driver_api._Driver import _Driver, RESOURCE_ENDPOINTS
from device.service.drivers.ietf_l2vpn.TfsDebugApiClient import TfsDebugApiClient
from device.service.driver_api.ImportTopologyEnum import ImportTopologyEnum, get_import_topology

LOGGER = logging.getLogger(__name__)

@@ -37,9 +40,19 @@ class FlexScaleDriver(_Driver):
        password = self.settings.get('password')
        self.__auth = HTTPBasicAuth(username, password) if username is not None and password is not None else None
        scheme = self.settings.get('scheme', 'http')
        self.dac = TfsDebugApiClient(self.address, int(self.port), scheme=scheme, username=username, password=password)
        self.__flexscale_root = '{:s}://{:s}:{:d}'.format(scheme, self.address, int(self.port))
        self.__timeout = int(self.settings.get('timeout', 120))

        # Options are:
        #    disabled --> just import endpoints as usual
        #    devices  --> imports sub-devices but not links connecting them.
        #                 (a remotely-controlled transport domain might exist between them)
        #    topology --> imports sub-devices and links connecting them.
        #                 (not supported by XR driver)
        self.__import_topology = get_import_topology(self.settings, default=ImportTopologyEnum.TOPOLOGY)
        

    def Connect(self) -> bool:
        url = self.__flexscale_root + '/OpticalTFS/GetLightpaths'
        with self.__lock:
@@ -75,8 +88,13 @@ class FlexScaleDriver(_Driver):
            for i, resource_key in enumerate(resource_keys):
                str_resource_name = 'resource_key[#{:d}]'.format(i)
                chk_string(str_resource_name, resource_key, allow_empty=False)
                results.extend(get_lightpaths(
                    self.__flexscale_root, resource_key, timeout=self.__timeout, auth=self.__auth))

                if resource_key == RESOURCE_ENDPOINTS:
                    # return endpoints through debug-api and list-devices method
                    results.extend(self.dac.get_devices_endpoints(self.__import_topology))

                # results.extend(get_lightpaths(
                #     self.__flexscale_root, resource_key, timeout=self.__timeout, auth=self.__auth))
        return results

    @metered_subclass_method(METRICS_POOL)
@@ -88,12 +106,13 @@ class FlexScaleDriver(_Driver):
            for _, resource in resources:
                LOGGER.info('resource = {:s}'.format(str(resource)))

                src_node = find_key(resource, 'src_node')
                dst_node = find_key(resource, 'dst_node')
                bitrate = find_key(resource, 'bitrate')
                src_node = '1' # find_key(resource, 'src_node')
                dst_node = '2' # find_key(resource, 'dst_node')
                bitrate =  '3' # find_key(resource, 'bitrate')

                response = add_lightpath(self.__flexscale_root, src_node, dst_node, bitrate, 
                                     auth=self.__auth, timeout=self.__timeout)

                results.extend(response)
        return results

Loading