Example #1
0
def _get_password_data_format_response(response):
    """
    Generate a response for get password request.

    @param response: Cloudstack response.
    @return: Response
    """
    if 'errortext' in response:
        errors.invalid_instance_id()
    else:
        response = response['password']
        return {
            'template_name_or_list': 'password.xml',
            'response_type': 'GetPasswordDataResponse',
            'response': response
        }
def _get_password_data_format_response(response):
    """
    Generate a response for get password request.

    @param response: Cloudstack response.
    @return: Response
    """
    if "errortext" in response:
        errors.invalid_instance_id()
    else:
        response = response["password"]
        return {
            "template_name_or_list": "password.xml",
            "response_type": "GetPasswordDataResponse",
            "response": response,
        }
Example #3
0
def _get_password_data_format_response(response):
    """
    Generate a response for get password request.

    @param response: Cloudstack response.
    @return: Response
    """
    if 'errortext' in response:
        errors.invalid_instance_id()
    else:
        response = response['password']
        return {
            'template_name_or_list': 'password.xml',
            'response_type': 'GetPasswordDataResponse',
            'response': response
        }
Example #4
0
def _attach_volume_response(response):
    """
    Generates a response for attach volume request.

    @param response: Response from Cloudstack.
    @return: Response.
    """
    if 'errortext' in response:
        if 'specify a volume that is not attached' in response['errortext']:
            errors.invalid_volume_attached()
        elif 'Invalid parameter virtualmachineid' in response['errortext']:
            errors.invalid_instance_id()
        elif 'Invalid parameter id' in response['errortext']:
            errors.invalid_volume_id()
        else:
            errors.invalid_request(response['errortext'])

    response = response['volume']
    return {
        'template_name_or_list': 'volume_attachment.xml',
        'response_type': 'AttachVolumeResponse',
        'response': response
    }
Example #5
0
def _attach_volume_response(response):
    """
    Generates a response for attach volume request.

    @param response: Response from Cloudstack.
    @return: Response.
    """
    if 'errortext' in response:
        if 'specify a volume that is not attached' in response['errortext']:
            errors.invalid_volume_attached()
        elif 'Invalid parameter virtualmachineid' in response['errortext']:
            errors.invalid_instance_id()
        elif 'Invalid parameter id' in response['errortext']:
            errors.invalid_volume_id()
        else:
            errors.invalid_request(response['errortext'])

    response = response['volume']
    return {
        'template_name_or_list': 'volume_attachment.xml',
        'response_type': 'AttachVolumeResponse',
        'response': response
    }