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

Merge branch 'feat/224-cttc-add-openflow-support-through-ryu-sdn-controller' into 'develop'

Resolve "(CTTC) Add OpenFlow support through Ryu SDN controller"

See merge request !296
parents 15854638 5e522dc1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -231,6 +231,7 @@ enum DeviceDriverEnum {
  DEVICEDRIVER_NCE = 15;
  DEVICEDRIVER_SMARTNIC = 16;
  DEVICEDRIVER_MORPHEUS = 17;
  DEVICEDRIVER_RYU = 18;
}

enum DeviceOperationalStatusEnum {
+1 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ class DeviceTypeEnum(Enum):
    QKD_NODE                        = 'qkd-node'
    OPEN_ROADM                      = 'openroadm'
    MORPHEUS                        = 'morpheus'
    OPENFLOW_RYU_CONTROLLER         = 'openflow-ryu-controller'

    # ETSI TeraFlowSDN controller
    TERAFLOWSDN_CONTROLLER          = 'teraflowsdn'
+1 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ class ORM_DeviceDriverEnum(enum.Enum):
    QKD                   = DeviceDriverEnum.DEVICEDRIVER_QKD
    SMARTNIC              = DeviceDriverEnum.DEVICEDRIVER_SMARTNIC
    MORPHEUS              = DeviceDriverEnum.DEVICEDRIVER_MORPHEUS
    RYU                   = DeviceDriverEnum.DEVICEDRIVER_RYU

grpc_to_enum__device_driver = functools.partial(
    grpc_to_enum, DeviceDriverEnum, ORM_DeviceDriverEnum)
+12 −13
Original line number Diff line number Diff line
@@ -100,11 +100,6 @@ def check_no_endpoints(device_endpoints) -> None:
def get_device_controller_uuid(device : Device) -> Optional[str]:
    controller_uuid = device.controller_id.device_uuid.uuid
    if len(controller_uuid) > 0: return controller_uuid
    #for config_rule in device.device_config.config_rules:
    #    if config_rule.WhichOneof('config_rule') != 'custom': continue
    #    if config_rule.custom.resource_key != '_controller': continue
    #    device_controller_id = json.loads(config_rule.custom.resource_value)
    #    return device_controller_id['uuid']
    return None

def populate_endpoints(
@@ -161,14 +156,18 @@ def populate_endpoints(
            _sub_device.device_type = resource_value['type']
            _sub_device.device_operational_status = resource_value['status']
            
            # Sub-devices should not have a driver assigned. Instead, they should have
            # a config rule specifying their controller.
            #_sub_device.device_drivers.extend(resource_value['drivers'])        # pylint: disable=no-member
            #controller_config_rule = _sub_device.device_config.config_rules.add()
            #controller_config_rule.action = ConfigActionEnum.CONFIGACTION_SET
            #controller_config_rule.custom.resource_key = '_controller'
            #controller = {'uuid': device_uuid, 'name': device_name}
            #controller_config_rule.custom.resource_value = json.dumps(controller, indent=0, sort_keys=True)
            # Sub-devices might not have a driver assigned.
            if 'drivers' in resource_value:
                drivers = resource_value['drivers']
                if isinstance(drivers, (list, set)):
                    _sub_device.device_drivers.extend(drivers)  # pylint: disable=no-member
                elif isinstance(drivers, (int, str)):
                    _sub_device.device_drivers.append(drivers)  # pylint: disable=no-member
                else:
                    MSG = 'Unsupported drivers definition in sub-device({:s}, {:s})'
                    raise Exception(MSG.format(str(resource_key), str(resource_value)))

            # Sub-devices should always have a controller associated.
            _sub_device.controller_id.device_uuid.uuid = device_uuid

            new_sub_devices[_sub_device_uuid] = _sub_device
+10 −0
Original line number Diff line number Diff line
@@ -193,6 +193,16 @@ if LOAD_ALL_DEVICE_DRIVERS:
                FilterFieldEnum.DRIVER     : DeviceDriverEnum.DEVICEDRIVER_IETF_NETWORK_TOPOLOGY,
            }
        ]))
if LOAD_ALL_DEVICE_DRIVERS:
    from .ryu.RyuDriver import RyuDriver
    DRIVERS.append(
        (RyuDriver, [
            {
                FilterFieldEnum.DEVICE_TYPE: DeviceTypeEnum.OPENFLOW_RYU_CONTROLLER,
                FilterFieldEnum.DRIVER     : DeviceDriverEnum.DEVICEDRIVER_RYU,
            }
        ])
    )

if LOAD_ALL_DEVICE_DRIVERS:
    from .xr.XrDriver import XrDriver # pylint: disable=wrong-import-position
Loading