def _create_snapshot_response(response): """ Generates a response for create snapshot request. @param response: Response from Cloudstack. @return: Response. """ if 'errortext' in response: if 'Invalid parameter volumeid' in response['errortext']: errors.invalid_volume_id() else: response = response['snapshot'] return { 'template_name_or_list': 'create_snapshot.xml', 'response_type': 'CreateSnapshotResponse', 'response': response }
def _delete_volume_response(response): """ Generates a response for delete volume request. @param response: Response from Cloudstack. @return: Response. """ if 'errortext' in response: if 'Unable to aquire volume' in response['errortext']: errors.invalid_volume_id() else: errors.invalid_request(response['errortext']) return { 'template_name_or_list': 'status.xml', 'response_type': 'DeleteVolumeResponse', 'return': 'true' }
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 }