You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by qu...@apache.org on 2017/10/19 05:14:22 UTC
[1/3] libcloud git commit: Fix ec2 volume encryption
Repository: libcloud
Updated Branches:
refs/heads/trunk 7ea3646c0 -> bf35421ea
Fix ec2 volume encryption
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/61c3e503
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/61c3e503
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/61c3e503
Branch: refs/heads/trunk
Commit: 61c3e50374519212e4bc04e0f0c276054e58ec34
Parents: 7ea3646
Author: mermoldy <s....@scalr.com>
Authored: Wed Jan 11 01:11:47 2017 +0200
Committer: Quentin Pradet <qu...@apache.org>
Committed: Thu Oct 19 09:08:19 2017 +0400
----------------------------------------------------------------------
libcloud/compute/drivers/ec2.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/61c3e503/libcloud/compute/drivers/ec2.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/ec2.py b/libcloud/compute/drivers/ec2.py
index dd62097..9b4b218 100644
--- a/libcloud/compute/drivers/ec2.py
+++ b/libcloud/compute/drivers/ec2.py
@@ -3906,7 +3906,7 @@ class BaseEC2NodeDriver(NodeDriver):
def create_volume(self, size, name, location=None, snapshot=None,
ex_volume_type='standard', ex_iops=None,
- ex_encrypted=None, ex_kms_key_id=None):
+ ex_encrypted=False, ex_kms_key_id=None):
"""
Create a new volume.
@@ -3972,11 +3972,11 @@ class BaseEC2NodeDriver(NodeDriver):
if ex_volume_type == 'io1' and ex_iops:
params['Iops'] = ex_iops
- if ex_encrypted is not None:
+ if ex_encrypted:
params['Encrypted'] = 1
- if ex_kms_key_id is not None:
- params['KmsKeyId'] = ex_kms_key_id
+ if ex_kms_key_id is not None:
+ params['KmsKeyId'] = ex_kms_key_id
volume = self._to_volume(
self.connection.request(self.path, params=params).object,
[2/3] libcloud git commit: Add EC2Tests.test_create_encrypted_volume
Posted by qu...@apache.org.
Add EC2Tests.test_create_encrypted_volume
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/1e87b825
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/1e87b825
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/1e87b825
Branch: refs/heads/trunk
Commit: 1e87b82590a4fee5349f59361178dc0e2c35d791
Parents: 61c3e50
Author: mermoldy <s....@scalr.com>
Authored: Mon Oct 9 14:57:54 2017 +0300
Committer: Quentin Pradet <qu...@apache.org>
Committed: Thu Oct 19 09:10:36 2017 +0400
----------------------------------------------------------------------
libcloud/compute/drivers/ec2.py | 4 ++++
.../fixtures/ec2/create_encrypted_volume.xml | 11 ++++++++++
.../test/compute/fixtures/ec2/create_volume.xml | 2 ++
libcloud/test/compute/test_ec2.py | 22 +++++++++++++++++++-
4 files changed, 38 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/1e87b825/libcloud/compute/drivers/ec2.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/ec2.py b/libcloud/compute/drivers/ec2.py
index 9b4b218..7ea29fa 100644
--- a/libcloud/compute/drivers/ec2.py
+++ b/libcloud/compute/drivers/ec2.py
@@ -2978,6 +2978,10 @@ RESOURCE_EXTRA_ATTRIBUTES_MAP = {
'xpath': 'status',
'transform_func': str
},
+ 'encrypted': {
+ 'xpath': 'encrypted',
+ 'transform_func': lambda x: {'true': True, 'false': False}.get(x)
+ },
'attach_time': {
'xpath': 'attachmentSet/item/attachTime',
'transform_func': parse_date
http://git-wip-us.apache.org/repos/asf/libcloud/blob/1e87b825/libcloud/test/compute/fixtures/ec2/create_encrypted_volume.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/ec2/create_encrypted_volume.xml b/libcloud/test/compute/fixtures/ec2/create_encrypted_volume.xml
new file mode 100644
index 0000000..bd22e89
--- /dev/null
+++ b/libcloud/test/compute/fixtures/ec2/create_encrypted_volume.xml
@@ -0,0 +1,11 @@
+<CreateVolumeResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">
+ <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
+ <volumeId>vol-4d826724</volumeId>
+ <size>10</size>
+ <snapshotId/>
+ <availabilityZone>us-east-1a</availabilityZone>
+ <status>creating</status>
+ <createTime>2008-05-07T11:51:50.000Z</createTime>
+ <volumeType>standard</volumeType>
+ <encrypted>true</encrypted>
+</CreateVolumeResponse>
http://git-wip-us.apache.org/repos/asf/libcloud/blob/1e87b825/libcloud/test/compute/fixtures/ec2/create_volume.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/ec2/create_volume.xml b/libcloud/test/compute/fixtures/ec2/create_volume.xml
index df7d7c4..40dd556 100644
--- a/libcloud/test/compute/fixtures/ec2/create_volume.xml
+++ b/libcloud/test/compute/fixtures/ec2/create_volume.xml
@@ -6,4 +6,6 @@
<availabilityZone>us-east-1a</availabilityZone>
<status>creating</status>
<createTime>2008-05-07T11:51:50.000Z</createTime>
+ <volumeType>standard</volumeType>
+ <encrypted>false</encrypted>
</CreateVolumeResponse>
http://git-wip-us.apache.org/repos/asf/libcloud/blob/1e87b825/libcloud/test/compute/test_ec2.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_ec2.py b/libcloud/test/compute/test_ec2.py
index a36e650..f0409ed 100644
--- a/libcloud/test/compute/test_ec2.py
+++ b/libcloud/test/compute/test_ec2.py
@@ -907,6 +907,20 @@ class EC2Tests(LibcloudTestCase, TestCaseMixin):
self.assertEqual('vol', vol.name)
self.assertEqual('creating', vol.extra['state'])
self.assertTrue(isinstance(vol.extra['create_time'], datetime))
+ self.assertEqual(False, vol.extra['encrypted'])
+
+ def test_create_encrypted_volume(self):
+ location = self.driver.list_locations()[0]
+ vol = self.driver.create_volume(
+ 10, 'vol', location,
+ ex_encrypted=True,
+ ex_kms_key_id='1234')
+
+ self.assertEqual(10, vol.size)
+ self.assertEqual('vol', vol.name)
+ self.assertEqual('creating', vol.extra['state'])
+ self.assertTrue(isinstance(vol.extra['create_time'], datetime))
+ self.assertEqual(True, vol.extra['encrypted'])
def test_destroy_volume(self):
vol = StorageVolume(id='vol-4282672b', name='test',
@@ -1531,7 +1545,13 @@ class EC2MockHttp(MockHttp):
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
def _CreateVolume(self, method, url, body, headers):
- body = self.fixtures.load('create_volume.xml')
+ if 'KmsKeyId=' in url:
+ assert 'Encrypted=1' in url, "If a KmsKeyId is specified, the " \
+ "Encrypted flag must also be set."
+ if 'Encrypted=1' in url:
+ body = self.fixtures.load('create_encrypted_volume.xml')
+ else:
+ body = self.fixtures.load('create_volume.xml')
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
def _DeleteVolume(self, method, url, body, headers):
[3/3] libcloud git commit: Add changes for #1008
Posted by qu...@apache.org.
Add changes for #1008
Closes #1008
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/bf35421e
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/bf35421e
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/bf35421e
Branch: refs/heads/trunk
Commit: bf35421ea7399c14441e3f25b9bf79d737a16a7f
Parents: 1e87b82
Author: Quentin Pradet <qu...@apache.org>
Authored: Thu Oct 19 09:13:30 2017 +0400
Committer: Quentin Pradet <qu...@apache.org>
Committed: Thu Oct 19 09:13:30 2017 +0400
----------------------------------------------------------------------
CHANGES.rst | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/bf35421e/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index d8d7191..bbb3ad8 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -70,6 +70,9 @@ Compute
(GITHUB-1130)
[Rick van de Loo]
+- [EC2] Fix EBS volume encryption (GITHUB-1008)
+ [Sergey Babak]
+
Storage
~~~~~~~