libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject [1/9] libcloud git commit: Add documentation. Add support for passing dict into cloud_environments to supply explicit endpoints.
Date Fri, 21 Apr 2017 22:12:38 GMT
Repository: libcloud
Updated Branches:
  refs/heads/trunk 55e5e82da -> 660a144da


Add documentation.  Add support for passing dict into cloud_environments to
supply explicit endpoints.


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

Branch: refs/heads/trunk
Commit: 6aa7bb47aa4fd883595afc988d70042d46b557cd
Parents: 59153c3
Author: Peter Amstutz <peter.amstutz@curoverse.com>
Authored: Fri Jan 6 10:34:06 2017 -0500
Committer: Peter Amstutz <peter.amstutz@curoverse.com>
Committed: Thu Apr 20 14:46:21 2017 -0400

----------------------------------------------------------------------
 docs/compute/drivers/azure_arm.rst | 10 ++++++++++
 libcloud/common/azure_arm.py       | 14 +++++++++++---
 2 files changed, 21 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/6aa7bb47/docs/compute/drivers/azure_arm.rst
----------------------------------------------------------------------
diff --git a/docs/compute/drivers/azure_arm.rst b/docs/compute/drivers/azure_arm.rst
index 6506d57..ff974ab 100644
--- a/docs/compute/drivers/azure_arm.rst
+++ b/docs/compute/drivers/azure_arm.rst
@@ -42,6 +42,16 @@ password ("secret"), you can create an AzureNodeDriver:
 .. literalinclude:: /examples/compute/azure_arm/instantiate.py
    :language: python
 
+Alternate Cloud Environments
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+You can select an alternate cloud environment using the "cloud_environment"
+parameter to AzureNodeDriver constructor.  Available alternate cloud
+environments are 'AzureChinaCloud', 'AzureUSGovernment' and 'AzureGermanCloud'.
+You can also supply explicit endpoints by providing a dict with the keys
+'resourceManagerEndpointUrl', 'activeDirectoryEndpointUrl' and
+'activeDirectoryResourceId'.
+
 API Docs
 --------
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/6aa7bb47/libcloud/common/azure_arm.py
----------------------------------------------------------------------
diff --git a/libcloud/common/azure_arm.py b/libcloud/common/azure_arm.py
index 48031a5..cbd42f8 100644
--- a/libcloud/common/azure_arm.py
+++ b/libcloud/common/azure_arm.py
@@ -147,9 +147,17 @@ class AzureResourceManagementConnection(ConnectionUserAndKey):
         super(AzureResourceManagementConnection, self) \
             .__init__(key, secret, **kwargs)
         cloud_environment = kwargs.get("cloud_environment", "default")
-        self.host = urlparse(publicEnvironments[cloud_environment]['resourceManagerEndpointUrl']).hostname
-        self.login_host = urlparse(publicEnvironments[cloud_environment]['activeDirectoryEndpointUrl']).hostname
-        self.login_resource = publicEnvironments[cloud_environment]['activeDirectoryResourceId']
+        if isinstance(cloud_environment, basestring):
+            cloud_environment = publicEnvironments[cloud_environment]
+        if not isinstance(cloud_environment, dict):
+            raise Exception("cloud_environment must be one of '%s' or a dict "
+                            "containing keys 'resourceManagerEndpointUrl', "
+                            "'activeDirectoryEndpointUrl', "
+                            "'activeDirectoryResourceId'" % (
+                                "', '".join(publicEnvironments.keys())))
+        self.host = urlparse(cloud_environment['resourceManagerEndpointUrl']).hostname
+        self.login_host = urlparse(cloud_environment['activeDirectoryEndpointUrl']).hostname
+        self.login_resource = cloud_environment['activeDirectoryResourceId']
         self.tenant_id = tenant_id
         self.subscription_id = subscription_id
 


Mime
View raw message