libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seb...@apache.org
Subject libcloud git commit: Auroracompute: Add support for multiple regions
Date Thu, 05 Nov 2015 13:30:48 GMT
Repository: libcloud
Updated Branches:
  refs/heads/trunk be5c62930 -> 4ba3f8d90


Auroracompute: Add support for multiple regions

Signed-off-by: runseb <runseb@gmail.com>

This closes #623


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

Branch: refs/heads/trunk
Commit: 4ba3f8d90fdf5bd5f09118d1ddda4c09854f316c
Parents: be5c629
Author: Wido den Hollander <wido@pcextreme.nl>
Authored: Wed Oct 28 15:02:41 2015 +0100
Committer: runseb <runseb@gmail.com>
Committed: Thu Nov 5 14:30:03 2015 +0100

----------------------------------------------------------------------
 CHANGES.rst                                     |  4 +++
 docs/compute/drivers/auroracompute.rst          | 21 ++++++++++--
 .../auroracompute/instantiate_driver_region.py  |  9 ++++++
 libcloud/compute/drivers/auroracompute.py       | 34 ++++++++++++++++++--
 libcloud/test/compute/test_auroracompute.py     | 28 +++++++++++++++-
 5 files changed, 90 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/4ba3f8d9/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index 1b50b45..f12f802 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -22,6 +22,10 @@ Compute
 - Return proper volume state for CloudStack volumes.
   (GITHUB-615, LIBCLOUD-764)
   [Wido den Hollander]
+
+- Add support for multiple regions in Aurora compute driver
+  (GITHUB-623)
+  [Wido den Hollander]
     
 Storage
 ~~~~~~~

http://git-wip-us.apache.org/repos/asf/libcloud/blob/4ba3f8d9/docs/compute/drivers/auroracompute.rst
----------------------------------------------------------------------
diff --git a/docs/compute/drivers/auroracompute.rst b/docs/compute/drivers/auroracompute.rst
index 07929c8..95d195c 100644
--- a/docs/compute/drivers/auroracompute.rst
+++ b/docs/compute/drivers/auroracompute.rst
@@ -16,7 +16,7 @@ The datacenters / availability zones are located in:
 .. figure:: /_static/images/provider_logos/pcextreme.png
     :align: center
     :width: 300
-    :target: https://www.pcextreme.nl/en/aurora/compute
+    :target: https://www.pcextreme.com/aurora/compute
 
 The AuroraCompute driver is based on the CloudStack driver. Please refer to
 :doc:`CloudStack Compute Driver Documentation <cloudstack>` page for more
@@ -41,6 +41,23 @@ With these credentials you can instantiate a driver:
    :language: python
 
 
+Using a different region
+------------------------
+
+By default the region AMS (Amsterdam) is selected by the driver.
+
+AuroraCompute supports multiple regions and when instantiating the driver you can
+choose a region.
+
+Keep in mind that each region uses different credentials. These can be found in
+the `Control Panel`_ under your users.
+
+In this example we select the Miami (MIA) region:
+
+.. literalinclude:: /examples/compute/auroracompute/instantiate_driver_region.py
+   :language: python
+
+
 API Docs
 --------
 
@@ -48,5 +65,5 @@ API Docs
     :members:
     :inherited-members:
 
-.. _`PCextreme B.V.`: https://www.pcextreme.nl/
+.. _`PCextreme B.V.`: https://www.pcextreme.com/
 .. _`Control Panel`: https://cp.pcextreme.nl/

http://git-wip-us.apache.org/repos/asf/libcloud/blob/4ba3f8d9/docs/examples/compute/auroracompute/instantiate_driver_region.py
----------------------------------------------------------------------
diff --git a/docs/examples/compute/auroracompute/instantiate_driver_region.py b/docs/examples/compute/auroracompute/instantiate_driver_region.py
new file mode 100644
index 0000000..7d6bed8
--- /dev/null
+++ b/docs/examples/compute/auroracompute/instantiate_driver_region.py
@@ -0,0 +1,9 @@
+from libcloud.compute.types import Provider
+from libcloud.compute.providers import get_driver
+from libcloud.compute.drivers.auroracompute import AuroraComputeRegion
+
+apikey = 'mykey'
+secretkey = 'mysecret'
+
+Driver = get_driver(Provider.AURORACOMPUTE, region=AuroraComputeRegion.MIA)
+conn = Driver(key=apikey, secret=secretkey)

http://git-wip-us.apache.org/repos/asf/libcloud/blob/4ba3f8d9/libcloud/compute/drivers/auroracompute.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/auroracompute.py b/libcloud/compute/drivers/auroracompute.py
index 392f5df..6be67ed 100644
--- a/libcloud/compute/drivers/auroracompute.py
+++ b/libcloud/compute/drivers/auroracompute.py
@@ -17,13 +17,41 @@ from libcloud.compute.providers import Provider
 from libcloud.compute.drivers.cloudstack import CloudStackNodeDriver
 
 __all__ = [
+    'AuroraComputeRegion',
     'AuroraComputeNodeDriver'
 ]
 
 
+class AuroraComputeRegion(object):
+    AMS = 'Amsterdam'
+    RTD = 'Rotterdam'
+    MIA = 'Miami'
+    LAX = 'Los Angeles'
+    TYO = 'Tokyo'
+
+
+REGION_ENDPOINT_MAP = {
+    AuroraComputeRegion.AMS: '/ams',
+    AuroraComputeRegion.RTD: '/rtd',
+    AuroraComputeRegion.MIA: '/mia',
+    AuroraComputeRegion.LAX: '/lax',
+    AuroraComputeRegion.TYO: '/tyo'
+}
+
+
 class AuroraComputeNodeDriver(CloudStackNodeDriver):
     type = Provider.AURORACOMPUTE
     name = 'PCextreme AuroraCompute'
-    website = 'https://www.pcextreme.nl/en/aurora/compute'
-    host = 'cloud.pcextreme.nl'
-    path = '/api'
+    website = 'https://www.pcextreme.com/aurora/compute'
+
+    def __init__(self, key, secret, path=None, host=None, url=None,
+                 region=None):
+        if host is None:
+            host = 'api.auroracompute.eu'
+
+        if path is None:
+            path = REGION_ENDPOINT_MAP.get(region, '/ams')
+
+        super(AuroraComputeNodeDriver, self).__init__(key=key, secret=secret,
+                                                      host=host, path=path,
+                                                      secure=True)

http://git-wip-us.apache.org/repos/asf/libcloud/blob/4ba3f8d9/libcloud/test/compute/test_auroracompute.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_auroracompute.py b/libcloud/test/compute/test_auroracompute.py
index 7d0ea3a..33ba158 100644
--- a/libcloud/test/compute/test_auroracompute.py
+++ b/libcloud/test/compute/test_auroracompute.py
@@ -16,12 +16,38 @@
 import sys
 
 from libcloud.compute.drivers.auroracompute import AuroraComputeNodeDriver
+from libcloud.compute.drivers.auroracompute import AuroraComputeRegion
 from libcloud.test.compute.test_cloudstack import CloudStackCommonTestCase
 from libcloud.test import unittest
 
 
-class AuroraComputeNodeDriverTestCase(CloudStackCommonTestCase, unittest.TestCase):
+class AuroraComputeNodeDriverTestCase(CloudStackCommonTestCase,
+                                      unittest.TestCase):
     driver_klass = AuroraComputeNodeDriver
 
+    def test_api_host(self):
+        driver = self.driver_klass('invalid', 'invalid')
+        self.assertEqual(driver.host, 'api.auroracompute.eu')
+
+    def test_without_region(self):
+        driver = self.driver_klass('invalid', 'invalid')
+        self.assertEqual(driver.path, '/ams')
+
+    def test_with_ams_region(self):
+        driver = self.driver_klass('invalid', 'invalid',
+                                   region=AuroraComputeRegion.AMS)
+        self.assertEqual(driver.path, '/ams')
+
+    def test_with_miami_region(self):
+        driver = self.driver_klass('invalid', 'invalid',
+                                   region=AuroraComputeRegion.MIA)
+        self.assertEqual(driver.path, '/mia')
+
+    def test_with_tokyo_region(self):
+        driver = self.driver_klass('invalid', 'invalid',
+                                   region=AuroraComputeRegion.TYO)
+        self.assertEqual(driver.path, '/tyo')
+
+
 if __name__ == '__main__':
     sys.exit(unittest.main())


Mime
View raw message