You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2013/10/12 11:46:57 UTC

[6/9] git commit: Assign region instance variable in the BaseDriver class.

Assign region instance variable in the BaseDriver class.


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

Branch: refs/heads/trunk
Commit: 10fa6806a59f3e4369c96c9b9ae6a87efd63314b
Parents: 0270594
Author: Tomaz Muraus <to...@apache.org>
Authored: Sat Oct 12 11:18:03 2013 +0200
Committer: Tomaz Muraus <to...@apache.org>
Committed: Sat Oct 12 11:18:03 2013 +0200

----------------------------------------------------------------------
 libcloud/common/base.py               |  7 ++++++-
 libcloud/compute/drivers/rackspace.py | 12 ++++++------
 2 files changed, 12 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/10fa6806/libcloud/common/base.py
----------------------------------------------------------------------
diff --git a/libcloud/common/base.py b/libcloud/common/base.py
index 0592a6a..3d6a9dc 100644
--- a/libcloud/common/base.py
+++ b/libcloud/common/base.py
@@ -823,7 +823,7 @@ class BaseDriver(object):
     connectionCls = ConnectionKey
 
     def __init__(self, key, secret=None, secure=True, host=None, port=None,
-                 api_version=None, **kwargs):
+                 api_version=None, region=None, **kwargs):
         """
         :param    key:    API key or username to be used (required)
         :type     key:    ``str``
@@ -845,6 +845,10 @@ class BaseDriver(object):
                                  which support multiple API versions.
         :type     api_version: ``str``
 
+        :param region: Optional driver region. Only used by drivers which
+                       support multiple regions.
+        :type region: ``str``
+
         :rtype: ``None``
         """
 
@@ -865,6 +869,7 @@ class BaseDriver(object):
             args.append(port)
 
         self.api_version = api_version
+        self.region = region
 
         conn_kwargs = self._ex_connection_class_kwargs()
         self.connection = self.connectionCls(*args, **conn_kwargs)

http://git-wip-us.apache.org/repos/asf/libcloud/blob/10fa6806/libcloud/compute/drivers/rackspace.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/rackspace.py b/libcloud/compute/drivers/rackspace.py
index fd7ba5b..75e5333 100644
--- a/libcloud/compute/drivers/rackspace.py
+++ b/libcloud/compute/drivers/rackspace.py
@@ -84,13 +84,13 @@ class RackspaceFirstGenNodeDriver(OpenStack_1_0_NodeDriver):
         if region not in ['us', 'uk']:
             raise ValueError('Invalid region: %s' % (region))
 
-        self.region = region
-
         super(RackspaceFirstGenNodeDriver, self).__init__(key=key,
                                                           secret=secret,
                                                           secure=secure,
                                                           host=host,
-                                                          port=port, **kwargs)
+                                                          port=port,
+                                                          region=region,
+                                                          **kwargs)
 
     def list_locations(self):
         """
@@ -178,11 +178,11 @@ class RackspaceNodeDriver(OpenStack_1_1_NodeDriver):
         else:
             self.api_name = 'rackspacenovaus'
 
-        self.region = region
-
         super(RackspaceNodeDriver, self).__init__(key=key, secret=secret,
                                                   secure=secure, host=host,
-                                                  port=port, **kwargs)
+                                                  port=port,
+                                                  region=region,
+                                                  **kwargs)
 
     def _ex_connection_class_kwargs(self):
         kwargs = self.openstack_connection_kwargs()