added encrypted attribute to snapshots

This commit is contained in:
Kieran Doonan 2016-07-04 14:29:33 +01:00
parent e9af4c9065
commit 44195a9151
2 changed files with 8 additions and 2 deletions

View File

@ -1604,7 +1604,7 @@ class Volume(TaggedEC2Resource):
class Snapshot(TaggedEC2Resource):
def __init__(self, ec2_backend, snapshot_id, volume, description):
def __init__(self, ec2_backend, snapshot_id, volume, description, encrypted=False):
self.id = snapshot_id
self.volume = volume
self.description = description
@ -1612,6 +1612,7 @@ class Snapshot(TaggedEC2Resource):
self.create_volume_permission_groups = set()
self.ec2_backend = ec2_backend
self.status = 'completed'
self.encrypted = encrypted
def get_filter_value(self, filter_name):
@ -1630,6 +1631,9 @@ class Snapshot(TaggedEC2Resource):
if filter_name == 'volume-size':
return self.volume.size
if filter_name == 'encrypted':
return str(self.encrypted).lower()
filter_value = super(Snapshot, self).get_filter_value(filter_name)
if filter_value is None:
@ -1701,7 +1705,7 @@ class EBSBackend(object):
def create_snapshot(self, volume_id, description):
snapshot_id = random_snapshot_id()
volume = self.get_volume(volume_id)
snapshot = Snapshot(self, snapshot_id, volume, description)
snapshot = Snapshot(self, snapshot_id, volume, description, volume.encrypted)
self.snapshots[snapshot_id] = snapshot
return snapshot

View File

@ -202,6 +202,7 @@ CREATE_SNAPSHOT_RESPONSE = """<CreateSnapshotResponse xmlns="http://ec2.amazonaw
<ownerId>111122223333</ownerId>
<volumeSize>{{ snapshot.volume.size }}</volumeSize>
<description>{{ snapshot.description }}</description>
<encrypted>{{ snapshot.encrypted }}</encrypted>
</CreateSnapshotResponse>"""
DESCRIBE_SNAPSHOTS_RESPONSE = """<DescribeSnapshotsResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
@ -217,6 +218,7 @@ DESCRIBE_SNAPSHOTS_RESPONSE = """<DescribeSnapshotsResponse xmlns="http://ec2.am
<ownerId>111122223333</ownerId>
<volumeSize>{{ snapshot.volume.size }}</volumeSize>
<description>{{ snapshot.description }}</description>
<encrypted>{{ snapshot.encrypted }}</encrypted>
<tagSet>
{% for tag in snapshot.get_tags() %}
<item>