Author: tomaz
Date: Tue Jul  3 01:58:43 2012
New Revision: 1356540

URL: http://svn.apache.org/viewvc?rev=1356540&view=rev
Log:
Add 'auth_user_variable' to the  OpenStackAuthConnection class. Contributed by
Mark Everrert, part of GITHUB-68.

Modified:
    libcloud/trunk/CHANGES
    libcloud/trunk/libcloud/common/openstack.py
    libcloud/trunk/libcloud/test/compute/test_openstack.py

Modified: libcloud/trunk/CHANGES
URL: 
http://svn.apache.org/viewvc/libcloud/trunk/CHANGES?rev=1356540&r1=1356539&r2=1356540&view=diff
==============================================================================
--- libcloud/trunk/CHANGES (original)
+++ libcloud/trunk/CHANGES Tue Jul  3 01:58:43 2012
@@ -70,6 +70,9 @@ Changes with Apache Libcloud in developm
       the eu-west-1 region.
       [Tomaz Muraus]
 
+    - Add 'auth_user_variable' to the  OpenStackAuthConnection class.
+      [Mark Everett]
+
   *) DNS
 
     - Add support for GEO RecordType to Zerigo driver. ; LIBCLOUD-203

Modified: libcloud/trunk/libcloud/common/openstack.py
URL: 
http://svn.apache.org/viewvc/libcloud/trunk/libcloud/common/openstack.py?rev=1356540&r1=1356539&r2=1356540&view=diff
==============================================================================
--- libcloud/trunk/libcloud/common/openstack.py (original)
+++ libcloud/trunk/libcloud/common/openstack.py Tue Jul  3 01:58:43 2012
@@ -147,6 +147,7 @@ class OpenStackAuthConnection(Connection
             self.urls['cloudFiles'] = \
                 [{'publicURL': headers.get('x-storage-url', None)}]
             self.auth_token = headers.get('x-auth-token', None)
+            self.auth_auth_user_info = None
 
             if not self.auth_token:
                 raise MalformedResponseError('Missing X-Auth-Token in \
@@ -177,6 +178,7 @@ class OpenStackAuthConnection(Connection
                 self.auth_token = body['auth']['token']['id']
                 self.auth_token_expires = body['auth']['token']['expires']
                 self.urls = body['auth']['serviceCatalog']
+                self.auth_user_info = None
             except KeyError:
                 e = sys.exc_info()[1]
                 raise MalformedResponseError('Auth JSON response is \
@@ -229,6 +231,7 @@ class OpenStackAuthConnection(Connection
                 self.auth_token = access['token']['id']
                 self.auth_token_expires = access['token']['expires']
                 self.urls = access['serviceCatalog']
+                self.auth_user_info = access.get('user', {})
             except KeyError:
                 e = sys.exc_info()[1]
                 raise MalformedResponseError('Auth JSON response is \
@@ -380,6 +383,7 @@ class OpenStackBaseConnection(Connection
     auth_url = None
     auth_token = None
     auth_token_expires = None
+    auth_user_info = None
     service_catalog = None
     service_type = None
     service_name = None
@@ -480,6 +484,7 @@ class OpenStackBaseConnection(Connection
 
             self.auth_token = osa.auth_token
             self.auth_token_expires = osa.auth_token_expires
+            self.auth_user_info = osa.auth_user_info
 
             # pull out and parse the service catalog
             self.service_catalog = OpenStackServiceCatalog(osa.urls,

Modified: libcloud/trunk/libcloud/test/compute/test_openstack.py
URL: 
http://svn.apache.org/viewvc/libcloud/trunk/libcloud/test/compute/test_openstack.py?rev=1356540&r1=1356539&r2=1356540&view=diff
==============================================================================
--- libcloud/trunk/libcloud/test/compute/test_openstack.py (original)
+++ libcloud/trunk/libcloud/test/compute/test_openstack.py Tue Jul  3 01:58:43 
2012
@@ -1046,5 +1046,15 @@ class OpenStack_1_1_Auth_2_0_Tests(OpenS
         clear_pricing_data()
         self.node = self.driver.list_nodes()[1]
 
+    def test_auth_user_info_is_set(self):
+        self.driver.connection._populate_hosts_and_request_paths()
+        self.assertEquals(self.driver.connection.auth_user_info, {
+            'id': '7',
+            'name': 'testuser',
+            'roles': [{'description': 'Default Role.',
+                        'id': 'identity:default',
+                        'name': 'identity:default'}]})
+
+
 if __name__ == '__main__':
     sys.exit(unittest.main())


Reply via email to