Exemple #1
0
def _run_instance_response(response):
    """
    Generates a response for a run instance request.

    @param response: Response from Cloudstack.
    @return: Response.
    """
    if 'errortext' in response:
        if 'Object vm_template' in response['errortext']:
            errors.invalid_image_id()
        elif 'Object security_group' in response['errortext']:
            errors.invalid_security_group()
        elif 'A key pair with name' in response['errortext']:
            errors.invalid_keypair_name()
        else:
            errors.invalid_request(response['errortext'])
    else:
        response = response['virtualmachine']
        response = {
            'template_name_or_list': 'run_instance.xml',
            'response_type': 'RunInstancesResponse',
            'response': response
        }

    return response
def _run_instance_response(response):
    """
    Generates a response for a run instance request.

    @param response: Response from Cloudstack.
    @return: Response.
    """
    if 'errortext' in response:
        if 'Object vm_template' in response['errortext']:
            errors.invalid_image_id()
        elif 'Object security_group' in response['errortext']:
            errors.invalid_security_group()
        elif 'A key pair with name' in response['errortext']:
            errors.invalid_keypair_name()
        else:
            errors.invalid_request(response['errortext'])
    else:
        response = response['virtualmachine']
        response = {
            'template_name_or_list': 'run_instance.xml',
            'response_type': 'RunInstancesResponse',
            'response': response
        }

    return response
Exemple #3
0
def _run_instance_response(response):
    if 'errortext' in response:
        if 'Invalid parameter templateid' in response['errortext']:
            errors.invalid_image_id()
        elif 'Unable to find group' in response['errortext']:
            errors.invalid_security_group()
        elif 'Invalid parameter securitygroupids' in response['errortext']:
            errors.invalid_security_group()
        elif 'A key pair with name' in response['errortext']:
            errors.invalid_keypair_name()
        else:
            errors.invalid_paramater_value(response['errortext'])
    else:
        response = response['virtualmachine']
        response = {
            'template_name_or_list': 'run_instance.xml',
            'response_type': 'RunInstancesResponse',
            'response': response
        }

    return response