libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r1351150 - in /libcloud/trunk/libcloud/common: base.py gogrid.py openstack.py
Date Sun, 17 Jun 2012 20:13:20 GMT
Author: tomaz
Date: Sun Jun 17 20:13:20 2012
New Revision: 1351150

URL: http://svn.apache.org/viewvc?rev=1351150&view=rev
Log:
pep8 cleanup, Contributed by DaeMyung Kang, part of LIBCLOUD-214.

Modified:
    libcloud/trunk/libcloud/common/base.py
    libcloud/trunk/libcloud/common/gogrid.py
    libcloud/trunk/libcloud/common/openstack.py

Modified: libcloud/trunk/libcloud/common/base.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/common/base.py?rev=1351150&r1=1351149&r2=1351150&view=diff
==============================================================================
--- libcloud/trunk/libcloud/common/base.py (original)
+++ libcloud/trunk/libcloud/common/base.py Sun Jun 17 20:13:20 2012
@@ -655,8 +655,8 @@ class PollingConnection(Connection):
 
         - Returned 'job_id' is then used to construct a URL which is used for
           retrieving job status. Constructed URL is then periodically polled
-          until the response indicates that the job has completed or the timeout
-          of 'self.timeout' seconds has been reached.
+          until the response indicates that the job has completed or the
+          timeout of 'self.timeout' seconds has been reached.
 
         @type action: C{str}
         @param action: A path
@@ -755,7 +755,8 @@ class ConnectionKey(Connection):
         passed value.
         """
         super(ConnectionKey, self).__init__(secure=secure, host=host,
-                                            port=port, url=url, timeout=timeout)
+                                            port=port, url=url,
+                                            timeout=timeout)
         self.key = key
 
 
@@ -825,7 +826,8 @@ class BaseDriver(object):
 
         self.api_version = api_version
 
-        self.connection = self.connectionCls(*args, **self._ex_connection_class_kwargs())
+        self.connection = self.connectionCls(*args,
+            **self._ex_connection_class_kwargs())
 
         self.connection.driver = self
         self.connection.connect()

Modified: libcloud/trunk/libcloud/common/gogrid.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/common/gogrid.py?rev=1351150&r1=1351149&r2=1351150&view=diff
==============================================================================
--- libcloud/trunk/libcloud/common/gogrid.py (original)
+++ libcloud/trunk/libcloud/common/gogrid.py Sun Jun 17 20:13:20 2012
@@ -44,7 +44,8 @@ class GoGridResponse(JsonResponse):
         if self.status == 403:
             raise InvalidCredsError('Invalid credentials', self.driver)
         if self.status == 401:
-            raise InvalidCredsError('API Key has insufficient rights', self.driver)
+            raise InvalidCredsError('API Key has insufficient rights',
+                self.driver)
         if not self.body:
             return None
         try:

Modified: libcloud/trunk/libcloud/common/openstack.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/common/openstack.py?rev=1351150&r1=1351149&r2=1351150&view=diff
==============================================================================
--- libcloud/trunk/libcloud/common/openstack.py (original)
+++ libcloud/trunk/libcloud/common/openstack.py Sun Jun 17 20:13:20 2012
@@ -140,9 +140,12 @@ class OpenStackAuthConnection(Connection
             headers = resp.headers
             # emulate the auth 1.1 URL list
             self.urls = {}
-            self.urls['cloudServers'] = [{'publicURL': headers.get('x-server-management-url',
None)}]
-            self.urls['cloudFilesCDN'] = [{'publicURL': headers.get('x-cdn-management-url',
None)}]
-            self.urls['cloudFiles'] = [{'publicURL': headers.get('x-storage-url', None)}]
+            self.urls['cloudServers'] = \
+                [{'publicURL': headers.get('x-server-management-url', None)}]
+            self.urls['cloudFilesCDN'] = \
+                [{'publicURL': headers.get('x-cdn-management-url', None)}]
+            self.urls['cloudFiles'] = \
+                [{'publicURL': headers.get('x-storage-url', None)}]
             self.auth_token = headers.get('x-auth-token', None)
 
             if not self.auth_token:
@@ -181,9 +184,9 @@ class OpenStackAuthConnection(Connection
 
     def authenticate_2_0_with_apikey(self):
         # API Key based authentication uses the RAX-KSKEY extension.
-        # https://github.com/openstack/keystone/tree/master/keystone/content/service
-        data = {'auth': 
-                {'RAX-KSKEY:apiKeyCredentials': 
+        # http://s.apache.org/oAi
+        data = {'auth':
+                {'RAX-KSKEY:apiKeyCredentials':
                  {'username': self.user_id, 'apiKey': self.key}}}
         if self.tenant_name:
             data['auth']['tenantName'] = self.tenant_name
@@ -193,9 +196,9 @@ class OpenStackAuthConnection(Connection
     def authenticate_2_0_with_password(self):
         # Password based authentication is the only 'core' authentication
         # method in Keystone at this time.
-        # 'keystone' - http://docs.openstack.org/api/openstack-identity-service/2.0/content/Identity-Service-Concepts-e1362.html
-        data = {'auth': 
-                {'passwordCredentials': 
+        # 'keystone' - http://s.apache.org/e8h
+        data = {'auth': \
+                {'passwordCredentials': \
                  {'username': self.user_id, 'password': self.key}}}
         if self.tenant_name:
             data['auth']['tenantName'] = self.tenant_name
@@ -263,7 +266,8 @@ class OpenStackServiceCatalog(object):
         eps = []
 
         if '2.0' in self._auth_version:
-            endpoints = self._service_catalog.get(service_type, {}).get(name, {})
+            endpoints = self._service_catalog.get(service_type, {}) \
+                                             .get(name, {})
         elif ('1.1' in self._auth_version) or ('1.0' in self._auth_version):
             endpoints = self._service_catalog.get(name, {})
 
@@ -275,7 +279,8 @@ class OpenStackServiceCatalog(object):
     def get_endpoint(self, service_type=None, name=None, region=None):
 
         if '2.0' in self._auth_version:
-            endpoint = self._service_catalog.get(service_type, {}).get(name, {}).get(region,
[])
+            endpoint = self._service_catalog.get(service_type, {}) \
+                                            .get(name, {}).get(region, [])
         elif ('1.1' in self._auth_version) or ('1.0' in self._auth_version):
             endpoint = self._service_catalog.get(name, {}).get(region, [])
 
@@ -300,9 +305,7 @@ class OpenStackServiceCatalog(object):
                 self._service_catalog[service][region].append(endpoint)
 
     def _parse_auth_v2(self, service_catalog):
-
         for service in service_catalog:
-
             service_type = service['type']
             service_name = service.get('name', None)
 
@@ -314,10 +317,12 @@ class OpenStackServiceCatalog(object):
 
             for endpoint in service.get('endpoints', []):
                 region = endpoint.get('region', None)
-                if region not in self._service_catalog[service_type][service_name]:
-                    self._service_catalog[service_type][service_name][region] = []
 
-                self._service_catalog[service_type][service_name][region].append(endpoint)
+                catalog = self._service_catalog[service_type][service_name]
+                if region not in catalog:
+                    catalog[region] = []
+
+                catalog[region].append(endpoint)
 
 
 class OpenStackBaseConnection(ConnectionUserAndKey):
@@ -359,15 +364,15 @@ class OpenStackBaseConnection(Connection
     is provided.
     @type ex_tenant_name: C{string}
 
-    @param ex_force_service_type: Service type to use when selecting an 
+    @param ex_force_service_type: Service type to use when selecting an
     service.  If not specified, a provider specific default will be used.
     @type ex_force_service_type: C{string}
 
-    @param ex_force_service_name: Service name to use when selecting an 
+    @param ex_force_service_name: Service name to use when selecting an
     service.  If not specified, a provider specific default will be used.
     @type ex_force_service_name: C{string}
 
-    @param ex_force_service_region: Region to use when selecting an 
+    @param ex_force_service_region: Region to use when selecting an
     service.  If not specified, a provider specific default will be used.
     @type ex_force_service_region: C{string}
     """
@@ -477,10 +482,13 @@ class OpenStackBaseConnection(Connection
             self.auth_token_expires = osa.auth_token_expires
 
             # pull out and parse the service catalog
-            self.service_catalog = OpenStackServiceCatalog(osa.urls, ex_force_auth_version=self._auth_version)
+            self.service_catalog = OpenStackServiceCatalog(osa.urls,
+                    ex_force_auth_version=self._auth_version)
 
         # Set up connection info
-        (self.host, self.port, self.secure, self.request_path) = self._tuple_from_url(self._ex_force_base_url
or self.get_endpoint())
+        url = self._ex_force_base_url or self.get_endpoint()
+        (self.host, self.port, self.secure, self.request_path) = \
+                self._tuple_from_url(url)
 
     def _add_cache_busting_to_params(self, params):
         cache_busting_number = binascii.hexlify(os.urandom(8))
@@ -501,7 +509,8 @@ class OpenStackDriverMixin(object):
         self._ex_tenant_name = kwargs.get('ex_tenant_name', None)
         self._ex_force_service_type = kwargs.get('ex_force_service_type', None)
         self._ex_force_service_name = kwargs.get('ex_force_service_name', None)
-        self._ex_force_service_region = kwargs.get('ex_force_service_region', None)
+        self._ex_force_service_region = kwargs.get('ex_force_service_region',
+                                                   None)
 
     def openstack_connection_kwargs(self):
         rv = {}



Mime
View raw message