Skip to content

Commit

Permalink
auroracompute: Add support for multiple regions
Browse files Browse the repository at this point in the history
  • Loading branch information
wido committed Nov 2, 2015
1 parent d9f1abd commit 8d9a06d
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 5 deletions.
21 changes: 19 additions & 2 deletions docs/compute/drivers/auroracompute.rst
Expand Up @@ -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
Expand All @@ -41,12 +41,29 @@ 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
--------

.. autoclass:: libcloud.compute.drivers.auroracompute.AuroraComputeNodeDriver
:members:
:inherited-members:

.. _`PCextreme B.V.`: https://www.pcextreme.nl/
.. _`PCextreme B.V.`: https://www.pcextreme.com/
.. _`Control Panel`: https://cp.pcextreme.nl/
@@ -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)
34 changes: 31 additions & 3 deletions libcloud/compute/drivers/auroracompute.py
Expand Up @@ -17,13 +17,41 @@
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)

0 comments on commit 8d9a06d

Please sign in to comment.