Esempio n. 1
0
def get_object_id_info(full_object_id, object_type):
    logger.debug("getting {0} info for id : {1}".format(
        object_type, full_object_id))
    splitted_object_id = full_object_id.split(
        config.PARAMETERS_OBJECT_ID_INFO_DELIMITER)
    system_id, wwn, internal_id = None, None, None
    if len(splitted_object_id) == 2:
        array_type, object_id = splitted_object_id
    elif len(splitted_object_id) == 3:
        array_type, system_id, object_id = splitted_object_id
    else:
        raise ObjectIdError(object_type, full_object_id)
    splitted_id = object_id.split(config.PARAMETERS_OBJECT_IDS_DELIMITER)
    if len(splitted_id) == 1:
        wwn = splitted_id[0]
    elif len(splitted_id) == 2:
        internal_id, wwn = splitted_id
    else:
        raise ObjectIdError(object_type, full_object_id)
    logger.debug("volume id : {0}, array type :{1}".format(
        object_id, array_type))
    return ObjectIdInfo(array_type=array_type,
                        system_id=system_id,
                        internal_id=internal_id,
                        object_id=wwn)
def _validate_source_info(source, source_type):
    source_object = getattr(source, source_type)
    logger.info("Source {0} specified: {1}".format(source_type, source_object))
    source_object_id = getattr(source_object, config.VOLUME_SOURCE_ID_FIELDS[source_type])
    if not source_object_id:
        raise ValidationException(messages.volume_source_id_is_missing.format(source_type))
    if config.PARAMETERS_OBJECT_ID_DELIMITER not in source_object_id:
        raise ObjectIdError(source_type, source_object_id)
def _get_object_id_info(full_object_id, object_type):
    logger.debug("getting {0} info for id : {1}".format(
        object_type, full_object_id))
    splitted_object_id = full_object_id.split(
        config.PARAMETERS_OBJECT_ID_DELIMITER)
    if len(splitted_object_id) != 2:
        raise ObjectIdError(object_type, full_object_id)

    array_type, object_id = splitted_object_id
    logger.debug("volume id : {0}, array type :{1}".format(
        object_id, array_type))
    return array_type, object_id
Esempio n. 4
0
def _validate_object_id(
        object_id,
        object_type=config.VOLUME_TYPE_NAME,
        message=messages.volume_id_should_not_be_empty_message):
    logger.debug("validating volume id")
    if not object_id:
        raise ValidationException(message)
    if config.PARAMETERS_OBJECT_ID_INFO_DELIMITER not in object_id:
        raise ObjectIdError(object_type, object_id)
    if len(object_id.split(
            config.PARAMETERS_OBJECT_ID_INFO_DELIMITER)) not in {
                config.MINIMUM_VOLUME_ID_PARTS, config.MAXIMUM_VOLUME_ID_PARTS
            }:
        raise ValidationException(messages.volume_id_wrong_format_message)
def validate_create_volume_source(request):
    source = request.volume_content_source
    if source:
        logger.info(source)
        if source.HasField(config.VOLUME_SOURCE_SNAPSHOT):
            source_snapshot = source.snapshot
            logger.info(
                "Source snapshot specified: {0}".format(source_snapshot))
            source_snapshot_id = source_snapshot.snapshot_id
            if not source_snapshot_id:
                raise ValidationException(
                    messages.volume_src_snapshot_id_is_missing)
            if config.PARAMETERS_OBJECT_ID_DELIMITER not in source_snapshot_id:
                raise ObjectIdError(config.OBJECT_TYPE_NAME_SNAPSHOT,
                                    source_snapshot_id)
        elif source.HasField(config.VOLUME_SOURCE_VOLUME):
            raise ValidationException(
                messages.volume_cloning_not_supported_message)