def check_datastore(datastore_name):
    """ Check datastore with given name is a valid datastore or not """
    if datastore_name == auth_data_const.DEFAULT_DS:
        return None

    if not vmdk_utils.validate_datastore(datastore_name):
        error_info = error_code.generate_error_info(ErrorCode.DS_NOT_EXIST, datastore_name)
        return error_info

    return None
Esempio n. 2
0
def check_default_datastore(datastore_name):
    """
        Check datastore with given name is a valid value for default_datastore
        Returns None for success and err message for errors
    """
    # The valid default_datastore name are:
    # named datastore existing on the host
    # hard coded datastore name "_VM_DS"
    # "_ALL_DS" is not a valid value to set as "default_datastore"
    if datastore_name == auth_data_const.VM_DS:
        return None
    if datastore_name == auth_data_const.ALL_DS:
        return generate_error_info(ErrorCode.DS_DEFAULT_CANNOT_USE_ALL_DS)

    if not vmdk_utils.validate_datastore(datastore_name):
        error_info = generate_error_info(ErrorCode.DS_NOT_EXIST, datastore_name)
        return error_info

    return None