[GitHub] libcloud pull request #1249: openstack: handle missing user email

2018-10-26 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/libcloud/pull/1249


---


[2/2] libcloud git commit: Add changes for #1249

2018-10-26 Thread vdloo
Add changes for #1249

Closes #1249


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/112f1583
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/112f1583
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/112f1583

Branch: refs/heads/trunk
Commit: 112f158333743e43313b9789d6158c070435d814
Parents: 8efa20a
Author: Rick van de Loo 
Authored: Fri Oct 26 18:49:52 2018 +0200
Committer: Rick van de Loo 
Committed: Fri Oct 26 18:49:52 2018 +0200

--
 CHANGES.rst | 3 +++
 1 file changed, 3 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/libcloud/blob/112f1583/CHANGES.rst
--
diff --git a/CHANGES.rst b/CHANGES.rst
index 13a29f9..d33f0b4 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -20,6 +20,9 @@ Common
 - [OpenStack] Document openstack_connection_kwargs method (GITHUB-1219)
   [Ken Dreyer]
 
+- [OpenStack] Handle missing user email in OpenStackIdentityUser (GITHUB-1249)
+  [Ken Dreyer]
+
 Compute
 ~~~
 



[1/2] libcloud git commit: openstack: handle missing user email

2018-10-26 Thread vdloo
Repository: libcloud
Updated Branches:
  refs/heads/trunk 102608f16 -> 112f15833


openstack: handle missing user email

Keystone may not always return an "email" entry for a user account.
Prior to this change, we could crash if we queried a user that lacked an
email record. Gracefully handle this case by setting email to None.

Signed-off-by: Rick van de Loo 


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/8efa20a6
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/8efa20a6
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/8efa20a6

Branch: refs/heads/trunk
Commit: 8efa20a62a82ff89b535031e5619071fa083a9ce
Parents: 102608f
Author: Ken Dreyer 
Authored: Mon Oct 22 11:07:38 2018 -0600
Committer: Rick van de Loo 
Committed: Fri Oct 26 18:48:36 2018 +0200

--
 libcloud/common/openstack_identity.py  |  2 +-
 libcloud/test/common/test_openstack_identity.py| 13 +
 .../fixtures/openstack_identity/v3/v3_users_b.json | 17 +
 3 files changed, 31 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/libcloud/blob/8efa20a6/libcloud/common/openstack_identity.py
--
diff --git a/libcloud/common/openstack_identity.py 
b/libcloud/common/openstack_identity.py
index 3d09681..f608244 100644
--- a/libcloud/common/openstack_identity.py
+++ b/libcloud/common/openstack_identity.py
@@ -1380,7 +1380,7 @@ class 
OpenStackIdentity_3_0_Connection(OpenStackIdentityConnection):
 user = OpenStackIdentityUser(id=data['id'],
  domain_id=data['domain_id'],
  name=data['name'],
- email=data['email'],
+ email=data.get('email'),
  description=data.get('description',
   None),
  enabled=data['enabled'])

http://git-wip-us.apache.org/repos/asf/libcloud/blob/8efa20a6/libcloud/test/common/test_openstack_identity.py
--
diff --git a/libcloud/test/common/test_openstack_identity.py 
b/libcloud/test/common/test_openstack_identity.py
index 916193f..e91c0b9 100644
--- a/libcloud/test/common/test_openstack_identity.py
+++ b/libcloud/test/common/test_openstack_identity.py
@@ -373,6 +373,12 @@ class 
OpenStackIdentity_3_0_ConnectionTests(unittest.TestCase):
 self.assertEqual(user.enabled, True)
 self.assertEqual(user.email, 'openstack-test@localhost')
 
+def test_get_user_without_email(self):
+user = self.auth_instance.get_user(user_id='b')
+self.assertEqual(user.id, 'b')
+self.assertEqual(user.name, 'userwithoutemail')
+self.assertEqual(user.email, None)
+
 def test_create_user(self):
 user = self.auth_instance.create_user(email='test2@localhost', 
password='test1',
   name='test2', 
domain_id='default')
@@ -699,6 +705,13 @@ class OpenStackIdentity_3_0_MockHttp(MockHttp):
 return (httplib.OK, body, self.json_content_headers, 
httplib.responses[httplib.OK])
 raise NotImplementedError()
 
+def _v3_users_b(self, method, url, body, headers):
+if method == 'GET':
+# look up a user
+body = self.fixtures.load('v3_users_b.json')
+return (httplib.OK, body, self.json_content_headers, 
httplib.responses[httplib.OK])
+raise NotImplementedError()
+
 def _v3_roles(self, method, url, body, headers):
 if method == 'GET':
 body = self.fixtures.load('v3_roles.json')

http://git-wip-us.apache.org/repos/asf/libcloud/blob/8efa20a6/libcloud/test/compute/fixtures/openstack_identity/v3/v3_users_b.json
--
diff --git 
a/libcloud/test/compute/fixtures/openstack_identity/v3/v3_users_b.json 
b/libcloud/test/compute/fixtures/openstack_identity/v3/v3_users_b.json
new file mode 100644
index 000..293ac5b
--- /dev/null
+++ b/libcloud/test/compute/fixtures/openstack_identity/v3/v3_users_b.json
@@ -0,0 +1,17 @@
+{
+"user":
+  {
+  "name": "userwithoutemail",
+  "links": {
+  "self": "http://192.168.18.100:5000/v3/users/b;
+  },
+  "domain_id": "default",
+  "enabled": true,
+  "id": "b"
+  },
+"links": {
+"self": "http://192.168.18.100:5000/v3/users;,
+"previous": null,
+"next": null
+}
+}



[jira] [Commented] (LIBCLOUD-1014) Add tags when create a snapshot

2018-10-26 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/LIBCLOUD-1014?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16665408#comment-16665408
 ] 

ASF GitHub Bot commented on LIBCLOUD-1014:
--

Github user asfgit closed the pull request at:

https://github.com/apache/libcloud/pull/1240


> Add tags when create a snapshot
> ---
>
> Key: LIBCLOUD-1014
> URL: https://issues.apache.org/jira/browse/LIBCLOUD-1014
> Project: Libcloud
>  Issue Type: Improvement
>  Components: Compute
>Reporter: Rafael dos Santos Goncalves
>Priority: Minor
>  Labels: features
>   Original Estimate: 10m
>  Remaining Estimate: 10m
>
> Hello, 
>     In my aws account have a lot of snapshots of many different projects. To 
> organize that, i need to create tags in my snapshots. Looking the method 
> [create_volume_snapshot|https://libcloud.readthedocs.io/en/latest/compute/drivers/ec2.html#libcloud.compute.drivers.ec2.BaseEC2NodeDriver.create_volume_snapshot]
>  i can't create tags. We can improve that method to accept metadata, what you 
> think ?
>  
> Thanks :D



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (LIBCLOUD-1014) Add tags when create a snapshot

2018-10-26 Thread ASF subversion and git services (JIRA)


[ 
https://issues.apache.org/jira/browse/LIBCLOUD-1014?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16665404#comment-16665404
 ] 

ASF subversion and git services commented on LIBCLOUD-1014:
---

Commit 51b6609f8d34d9fe73134fdc76aa968cd1210425 in libcloud's branch 
refs/heads/trunk from elesbom
[ https://git-wip-us.apache.org/repos/asf?p=libcloud.git;h=51b6609 ]

[LIBCLOUD-1014] Accept metadata when create a snapshot


> Add tags when create a snapshot
> ---
>
> Key: LIBCLOUD-1014
> URL: https://issues.apache.org/jira/browse/LIBCLOUD-1014
> Project: Libcloud
>  Issue Type: Improvement
>  Components: Compute
>Reporter: Rafael dos Santos Goncalves
>Priority: Minor
>  Labels: features
>   Original Estimate: 10m
>  Remaining Estimate: 10m
>
> Hello, 
>     In my aws account have a lot of snapshots of many different projects. To 
> organize that, i need to create tags in my snapshots. Looking the method 
> [create_volume_snapshot|https://libcloud.readthedocs.io/en/latest/compute/drivers/ec2.html#libcloud.compute.drivers.ec2.BaseEC2NodeDriver.create_volume_snapshot]
>  i can't create tags. We can improve that method to accept metadata, what you 
> think ?
>  
> Thanks :D



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[GitHub] libcloud pull request #1240: [LIBCLOUD-1014] Accept tags when create a snaps...

2018-10-26 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/libcloud/pull/1240


---


[3/4] libcloud git commit: [LIBCLOUD-1014] PEP8

2018-10-26 Thread vdloo
[LIBCLOUD-1014] PEP8

Signed-off-by: Rick van de Loo 


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/60859882
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/60859882
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/60859882

Branch: refs/heads/trunk
Commit: 608598821758cab79ed5e61b370ee0407f03616a
Parents: 7dce67d
Author: elesbom 
Authored: Mon Sep 24 15:11:35 2018 -0300
Committer: Rick van de Loo 
Committed: Fri Oct 26 18:43:30 2018 +0200

--
 libcloud/test/compute/test_ec2.py | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/libcloud/blob/60859882/libcloud/test/compute/test_ec2.py
--
diff --git a/libcloud/test/compute/test_ec2.py 
b/libcloud/test/compute/test_ec2.py
index bc22666..15a7862 100644
--- a/libcloud/test/compute/test_ec2.py
+++ b/libcloud/test/compute/test_ec2.py
@@ -1803,13 +1803,12 @@ class NimbusTests(EC2Tests):
 self.assertExecutedMethodCount(0)
 
 def test_create_volume_snapshot_with_tags(self):
-vol = StorageVolume(id='vol-4282672b', name='test',
-state=StorageVolumeState.AVAILABLE,
-size=10, driver=self.driver)
-snap = self.driver.create_volume_snapshot(
-vol, 'Test snapshot', ex_metadata={'my_tag': 'test'})
-self.assertDictEqual({}, snap.extra['tags'])
-
+vol = StorageVolume(id='vol-4282672b', name='test',
+state=StorageVolumeState.AVAILABLE,
+size=10, driver=self.driver)
+snap = self.driver.create_volume_snapshot(
+vol, 'Test snapshot', ex_metadata={'my_tag': 'test'})
+self.assertDictEqual({}, snap.extra['tags'])
 
 
 class EucTests(LibcloudTestCase, TestCaseMixin):



[4/4] libcloud git commit: Add changes for #1240

2018-10-26 Thread vdloo
Add changes for #1240

Closes #1240


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/102608f1
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/102608f1
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/102608f1

Branch: refs/heads/trunk
Commit: 102608f165e47f469dc421e784d41e93f307caac
Parents: 6085988
Author: Rick van de Loo 
Authored: Fri Oct 26 18:46:03 2018 +0200
Committer: Rick van de Loo 
Committed: Fri Oct 26 18:46:03 2018 +0200

--
 CHANGES.rst | 3 +++
 1 file changed, 3 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/libcloud/blob/102608f1/CHANGES.rst
--
diff --git a/CHANGES.rst b/CHANGES.rst
index 48b560a..13a29f9 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -53,6 +53,9 @@ Compute
 - [EC2] Update instance sizes (GITHUB-1238)
   [Ward Vandewege]
 
+- [EC2] Accept tags when create a snapshot (LIBCLOUD-1014, GITHUB-1240)
+  [Rafael Gonçalves]
+
 - [GCE] Expand Firewall options coverage (LIBCLOUD-960, GITHUB-1144)
   [maxlip]
 



[jira] [Commented] (LIBCLOUD-1014) Add tags when create a snapshot

2018-10-26 Thread ASF subversion and git services (JIRA)


[ 
https://issues.apache.org/jira/browse/LIBCLOUD-1014?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16665405#comment-16665405
 ] 

ASF subversion and git services commented on LIBCLOUD-1014:
---

Commit 7dce67d17764bf47430c5e5207748fc25c8e73c1 in libcloud's branch 
refs/heads/trunk from elesbom
[ https://git-wip-us.apache.org/repos/asf?p=libcloud.git;h=7dce67d ]

[LIBCLOUD-1014] Fix test for PR #1240


> Add tags when create a snapshot
> ---
>
> Key: LIBCLOUD-1014
> URL: https://issues.apache.org/jira/browse/LIBCLOUD-1014
> Project: Libcloud
>  Issue Type: Improvement
>  Components: Compute
>Reporter: Rafael dos Santos Goncalves
>Priority: Minor
>  Labels: features
>   Original Estimate: 10m
>  Remaining Estimate: 10m
>
> Hello, 
>     In my aws account have a lot of snapshots of many different projects. To 
> organize that, i need to create tags in my snapshots. Looking the method 
> [create_volume_snapshot|https://libcloud.readthedocs.io/en/latest/compute/drivers/ec2.html#libcloud.compute.drivers.ec2.BaseEC2NodeDriver.create_volume_snapshot]
>  i can't create tags. We can improve that method to accept metadata, what you 
> think ?
>  
> Thanks :D



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (LIBCLOUD-1014) Add tags when create a snapshot

2018-10-26 Thread ASF subversion and git services (JIRA)


[ 
https://issues.apache.org/jira/browse/LIBCLOUD-1014?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16665406#comment-16665406
 ] 

ASF subversion and git services commented on LIBCLOUD-1014:
---

Commit 608598821758cab79ed5e61b370ee0407f03616a in libcloud's branch 
refs/heads/trunk from elesbom
[ https://git-wip-us.apache.org/repos/asf?p=libcloud.git;h=6085988 ]

[LIBCLOUD-1014] PEP8

Signed-off-by: Rick van de Loo 


> Add tags when create a snapshot
> ---
>
> Key: LIBCLOUD-1014
> URL: https://issues.apache.org/jira/browse/LIBCLOUD-1014
> Project: Libcloud
>  Issue Type: Improvement
>  Components: Compute
>Reporter: Rafael dos Santos Goncalves
>Priority: Minor
>  Labels: features
>   Original Estimate: 10m
>  Remaining Estimate: 10m
>
> Hello, 
>     In my aws account have a lot of snapshots of many different projects. To 
> organize that, i need to create tags in my snapshots. Looking the method 
> [create_volume_snapshot|https://libcloud.readthedocs.io/en/latest/compute/drivers/ec2.html#libcloud.compute.drivers.ec2.BaseEC2NodeDriver.create_volume_snapshot]
>  i can't create tags. We can improve that method to accept metadata, what you 
> think ?
>  
> Thanks :D



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[2/4] libcloud git commit: [LIBCLOUD-1014] Accept metadata when create a snapshot

2018-10-26 Thread vdloo
[LIBCLOUD-1014] Accept metadata when create a snapshot


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/51b6609f
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/51b6609f
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/51b6609f

Branch: refs/heads/trunk
Commit: 51b6609f8d34d9fe73134fdc76aa968cd1210425
Parents: 2dcf434
Author: elesbom 
Authored: Mon Sep 24 13:18:42 2018 -0300
Committer: Rick van de Loo 
Committed: Fri Oct 26 18:43:27 2018 +0200

--
 libcloud/compute/drivers/ec2.py   | 14 +++---
 libcloud/test/compute/test_ec2.py |  8 
 2 files changed, 19 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/libcloud/blob/51b6609f/libcloud/compute/drivers/ec2.py
--
diff --git a/libcloud/compute/drivers/ec2.py b/libcloud/compute/drivers/ec2.py
index 00e3829..badb97c 100644
--- a/libcloud/compute/drivers/ec2.py
+++ b/libcloud/compute/drivers/ec2.py
@@ -2132,7 +2132,7 @@ class BaseEC2NodeDriver(NodeDriver):
 response = self.connection.request(self.path, params=params).object
 return self._get_boolean(response)
 
-def create_volume_snapshot(self, volume, name=None):
+def create_volume_snapshot(self, volume, name=None, ex_metadata=None):
 """
 Create snapshot from volume
 
@@ -2142,6 +2142,10 @@ class BaseEC2NodeDriver(NodeDriver):
 :param  name: Name of snapshot (optional)
 :type   name: ``str``
 
+:keywordex_metadata: The Key/Value metadata to associate
+ with a snapshot (optional)
+:type   ex_metadata: ``dict``
+
 :rtype: :class:`VolumeSnapshot`
 """
 params = {
@@ -2153,11 +2157,15 @@ class BaseEC2NodeDriver(NodeDriver):
 params.update({
 'Description': name,
 })
+if ex_metadata is None:
+ex_metadata = {}
+
 response = self.connection.request(self.path, params=params).object
 snapshot = self._to_snapshot(response, name)
 
-if name and self.ex_create_tags(snapshot, {'Name': name}):
-snapshot.extra['tags']['Name'] = name
+ex_metadata.update(**{'Name': name} if name else {})
+if self.ex_create_tags(snapshot, ex_metadata):
+snapshot.extra['tags'] = ex_metadata
 
 return snapshot
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/51b6609f/libcloud/test/compute/test_ec2.py
--
diff --git a/libcloud/test/compute/test_ec2.py 
b/libcloud/test/compute/test_ec2.py
index 2fb93cd..430718a 100644
--- a/libcloud/test/compute/test_ec2.py
+++ b/libcloud/test/compute/test_ec2.py
@@ -933,6 +933,14 @@ class EC2Tests(LibcloudTestCase, TestCaseMixin):
 # 2013-08-15T16:22:30.000Z
 self.assertEqual(datetime(2013, 8, 15, 16, 22, 30, tzinfo=UTC), 
snap.created)
 
+def test_create_volume_snapshot_with_tags(self):
+vol = StorageVolume(id='vol-4282672b', name='test',
+state=StorageVolumeState.AVAILABLE,
+size=10, driver=self.driver)
+snap = self.driver.create_volume_snapshot(
+vol, 'Test snapshot', ex_metadata={'my_tag': 'test'})
+self.assertEqual('test', snap.extra['tags']['my_tag'])
+
 def test_list_snapshots(self):
 snaps = self.driver.list_snapshots()
 



[1/4] libcloud git commit: [LIBCLOUD-1014] Fix test for PR #1240

2018-10-26 Thread vdloo
Repository: libcloud
Updated Branches:
  refs/heads/trunk 2dcf43400 -> 102608f16


[LIBCLOUD-1014] Fix test for PR #1240


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/7dce67d1
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/7dce67d1
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/7dce67d1

Branch: refs/heads/trunk
Commit: 7dce67d17764bf47430c5e5207748fc25c8e73c1
Parents: 51b6609
Author: elesbom 
Authored: Mon Sep 24 14:39:59 2018 -0300
Committer: Rick van de Loo 
Committed: Fri Oct 26 18:43:27 2018 +0200

--
 libcloud/test/compute/test_ec2.py | 9 +
 1 file changed, 9 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/libcloud/blob/7dce67d1/libcloud/test/compute/test_ec2.py
--
diff --git a/libcloud/test/compute/test_ec2.py 
b/libcloud/test/compute/test_ec2.py
index 430718a..bc22666 100644
--- a/libcloud/test/compute/test_ec2.py
+++ b/libcloud/test/compute/test_ec2.py
@@ -1802,6 +1802,15 @@ class NimbusTests(EC2Tests):
 self.driver.ex_create_tags(resource=node, tags={'foo': 'bar'})
 self.assertExecutedMethodCount(0)
 
+def test_create_volume_snapshot_with_tags(self):
+vol = StorageVolume(id='vol-4282672b', name='test',
+state=StorageVolumeState.AVAILABLE,
+size=10, driver=self.driver)
+snap = self.driver.create_volume_snapshot(
+vol, 'Test snapshot', ex_metadata={'my_tag': 'test'})
+self.assertDictEqual({}, snap.extra['tags'])
+
+
 
 class EucTests(LibcloudTestCase, TestCaseMixin):