Repository: libcloud
Updated Branches:
  refs/heads/trunk f13b236ef -> 6f21c38dc


Allow location of the data center to be supplied
Closes #635
Signed-off-by: Anthony Shaw <[email protected]>


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

Branch: refs/heads/trunk
Commit: 3415ef20ed259a5ef7ae5adbda4c2abe34f82522
Parents: f13b236
Author: Joel Reymont <[email protected]>
Authored: Wed Nov 18 22:14:34 2015 +0100
Committer: Anthony Shaw <[email protected]>
Committed: Thu Nov 19 06:55:06 2015 +0800

----------------------------------------------------------------------
 libcloud/compute/drivers/profitbricks.py | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/3415ef20/libcloud/compute/drivers/profitbricks.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/profitbricks.py 
b/libcloud/compute/drivers/profitbricks.py
index fa33f0c..53fba79 100644
--- a/libcloud/compute/drivers/profitbricks.py
+++ b/libcloud/compute/drivers/profitbricks.py
@@ -375,10 +375,10 @@ class ProfitBricksNodeDriver(NodeDriver):
 
         return True
 
-    def create_node(self, name, image, size=None, volume=None,
-                    ex_datacenter=None, ex_internet_access=True,
-                    ex_availability_zone=None, ex_ram=None,
-                    ex_cores=None, ex_disk=None, **kwargs):
+    def create_node(self, name, image, size=None, location=None,
+                    volume=None, ex_datacenter=None, ex_internet_access=True,
+                    ex_availability_zone=None, ex_ram=None, ex_cores=None,
+                    ex_disk=None, **kwargs):
         """
         Creates a node.
 
@@ -389,6 +389,10 @@ class ProfitBricksNodeDriver(NodeDriver):
         :param volume: If the volume already exists then pass this in.
         :type volume: :class:`StorageVolume`
 
+        :param location: The location of the new data center
+            if one is not supplied.
+        :type location: : :class:`NodeLocation`
+
         :param ex_datacenter: If you've already created the DC then pass
                            it in.
         :type ex_datacenter: :class:`Datacenter`
@@ -417,7 +421,10 @@ class ProfitBricksNodeDriver(NodeDriver):
             '''
 
             'Creating a Datacenter for the node since one was not provided.'
-            new_datacenter = self._create_new_datacenter_for_node(name=name)
+            new_datacenter = self._create_new_datacenter_for_node(
+                name=name,
+                location=location
+            )
             datacenter_id = new_datacenter.id
 
             'Waiting for the Datacenter create operation to finish.'
@@ -1431,13 +1438,17 @@ class ProfitBricksNodeDriver(NodeDriver):
 
         return datacenter
 
-    def _create_new_datacenter_for_node(self, name):
+    def _create_new_datacenter_for_node(self, name, location):
         """
         Creates a Datacenter for a node.
         """
         dc_name = name + '-DC'
 
-        return self.ex_create_datacenter(name=dc_name, location='us/las')
+        if not location:
+            loc = 'us/las'
+        else:
+            loc = location.id
+        return self.ex_create_datacenter(name=dc_name, location=loc)
 
     def _wait_for_storage_volume_state(self, volume, state=NodeState.RUNNING,
                                        timeout=300, interval=5):

Reply via email to