def _attach_volume_response()

in ec2stack/providers/cloudstack/volumes.py [0: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
    }