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 2018/07/06 06:18:15 UTC

[1/2] libcloud git commit: openstack: add get_user method

Repository: libcloud
Updated Branches:
  refs/heads/trunk b5592af8b -> 8a9ffd1df


openstack: add get_user method

libcloud's OpenStack compute nodes have a "userId" value in node.extra.

Add a new get_user() method to the OpenStackIdentityConnection v3 class
to look up this user by the user ID value.

This allows callers to discover more information about the user that
created a node (for example).

Signed-off-by: Quentin Pradet <qu...@apache.org>


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

Branch: refs/heads/trunk
Commit: 72722703110fc66d4919d6779297e3b85f253174
Parents: b5592af
Author: Ken Dreyer <kt...@ktdreyer.com>
Authored: Fri Jun 1 11:04:09 2018 -0600
Committer: Quentin Pradet <qu...@apache.org>
Committed: Fri Jul 6 10:15:42 2018 +0400

----------------------------------------------------------------------
 libcloud/common/openstack_identity.py           | 14 ++++++++++++++
 libcloud/test/common/test_openstack_identity.py | 11 +++++++++++
 2 files changed, 25 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/72722703/libcloud/common/openstack_identity.py
----------------------------------------------------------------------
diff --git a/libcloud/common/openstack_identity.py b/libcloud/common/openstack_identity.py
index 4285933..3d09681 100644
--- a/libcloud/common/openstack_identity.py
+++ b/libcloud/common/openstack_identity.py
@@ -1130,6 +1130,20 @@ class OpenStackIdentity_3_0_Connection(OpenStackIdentityConnection):
         result = self._to_domain(data=response.object['domain'])
         return result
 
+    def get_user(self, user_id):
+        """
+        Get a user account by ID.
+
+        :param user_id: User's id.
+        :type name: ``str``
+
+        :return: Located user.
+        :rtype: :class:`.OpenStackIdentityUser`
+        """
+        response = self.authenticated_request('/v3/users/%s' % user_id)
+        user = self._to_user(data=response.object['user'])
+        return user
+
     def list_user_projects(self, user):
         """
         Retrieve all the projects user belongs to.

http://git-wip-us.apache.org/repos/asf/libcloud/blob/72722703/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 c36f13a..916193f 100644
--- a/libcloud/test/common/test_openstack_identity.py
+++ b/libcloud/test/common/test_openstack_identity.py
@@ -366,6 +366,13 @@ class OpenStackIdentity_3_0_ConnectionTests(unittest.TestCase):
         domain = self.auth_instance.get_domain(domain_id='default')
         self.assertEqual(domain.name, 'Default')
 
+    def test_get_user(self):
+        user = self.auth_instance.get_user(user_id='a')
+        self.assertEqual(user.id, 'a')
+        self.assertEqual(user.domain_id, 'default')
+        self.assertEqual(user.enabled, True)
+        self.assertEqual(user.email, 'openstack-test@localhost')
+
     def test_create_user(self):
         user = self.auth_instance.create_user(email='test2@localhost', password='test1',
                                               name='test2', domain_id='default')
@@ -682,6 +689,10 @@ class OpenStackIdentity_3_0_MockHttp(MockHttp):
         raise NotImplementedError()
 
     def _v3_users_a(self, method, url, body, headers):
+        if method == 'GET':
+            # look up a user
+            body = self.fixtures.load('v3_users_a.json')
+            return (httplib.OK, body, self.json_content_headers, httplib.responses[httplib.OK])
         if method == 'PATCH':
             # enable / disable user
             body = self.fixtures.load('v3_users_a.json')


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

Posted by qu...@apache.org.
Add changes for #1216

Closes #1216, closes #1220


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

Branch: refs/heads/trunk
Commit: 8a9ffd1dfc3318193145e4e7cae10e11900acd1c
Parents: 7272270
Author: Quentin Pradet <qu...@apache.org>
Authored: Fri Jul 6 10:17:00 2018 +0400
Committer: Quentin Pradet <qu...@apache.org>
Committed: Fri Jul 6 10:17:15 2018 +0400

----------------------------------------------------------------------
 CHANGES.rst | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/8a9ffd1d/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index 8dcda6b..2f790ed 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -90,7 +90,10 @@ Compute
 - [OpenStack] Implement port attaching/detaching (GITHUB-1225)
   [Rick van de Loo]
 
-- [Scaleway] New Scaleway driver (GITHUB-1121, GITHUB-1216)
+- [OpenStack] Add get_user method (GITHUB-1216)
+  [Ken Dreyer]
+
+- [Scaleway] New Scaleway driver (GITHUB-1121, GITHUB-1220)
   [Daniel Hunsaker, Nándor István Krácser, Rémy Léone]
 
 DNS