2013-12-29 13:25:13 +00:00
|
|
|
from moto.core.responses import BaseResponse
|
2016-01-11 05:44:29 +00:00
|
|
|
from moto.ec2.utils import filters_from_querystring
|
2013-02-22 04:13:01 +00:00
|
|
|
|
|
|
|
|
2013-12-29 13:25:13 +00:00
|
|
|
class ElasticBlockStore(BaseResponse):
|
2013-02-22 04:13:01 +00:00
|
|
|
def attach_volume(self):
|
2019-10-31 15:44:26 +00:00
|
|
|
volume_id = self._get_param("VolumeId")
|
|
|
|
instance_id = self._get_param("InstanceId")
|
|
|
|
device_path = self._get_param("Device")
|
|
|
|
if self.is_not_dryrun("AttachVolume"):
|
2017-02-24 02:37:43 +00:00
|
|
|
attachment = self.ec2_backend.attach_volume(
|
2019-10-31 15:44:26 +00:00
|
|
|
volume_id, instance_id, device_path
|
|
|
|
)
|
2016-10-15 13:08:44 +00:00
|
|
|
template = self.response_template(ATTACHED_VOLUME_RESPONSE)
|
|
|
|
return template.render(attachment=attachment)
|
2013-02-22 04:13:01 +00:00
|
|
|
|
|
|
|
def copy_snapshot(self):
|
2019-10-31 15:44:26 +00:00
|
|
|
source_snapshot_id = self._get_param("SourceSnapshotId")
|
|
|
|
source_region = self._get_param("SourceRegion")
|
|
|
|
description = self._get_param("Description")
|
2020-10-09 11:33:07 +00:00
|
|
|
tags = self._parse_tag_specification("TagSpecification")
|
|
|
|
snapshot_tags = tags.get("snapshot", {})
|
2019-10-31 15:44:26 +00:00
|
|
|
if self.is_not_dryrun("CopySnapshot"):
|
2018-02-09 19:49:40 +00:00
|
|
|
snapshot = self.ec2_backend.copy_snapshot(
|
2019-10-31 15:44:26 +00:00
|
|
|
source_snapshot_id, source_region, description
|
|
|
|
)
|
2020-10-09 11:33:07 +00:00
|
|
|
snapshot.add_tags(snapshot_tags)
|
2018-02-09 19:49:40 +00:00
|
|
|
template = self.response_template(COPY_SNAPSHOT_RESPONSE)
|
|
|
|
return template.render(snapshot=snapshot)
|
2013-02-22 04:13:01 +00:00
|
|
|
|
|
|
|
def create_snapshot(self):
|
2019-10-31 15:44:26 +00:00
|
|
|
volume_id = self._get_param("VolumeId")
|
|
|
|
description = self._get_param("Description")
|
2018-04-04 16:21:08 +00:00
|
|
|
tags = self._parse_tag_specification("TagSpecification")
|
2019-10-31 15:44:26 +00:00
|
|
|
snapshot_tags = tags.get("snapshot", {})
|
|
|
|
if self.is_not_dryrun("CreateSnapshot"):
|
2016-10-15 13:08:44 +00:00
|
|
|
snapshot = self.ec2_backend.create_snapshot(volume_id, description)
|
2018-04-04 16:21:08 +00:00
|
|
|
snapshot.add_tags(snapshot_tags)
|
2016-10-15 13:08:44 +00:00
|
|
|
template = self.response_template(CREATE_SNAPSHOT_RESPONSE)
|
|
|
|
return template.render(snapshot=snapshot)
|
2013-02-22 04:13:01 +00:00
|
|
|
|
2022-01-25 10:27:02 +00:00
|
|
|
def create_snapshots(self):
|
|
|
|
params = self._get_params()
|
|
|
|
instance_spec = params.get("InstanceSpecification")
|
|
|
|
description = params.get("Description", "")
|
|
|
|
tags = self._parse_tag_specification("TagSpecification")
|
|
|
|
snapshot_tags = tags.get("snapshot", {})
|
|
|
|
|
|
|
|
if self.is_not_dryrun("CreateSnapshots"):
|
|
|
|
snapshots = self.ec2_backend.create_snapshots(
|
|
|
|
instance_spec, description, snapshot_tags
|
|
|
|
)
|
|
|
|
template = self.response_template(CREATE_SNAPSHOTS_RESPONSE)
|
|
|
|
return template.render(snapshots=snapshots)
|
|
|
|
|
2013-02-22 04:13:01 +00:00
|
|
|
def create_volume(self):
|
2019-10-31 15:44:26 +00:00
|
|
|
size = self._get_param("Size")
|
|
|
|
zone = self._get_param("AvailabilityZone")
|
|
|
|
snapshot_id = self._get_param("SnapshotId")
|
2021-10-10 19:16:28 +00:00
|
|
|
volume_type = self._get_param("VolumeType")
|
2018-01-15 08:52:32 +00:00
|
|
|
tags = self._parse_tag_specification("TagSpecification")
|
2019-10-31 15:44:26 +00:00
|
|
|
volume_tags = tags.get("volume", {})
|
2020-10-14 14:18:50 +00:00
|
|
|
encrypted = self._get_bool_param("Encrypted", if_none=False)
|
|
|
|
kms_key_id = self._get_param("KmsKeyId")
|
2019-10-31 15:44:26 +00:00
|
|
|
if self.is_not_dryrun("CreateVolume"):
|
2020-10-14 14:18:50 +00:00
|
|
|
volume = self.ec2_backend.create_volume(
|
2021-10-10 19:16:28 +00:00
|
|
|
size=size,
|
|
|
|
zone_name=zone,
|
|
|
|
snapshot_id=snapshot_id,
|
|
|
|
encrypted=encrypted,
|
|
|
|
kms_key_id=kms_key_id,
|
|
|
|
volume_type=volume_type,
|
2020-10-14 14:18:50 +00:00
|
|
|
)
|
2018-01-15 08:52:32 +00:00
|
|
|
volume.add_tags(volume_tags)
|
2016-10-15 13:08:44 +00:00
|
|
|
template = self.response_template(CREATE_VOLUME_RESPONSE)
|
|
|
|
return template.render(volume=volume)
|
2013-02-22 04:13:01 +00:00
|
|
|
|
|
|
|
def delete_snapshot(self):
|
2019-10-31 15:44:26 +00:00
|
|
|
snapshot_id = self._get_param("SnapshotId")
|
|
|
|
if self.is_not_dryrun("DeleteSnapshot"):
|
2016-10-15 13:08:44 +00:00
|
|
|
self.ec2_backend.delete_snapshot(snapshot_id)
|
|
|
|
return DELETE_SNAPSHOT_RESPONSE
|
2013-02-22 04:13:01 +00:00
|
|
|
|
|
|
|
def delete_volume(self):
|
2019-10-31 15:44:26 +00:00
|
|
|
volume_id = self._get_param("VolumeId")
|
|
|
|
if self.is_not_dryrun("DeleteVolume"):
|
2016-10-15 13:08:44 +00:00
|
|
|
self.ec2_backend.delete_volume(volume_id)
|
|
|
|
return DELETE_VOLUME_RESPONSE
|
2013-02-22 04:13:01 +00:00
|
|
|
|
|
|
|
def describe_snapshots(self):
|
2016-01-11 05:44:29 +00:00
|
|
|
filters = filters_from_querystring(self.querystring)
|
2019-10-31 15:44:26 +00:00
|
|
|
snapshot_ids = self._get_multi_param("SnapshotId")
|
|
|
|
snapshots = self.ec2_backend.describe_snapshots(
|
|
|
|
snapshot_ids=snapshot_ids, filters=filters
|
|
|
|
)
|
2014-12-12 20:46:07 +00:00
|
|
|
template = self.response_template(DESCRIBE_SNAPSHOTS_RESPONSE)
|
2013-02-23 23:01:41 +00:00
|
|
|
return template.render(snapshots=snapshots)
|
2013-02-22 04:13:01 +00:00
|
|
|
|
|
|
|
def describe_volumes(self):
|
2016-01-11 05:44:29 +00:00
|
|
|
filters = filters_from_querystring(self.querystring)
|
2019-10-31 15:44:26 +00:00
|
|
|
volume_ids = self._get_multi_param("VolumeId")
|
|
|
|
volumes = self.ec2_backend.describe_volumes(
|
|
|
|
volume_ids=volume_ids, filters=filters
|
|
|
|
)
|
2014-12-12 20:46:07 +00:00
|
|
|
template = self.response_template(DESCRIBE_VOLUMES_RESPONSE)
|
2013-02-23 22:37:55 +00:00
|
|
|
return template.render(volumes=volumes)
|
2013-02-22 04:13:01 +00:00
|
|
|
|
|
|
|
def describe_volume_attribute(self):
|
2017-02-24 02:37:43 +00:00
|
|
|
raise NotImplementedError(
|
2019-10-31 15:44:26 +00:00
|
|
|
"ElasticBlockStore.describe_volume_attribute is not yet implemented"
|
|
|
|
)
|
2013-02-22 04:13:01 +00:00
|
|
|
|
|
|
|
def describe_volume_status(self):
|
2017-02-24 02:37:43 +00:00
|
|
|
raise NotImplementedError(
|
2019-10-31 15:44:26 +00:00
|
|
|
"ElasticBlockStore.describe_volume_status is not yet implemented"
|
|
|
|
)
|
2013-02-22 04:13:01 +00:00
|
|
|
|
|
|
|
def detach_volume(self):
|
2019-10-31 15:44:26 +00:00
|
|
|
volume_id = self._get_param("VolumeId")
|
|
|
|
instance_id = self._get_param("InstanceId")
|
|
|
|
device_path = self._get_param("Device")
|
|
|
|
if self.is_not_dryrun("DetachVolume"):
|
2017-02-24 02:37:43 +00:00
|
|
|
attachment = self.ec2_backend.detach_volume(
|
2019-10-31 15:44:26 +00:00
|
|
|
volume_id, instance_id, device_path
|
|
|
|
)
|
2016-10-15 13:08:44 +00:00
|
|
|
template = self.response_template(DETATCH_VOLUME_RESPONSE)
|
|
|
|
return template.render(attachment=attachment)
|
2013-02-23 22:37:55 +00:00
|
|
|
|
2013-02-22 04:13:01 +00:00
|
|
|
def enable_volume_io(self):
|
2019-10-31 15:44:26 +00:00
|
|
|
if self.is_not_dryrun("EnableVolumeIO"):
|
2017-02-24 02:37:43 +00:00
|
|
|
raise NotImplementedError(
|
2019-10-31 15:44:26 +00:00
|
|
|
"ElasticBlockStore.enable_volume_io is not yet implemented"
|
|
|
|
)
|
2013-02-22 04:13:01 +00:00
|
|
|
|
|
|
|
def import_volume(self):
|
2019-10-31 15:44:26 +00:00
|
|
|
if self.is_not_dryrun("ImportVolume"):
|
2017-02-24 02:37:43 +00:00
|
|
|
raise NotImplementedError(
|
2019-10-31 15:44:26 +00:00
|
|
|
"ElasticBlockStore.import_volume is not yet implemented"
|
|
|
|
)
|
2013-02-22 04:13:01 +00:00
|
|
|
|
2014-08-26 22:16:58 +00:00
|
|
|
def describe_snapshot_attribute(self):
|
2019-10-31 15:44:26 +00:00
|
|
|
snapshot_id = self._get_param("SnapshotId")
|
|
|
|
groups = self.ec2_backend.get_create_volume_permission_groups(snapshot_id)
|
2020-08-01 16:03:54 +00:00
|
|
|
user_ids = self.ec2_backend.get_create_volume_permission_userids(snapshot_id)
|
2019-10-31 15:44:26 +00:00
|
|
|
template = self.response_template(DESCRIBE_SNAPSHOT_ATTRIBUTES_RESPONSE)
|
2020-08-01 16:03:54 +00:00
|
|
|
return template.render(snapshot_id=snapshot_id, groups=groups, userIds=user_ids)
|
2014-08-26 22:16:58 +00:00
|
|
|
|
2013-02-22 04:13:01 +00:00
|
|
|
def modify_snapshot_attribute(self):
|
2019-10-31 15:44:26 +00:00
|
|
|
snapshot_id = self._get_param("SnapshotId")
|
|
|
|
operation_type = self._get_param("OperationType")
|
2020-08-01 16:03:54 +00:00
|
|
|
groups = self._get_multi_param("UserGroup")
|
|
|
|
user_ids = self._get_multi_param("UserId")
|
2019-10-31 15:44:26 +00:00
|
|
|
if self.is_not_dryrun("ModifySnapshotAttribute"):
|
|
|
|
if operation_type == "add":
|
2017-02-24 02:37:43 +00:00
|
|
|
self.ec2_backend.add_create_volume_permission(
|
2020-08-01 16:03:54 +00:00
|
|
|
snapshot_id, user_ids=user_ids, groups=groups
|
2019-10-31 15:44:26 +00:00
|
|
|
)
|
|
|
|
elif operation_type == "remove":
|
2017-02-24 02:37:43 +00:00
|
|
|
self.ec2_backend.remove_create_volume_permission(
|
2020-08-01 16:03:54 +00:00
|
|
|
snapshot_id, user_ids=user_ids, groups=groups
|
2019-10-31 15:44:26 +00:00
|
|
|
)
|
2016-10-15 13:08:44 +00:00
|
|
|
return MODIFY_SNAPSHOT_ATTRIBUTE_RESPONSE
|
2013-02-22 04:13:01 +00:00
|
|
|
|
|
|
|
def modify_volume_attribute(self):
|
2019-10-31 15:44:26 +00:00
|
|
|
if self.is_not_dryrun("ModifyVolumeAttribute"):
|
2017-02-24 02:37:43 +00:00
|
|
|
raise NotImplementedError(
|
2019-10-31 15:44:26 +00:00
|
|
|
"ElasticBlockStore.modify_volume_attribute is not yet implemented"
|
|
|
|
)
|
2013-02-22 04:13:01 +00:00
|
|
|
|
|
|
|
def reset_snapshot_attribute(self):
|
2019-10-31 15:44:26 +00:00
|
|
|
if self.is_not_dryrun("ResetSnapshotAttribute"):
|
2017-02-24 02:37:43 +00:00
|
|
|
raise NotImplementedError(
|
2019-10-31 15:44:26 +00:00
|
|
|
"ElasticBlockStore.reset_snapshot_attribute is not yet implemented"
|
|
|
|
)
|
2013-02-22 04:13:01 +00:00
|
|
|
|
2013-02-23 22:37:55 +00:00
|
|
|
|
2016-02-02 13:15:18 +00:00
|
|
|
CREATE_VOLUME_RESPONSE = """<CreateVolumeResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
|
2013-02-23 22:37:55 +00:00
|
|
|
<requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
|
|
|
|
<volumeId>{{ volume.id }}</volumeId>
|
|
|
|
<size>{{ volume.size }}</size>
|
2015-11-03 14:37:02 +00:00
|
|
|
{% if volume.snapshot_id %}
|
|
|
|
<snapshotId>{{ volume.snapshot_id }}</snapshotId>
|
|
|
|
{% else %}
|
|
|
|
<snapshotId/>
|
|
|
|
{% endif %}
|
2020-10-14 14:18:50 +00:00
|
|
|
<encrypted>{{ 'true' if volume.encrypted else 'false' }}</encrypted>
|
|
|
|
{% if volume.encrypted %}
|
|
|
|
<kmsKeyId>{{ volume.kms_key_id }}</kmsKeyId>
|
|
|
|
{% endif %}
|
2013-02-23 22:37:55 +00:00
|
|
|
<availabilityZone>{{ volume.zone.name }}</availabilityZone>
|
|
|
|
<status>creating</status>
|
2015-07-25 23:37:20 +00:00
|
|
|
<createTime>{{ volume.create_time}}</createTime>
|
bugfix ebs volume tag behaviour
This commit modifies the response format of the ec2 calls
`create_volume` and `describe_volumes`. Previously, these calls would
always include a `Tags` key in the response, even when a volume has no tags.
Now, the `Tags` key will not be included in the response if the volume
has no tags.
When an EBS volume has no tags, calls to the aws ec2 endpoints `create_volume`
and `describe_volumes` do not include the `Tags` key in the
`response.Volumes[]` object.
However, moto does include the `Tags` key in this case. This discrepancy
in behaviour can result in code passing a moto test but failing in
production.
Sample snippets that trigger this condition:
```
def create_volume_and_then_get_tags_from_response():
client = boto3.client('ec2', region_name='us-east-1')
volume_response = client.create_volume(
Size=10,
AvailabilityZone='us-east-1a'
)
keys = volume_response['Keys']
```
```
def create_volume_and_then_get_tags_from_describe_volumes():
client = boto3.client('ec2', region_name='us-east-1')
volume_response = client.create_volume(
Size=10,
AvailabilityZone='us-east-1a'
)
volume_describe_response = client.describe_volumes()
keys = volume_describe_response['Volumes'][0]['Keys']
```
Both sample snippets will succeed in a moto test, but fail with a
`KeyError` when using the aws api.
2019-03-07 22:07:15 +00:00
|
|
|
{% if volume.get_tags() %}
|
|
|
|
<tagSet>
|
|
|
|
{% for tag in volume.get_tags() %}
|
|
|
|
<item>
|
|
|
|
<resourceId>{{ tag.resource_id }}</resourceId>
|
|
|
|
<resourceType>{{ tag.resource_type }}</resourceType>
|
|
|
|
<key>{{ tag.key }}</key>
|
|
|
|
<value>{{ tag.value }}</value>
|
|
|
|
</item>
|
|
|
|
{% endfor %}
|
|
|
|
</tagSet>
|
|
|
|
{% endif %}
|
2021-10-10 19:16:28 +00:00
|
|
|
<volumeType>{{ volume.volume_type }}</volumeType>
|
2013-02-23 22:37:55 +00:00
|
|
|
</CreateVolumeResponse>"""
|
|
|
|
|
2016-02-02 13:15:18 +00:00
|
|
|
DESCRIBE_VOLUMES_RESPONSE = """<DescribeVolumesResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
|
2013-02-23 22:37:55 +00:00
|
|
|
<requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
|
|
|
|
<volumeSet>
|
|
|
|
{% for volume in volumes %}
|
|
|
|
<item>
|
|
|
|
<volumeId>{{ volume.id }}</volumeId>
|
|
|
|
<size>{{ volume.size }}</size>
|
2015-11-03 14:37:02 +00:00
|
|
|
{% if volume.snapshot_id %}
|
|
|
|
<snapshotId>{{ volume.snapshot_id }}</snapshotId>
|
|
|
|
{% else %}
|
|
|
|
<snapshotId/>
|
|
|
|
{% endif %}
|
2020-10-14 14:18:50 +00:00
|
|
|
<encrypted>{{ 'true' if volume.encrypted else 'false' }}</encrypted>
|
|
|
|
{% if volume.encrypted %}
|
|
|
|
<kmsKeyId>{{ volume.kms_key_id }}</kmsKeyId>
|
|
|
|
{% endif %}
|
2013-02-23 22:37:55 +00:00
|
|
|
<availabilityZone>{{ volume.zone.name }}</availabilityZone>
|
|
|
|
<status>{{ volume.status }}</status>
|
2015-07-25 23:37:20 +00:00
|
|
|
<createTime>{{ volume.create_time}}</createTime>
|
2013-02-23 22:37:55 +00:00
|
|
|
<attachmentSet>
|
|
|
|
{% if volume.attachment %}
|
|
|
|
<item>
|
|
|
|
<volumeId>{{ volume.id }}</volumeId>
|
|
|
|
<instanceId>{{ volume.attachment.instance.id }}</instanceId>
|
|
|
|
<device>{{ volume.attachment.device }}</device>
|
|
|
|
<status>attached</status>
|
2015-07-25 23:37:20 +00:00
|
|
|
<attachTime>{{volume.attachment.attach_time}}</attachTime>
|
2013-02-23 22:37:55 +00:00
|
|
|
<deleteOnTermination>false</deleteOnTermination>
|
|
|
|
</item>
|
|
|
|
{% endif %}
|
|
|
|
</attachmentSet>
|
bugfix ebs volume tag behaviour
This commit modifies the response format of the ec2 calls
`create_volume` and `describe_volumes`. Previously, these calls would
always include a `Tags` key in the response, even when a volume has no tags.
Now, the `Tags` key will not be included in the response if the volume
has no tags.
When an EBS volume has no tags, calls to the aws ec2 endpoints `create_volume`
and `describe_volumes` do not include the `Tags` key in the
`response.Volumes[]` object.
However, moto does include the `Tags` key in this case. This discrepancy
in behaviour can result in code passing a moto test but failing in
production.
Sample snippets that trigger this condition:
```
def create_volume_and_then_get_tags_from_response():
client = boto3.client('ec2', region_name='us-east-1')
volume_response = client.create_volume(
Size=10,
AvailabilityZone='us-east-1a'
)
keys = volume_response['Keys']
```
```
def create_volume_and_then_get_tags_from_describe_volumes():
client = boto3.client('ec2', region_name='us-east-1')
volume_response = client.create_volume(
Size=10,
AvailabilityZone='us-east-1a'
)
volume_describe_response = client.describe_volumes()
keys = volume_describe_response['Volumes'][0]['Keys']
```
Both sample snippets will succeed in a moto test, but fail with a
`KeyError` when using the aws api.
2019-03-07 22:07:15 +00:00
|
|
|
{% if volume.get_tags() %}
|
|
|
|
<tagSet>
|
|
|
|
{% for tag in volume.get_tags() %}
|
|
|
|
<item>
|
|
|
|
<resourceId>{{ tag.resource_id }}</resourceId>
|
|
|
|
<resourceType>{{ tag.resource_type }}</resourceType>
|
|
|
|
<key>{{ tag.key }}</key>
|
|
|
|
<value>{{ tag.value }}</value>
|
|
|
|
</item>
|
|
|
|
{% endfor %}
|
|
|
|
</tagSet>
|
|
|
|
{% endif %}
|
2021-10-10 19:16:28 +00:00
|
|
|
<volumeType>{{ volume.volume_type }}</volumeType>
|
2013-02-23 22:37:55 +00:00
|
|
|
</item>
|
|
|
|
{% endfor %}
|
|
|
|
</volumeSet>
|
|
|
|
</DescribeVolumesResponse>"""
|
|
|
|
|
2016-02-02 13:15:18 +00:00
|
|
|
DELETE_VOLUME_RESPONSE = """<DeleteVolumeResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
|
2013-02-23 22:37:55 +00:00
|
|
|
<requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
|
|
|
|
<return>true</return>
|
|
|
|
</DeleteVolumeResponse>"""
|
|
|
|
|
2016-02-02 13:15:18 +00:00
|
|
|
ATTACHED_VOLUME_RESPONSE = """<AttachVolumeResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
|
2013-02-23 22:37:55 +00:00
|
|
|
<requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
|
|
|
|
<volumeId>{{ attachment.volume.id }}</volumeId>
|
|
|
|
<instanceId>{{ attachment.instance.id }}</instanceId>
|
|
|
|
<device>{{ attachment.device }}</device>
|
|
|
|
<status>attaching</status>
|
2015-07-25 23:37:20 +00:00
|
|
|
<attachTime>{{attachment.attach_time}}</attachTime>
|
2013-02-23 22:37:55 +00:00
|
|
|
</AttachVolumeResponse>"""
|
|
|
|
|
2016-02-02 13:15:18 +00:00
|
|
|
DETATCH_VOLUME_RESPONSE = """<DetachVolumeResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
|
2013-02-23 22:37:55 +00:00
|
|
|
<requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
|
|
|
|
<volumeId>{{ attachment.volume.id }}</volumeId>
|
|
|
|
<instanceId>{{ attachment.instance.id }}</instanceId>
|
|
|
|
<device>{{ attachment.device }}</device>
|
|
|
|
<status>detaching</status>
|
2015-04-28 11:39:48 +00:00
|
|
|
<attachTime>2013-10-04T17:38:53.000Z</attachTime>
|
2013-02-23 22:37:55 +00:00
|
|
|
</DetachVolumeResponse>"""
|
|
|
|
|
2016-02-02 13:15:18 +00:00
|
|
|
CREATE_SNAPSHOT_RESPONSE = """<CreateSnapshotResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
|
2013-02-23 23:01:41 +00:00
|
|
|
<requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
|
|
|
|
<snapshotId>{{ snapshot.id }}</snapshotId>
|
|
|
|
<volumeId>{{ snapshot.volume.id }}</volumeId>
|
|
|
|
<status>pending</status>
|
2015-07-25 23:37:20 +00:00
|
|
|
<startTime>{{ snapshot.start_time}}</startTime>
|
2013-02-23 23:01:41 +00:00
|
|
|
<progress>60%</progress>
|
2018-03-21 15:55:58 +00:00
|
|
|
<ownerId>{{ snapshot.owner_id }}</ownerId>
|
2013-02-23 23:01:41 +00:00
|
|
|
<volumeSize>{{ snapshot.volume.size }}</volumeSize>
|
|
|
|
<description>{{ snapshot.description }}</description>
|
2021-09-25 11:13:07 +00:00
|
|
|
<encrypted>{{ 'true' if snapshot.encrypted else 'false' }}</encrypted>
|
2018-04-04 16:21:08 +00:00
|
|
|
<tagSet>
|
|
|
|
{% for tag in snapshot.get_tags() %}
|
|
|
|
<item>
|
|
|
|
<resourceId>{{ tag.resource_id }}</resourceId>
|
|
|
|
<resourceType>{{ tag.resource_type }}</resourceType>
|
|
|
|
<key>{{ tag.key }}</key>
|
|
|
|
<value>{{ tag.value }}</value>
|
|
|
|
</item>
|
|
|
|
{% endfor %}
|
|
|
|
</tagSet>
|
2013-02-23 23:01:41 +00:00
|
|
|
</CreateSnapshotResponse>"""
|
|
|
|
|
2022-01-25 10:27:02 +00:00
|
|
|
CREATE_SNAPSHOTS_RESPONSE = """<CreateSnapshotsResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
|
|
|
|
<requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
|
|
|
|
<snapshotSet>
|
|
|
|
{% for snapshot in snapshots %}
|
|
|
|
<item>
|
|
|
|
<snapshotId>{{ snapshot.id }}</snapshotId>
|
|
|
|
<volumeId>{{ snapshot.volume.id }}</volumeId>
|
|
|
|
<status>pending</status>
|
|
|
|
<startTime>{{ snapshot.start_time}}</startTime>
|
|
|
|
<progress>60%</progress>
|
|
|
|
<ownerId>{{ snapshot.owner_id }}</ownerId>
|
|
|
|
<volumeSize>{{ snapshot.volume.size }}</volumeSize>
|
|
|
|
<description>{{ snapshot.description }}</description>
|
|
|
|
<encrypted>{{ 'true' if snapshot.encrypted else 'false' }}</encrypted>
|
|
|
|
<tagSet>
|
|
|
|
{% for tag in snapshot.get_tags() %}
|
|
|
|
<item>
|
|
|
|
<resourceId>{{ tag.resource_id }}</resourceId>
|
|
|
|
<resourceType>{{ tag.resource_type }}</resourceType>
|
|
|
|
<key>{{ tag.key }}</key>
|
|
|
|
<value>{{ tag.value }}</value>
|
|
|
|
</item>
|
|
|
|
{% endfor %}
|
|
|
|
</tagSet>
|
|
|
|
</item>
|
|
|
|
{% endfor %}
|
|
|
|
</snapshotSet>
|
|
|
|
</CreateSnapshotsResponse>"""
|
|
|
|
|
2018-02-09 19:49:40 +00:00
|
|
|
COPY_SNAPSHOT_RESPONSE = """<CopySnapshotResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">
|
|
|
|
<requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
|
|
|
|
<snapshotId>{{ snapshot.id }}</snapshotId>
|
2020-10-09 11:33:07 +00:00
|
|
|
<tagSet>
|
|
|
|
{% for tag in snapshot.get_tags() %}
|
|
|
|
<item>
|
|
|
|
<resourceId>{{ tag.resource_id }}</resourceId>
|
|
|
|
<resourceType>{{ tag.resource_type }}</resourceType>
|
|
|
|
<key>{{ tag.key }}</key>
|
|
|
|
<value>{{ tag.value }}</value>
|
|
|
|
</item>
|
|
|
|
{% endfor %}
|
|
|
|
</tagSet>
|
2018-02-09 19:49:40 +00:00
|
|
|
</CopySnapshotResponse>"""
|
|
|
|
|
2016-02-02 13:15:18 +00:00
|
|
|
DESCRIBE_SNAPSHOTS_RESPONSE = """<DescribeSnapshotsResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
|
2013-02-23 23:01:41 +00:00
|
|
|
<requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
|
|
|
|
<snapshotSet>
|
|
|
|
{% for snapshot in snapshots %}
|
|
|
|
<item>
|
|
|
|
<snapshotId>{{ snapshot.id }}</snapshotId>
|
2016-10-15 13:08:44 +00:00
|
|
|
<volumeId>{{ snapshot.volume.id }}</volumeId>
|
2016-05-02 02:24:49 +00:00
|
|
|
<status>{{ snapshot.status }}</status>
|
2015-07-25 23:37:20 +00:00
|
|
|
<startTime>{{ snapshot.start_time}}</startTime>
|
2015-10-13 15:07:47 +00:00
|
|
|
<progress>100%</progress>
|
2018-03-21 15:55:58 +00:00
|
|
|
<ownerId>{{ snapshot.owner_id }}</ownerId>
|
2016-10-15 13:08:44 +00:00
|
|
|
<volumeSize>{{ snapshot.volume.size }}</volumeSize>
|
2013-02-23 23:01:41 +00:00
|
|
|
<description>{{ snapshot.description }}</description>
|
2021-09-25 11:13:07 +00:00
|
|
|
<encrypted>{{ 'true' if snapshot.encrypted else 'false' }}</encrypted>
|
2013-02-23 23:01:41 +00:00
|
|
|
<tagSet>
|
2014-11-09 14:00:40 +00:00
|
|
|
{% for tag in snapshot.get_tags() %}
|
|
|
|
<item>
|
|
|
|
<resourceId>{{ tag.resource_id }}</resourceId>
|
|
|
|
<resourceType>{{ tag.resource_type }}</resourceType>
|
|
|
|
<key>{{ tag.key }}</key>
|
|
|
|
<value>{{ tag.value }}</value>
|
|
|
|
</item>
|
|
|
|
{% endfor %}
|
2013-02-23 23:01:41 +00:00
|
|
|
</tagSet>
|
|
|
|
</item>
|
|
|
|
{% endfor %}
|
|
|
|
</snapshotSet>
|
|
|
|
</DescribeSnapshotsResponse>"""
|
|
|
|
|
2016-02-02 13:15:18 +00:00
|
|
|
DELETE_SNAPSHOT_RESPONSE = """<DeleteSnapshotResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
|
2013-02-23 23:01:41 +00:00
|
|
|
<requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
|
|
|
|
<return>true</return>
|
|
|
|
</DeleteSnapshotResponse>"""
|
2014-08-26 22:16:58 +00:00
|
|
|
|
|
|
|
DESCRIBE_SNAPSHOT_ATTRIBUTES_RESPONSE = """
|
2016-02-02 13:15:18 +00:00
|
|
|
<DescribeSnapshotAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
|
2014-08-26 22:16:58 +00:00
|
|
|
<requestId>a9540c9f-161a-45d8-9cc1-1182b89ad69f</requestId>
|
|
|
|
<snapshotId>snap-a0332ee0</snapshotId>
|
2020-08-01 16:03:54 +00:00
|
|
|
<createVolumePermission>
|
|
|
|
{% for group in groups %}
|
|
|
|
<item>
|
|
|
|
<group>{{ group }}</group>
|
|
|
|
</item>
|
|
|
|
{% endfor %}
|
|
|
|
{% for userId in userIds %}
|
|
|
|
<item>
|
|
|
|
<userId>{{ userId }}</userId>
|
|
|
|
</item>
|
|
|
|
{% endfor %}
|
|
|
|
</createVolumePermission>
|
2014-08-26 22:16:58 +00:00
|
|
|
</DescribeSnapshotAttributeResponse>
|
|
|
|
"""
|
|
|
|
|
|
|
|
MODIFY_SNAPSHOT_ATTRIBUTE_RESPONSE = """
|
2016-02-02 13:15:18 +00:00
|
|
|
<ModifySnapshotAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
|
2014-08-26 22:16:58 +00:00
|
|
|
<requestId>666d2944-9276-4d6a-be12-1f4ada972fd8</requestId>
|
|
|
|
<return>true</return>
|
|
|
|
</ModifySnapshotAttributeResponse>
|
2017-02-24 02:37:43 +00:00
|
|
|
"""
|