You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by an...@apache.org on 2017/04/21 22:12:38 UTC

[1/9] libcloud git commit: Add documentation. Add support for passing dict into cloud_environments to supply explicit endpoints.

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 <pe...@curoverse.com>
Authored: Fri Jan 6 10:34:06 2017 -0500
Committer: Peter Amstutz <pe...@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
 


[7/9] libcloud git commit: Use compatability shim for urlparse. Don't use dict comprehension. Fix linting.

Posted by an...@apache.org.
Use compatability shim for urlparse.  Don't use dict comprehension.  Fix
linting.


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

Branch: refs/heads/trunk
Commit: 16a2611a62af61aa1690d559a02d4a8c6af4bb62
Parents: 018e09f
Author: Peter Amstutz <pe...@curoverse.com>
Authored: Thu Apr 20 14:47:48 2017 -0400
Committer: Peter Amstutz <pe...@curoverse.com>
Committed: Thu Apr 20 15:29:24 2017 -0400

----------------------------------------------------------------------
 libcloud/common/azure_arm.py          | 171 ++++++++++++++++-------------
 libcloud/compute/drivers/azure_arm.py |   8 +-
 2 files changed, 99 insertions(+), 80 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/16a2611a/libcloud/common/azure_arm.py
----------------------------------------------------------------------
diff --git a/libcloud/common/azure_arm.py b/libcloud/common/azure_arm.py
index 1dcf817..064e07e 100644
--- a/libcloud/common/azure_arm.py
+++ b/libcloud/common/azure_arm.py
@@ -19,7 +19,7 @@ except ImportError:
     import json
 
 import time
-from urlparse import urlparse
+from libcloud.utils.py3 import urlparse
 
 from libcloud.common.base import (ConnectionUserAndKey,
                                   JsonResponse,
@@ -56,80 +56,95 @@ class AzureAuthJsonResponse(JsonResponse):
         else:
             return str(b)
 
-# Based on https://github.com/Azure/azure-xplat-cli/blob/master/lib/util/profile/environment.js
-publicEnvironments = {v['name']: v for v in [
-  {
-    'name': 'default',
-    'portalUrl': 'http://go.microsoft.com/fwlink/?LinkId=254433',
-    'publishingProfileUrl': 'http://go.microsoft.com/fwlink/?LinkId=254432',
-    'managementEndpointUrl': 'https://management.core.windows.net',
-    'resourceManagerEndpointUrl': 'https://management.azure.com/',
-    'sqlManagementEndpointUrl': 'https://management.core.windows.net:8443/',
-    'sqlServerHostnameSuffix': '.database.windows.net',
-    'galleryEndpointUrl': 'https://gallery.azure.com/',
-    'activeDirectoryEndpointUrl': 'https://login.microsoftonline.com',
-    'activeDirectoryResourceId': 'https://management.core.windows.net/',
-    'activeDirectoryGraphResourceId': 'https://graph.windows.net/',
-    'activeDirectoryGraphApiVersion': '2013-04-05',
-    'storageEndpointSuffix': '.core.windows.net',
-    'keyVaultDnsSuffix': '.vault.azure.net',
-    'azureDataLakeStoreFileSystemEndpointSuffix': 'azuredatalakestore.net',
-    'azureDataLakeAnalyticsCatalogAndJobEndpointSuffix': 'azuredatalakeanalytics.net'
-  },
-  {
-    'name': 'AzureChinaCloud',
-    'portalUrl': 'http://go.microsoft.com/fwlink/?LinkId=301902',
-    'publishingProfileUrl': 'http://go.microsoft.com/fwlink/?LinkID=301774',
-    'managementEndpointUrl': 'https://management.core.chinacloudapi.cn',
-    'resourceManagerEndpointUrl': 'https://management.chinacloudapi.cn',
-    'sqlManagementEndpointUrl': 'https://management.core.chinacloudapi.cn:8443/',
-    'sqlServerHostnameSuffix': '.database.chinacloudapi.cn',
-    'galleryEndpointUrl': 'https://gallery.chinacloudapi.cn/',
-    'activeDirectoryEndpointUrl': 'https://login.chinacloudapi.cn',
-    'activeDirectoryResourceId': 'https://management.core.chinacloudapi.cn/',
-    'activeDirectoryGraphResourceId': 'https://graph.chinacloudapi.cn/',
-    'activeDirectoryGraphApiVersion': '2013-04-05',
-    'storageEndpointSuffix': '.core.chinacloudapi.cn',
-    'keyVaultDnsSuffix': '.vault.azure.cn',
-    'azureDataLakeStoreFileSystemEndpointSuffix': 'N/A',
-    'azureDataLakeAnalyticsCatalogAndJobEndpointSuffix': 'N/A'
-  },
-  {
-    'name': 'AzureUSGovernment',
-    'portalUrl': 'https://manage.windowsazure.us',
-    'publishingProfileUrl': 'https://manage.windowsazure.us/publishsettings/index',
-    'managementEndpointUrl': 'https://management.core.usgovcloudapi.net',
-    'resourceManagerEndpointUrl': 'https://management.usgovcloudapi.net',
-    'sqlManagementEndpointUrl': 'https://management.core.usgovcloudapi.net:8443/',
-    'sqlServerHostnameSuffix': '.database.usgovcloudapi.net',
-    'galleryEndpointUrl': 'https://gallery.usgovcloudapi.net/',
-    'activeDirectoryEndpointUrl': 'https://login-us.microsoftonline.com',
-    'activeDirectoryResourceId': 'https://management.core.usgovcloudapi.net/',
-    'activeDirectoryGraphResourceId': 'https://graph.windows.net/',
-    'activeDirectoryGraphApiVersion': '2013-04-05',
-    'storageEndpointSuffix': '.core.usgovcloudapi.net',
-    'keyVaultDnsSuffix': '.vault.usgovcloudapi.net',
-    'azureDataLakeStoreFileSystemEndpointSuffix': 'N/A',
-    'azureDataLakeAnalyticsCatalogAndJobEndpointSuffix': 'N/A'
-  },
-  {
-    'name': 'AzureGermanCloud',
-    'portalUrl': 'http://portal.microsoftazure.de/',
-    'publishingProfileUrl': 'https://manage.microsoftazure.de/publishsettings/index',
-    'managementEndpointUrl': 'https://management.core.cloudapi.de',
-    'resourceManagerEndpointUrl': 'https://management.microsoftazure.de',
-    'sqlManagementEndpointUrl': 'https://management.core.cloudapi.de:8443/',
-    'sqlServerHostnameSuffix': '.database.cloudapi.de',
-    'galleryEndpointUrl': 'https://gallery.cloudapi.de/',
-    'activeDirectoryEndpointUrl': 'https://login.microsoftonline.de',
-    'activeDirectoryResourceId': 'https://management.core.cloudapi.de/',
-    'activeDirectoryGraphResourceId': 'https://graph.cloudapi.de/',
-    'activeDirectoryGraphApiVersion': '2013-04-05',
-    'storageEndpointSuffix': '.core.cloudapi.de',
-    'keyVaultDnsSuffix': '.vault.microsoftazure.de',
-    'azureDataLakeStoreFileSystemEndpointSuffix': 'N/A',
-    'azureDataLakeAnalyticsCatalogAndJobEndpointSuffix': 'N/A'
-  }]}
+# Based on
+# https://github.com/Azure/azure-xplat-cli/blob/master/lib/util/profile/environment.js
+publicEnvironments = {
+    "default": {
+        'name': 'default',
+        'portalUrl': 'http://go.microsoft.com/fwlink/?LinkId=254433',
+        'publishingProfileUrl':
+            'http://go.microsoft.com/fwlink/?LinkId=254432',
+        'managementEndpointUrl': 'https://management.core.windows.net',
+        'resourceManagerEndpointUrl':
+            'https://management.azure.com/',
+        'sqlManagementEndpointUrl':
+            'https://management.core.windows.net:8443/',
+        'sqlServerHostnameSuffix': '.database.windows.net',
+        'galleryEndpointUrl': 'https://gallery.azure.com/',
+        'activeDirectoryEndpointUrl': 'https://login.microsoftonline.com',
+        'activeDirectoryResourceId': 'https://management.core.windows.net/',
+        'activeDirectoryGraphResourceId': 'https://graph.windows.net/',
+        'activeDirectoryGraphApiVersion': '2013-04-05',
+        'storageEndpointSuffix': '.core.windows.net',
+        'keyVaultDnsSuffix': '.vault.azure.net',
+        'azureDataLakeStoreFileSystemEndpointSuffix': 'azuredatalakestore.net',
+        'azureDataLakeAnalyticsCatalogAndJobEndpointSuffix':
+            'azuredatalakeanalytics.net'
+    },
+    "AzureChinaCloud": {
+        'name': 'AzureChinaCloud',
+        'portalUrl': 'http://go.microsoft.com/fwlink/?LinkId=301902',
+        'publishingProfileUrl':
+            'http://go.microsoft.com/fwlink/?LinkID=301774',
+        'managementEndpointUrl': 'https://management.core.chinacloudapi.cn',
+        'resourceManagerEndpointUrl': 'https://management.chinacloudapi.cn',
+        'sqlManagementEndpointUrl':
+            'https://management.core.chinacloudapi.cn:8443/',
+        'sqlServerHostnameSuffix': '.database.chinacloudapi.cn',
+        'galleryEndpointUrl': 'https://gallery.chinacloudapi.cn/',
+        'activeDirectoryEndpointUrl': 'https://login.chinacloudapi.cn',
+        'activeDirectoryResourceId':
+            'https://management.core.chinacloudapi.cn/',
+        'activeDirectoryGraphResourceId': 'https://graph.chinacloudapi.cn/',
+        'activeDirectoryGraphApiVersion': '2013-04-05',
+        'storageEndpointSuffix': '.core.chinacloudapi.cn',
+        'keyVaultDnsSuffix': '.vault.azure.cn',
+        'azureDataLakeStoreFileSystemEndpointSuffix': 'N/A',
+        'azureDataLakeAnalyticsCatalogAndJobEndpointSuffix': 'N/A'
+    },
+    "AzureUSGovernment": {
+        'name': 'AzureUSGovernment',
+        'portalUrl': 'https://manage.windowsazure.us',
+        'publishingProfileUrl':
+            'https://manage.windowsazure.us/publishsettings/index',
+        'managementEndpointUrl': 'https://management.core.usgovcloudapi.net',
+        'resourceManagerEndpointUrl': 'https://management.usgovcloudapi.net',
+        'sqlManagementEndpointUrl':
+            'https://management.core.usgovcloudapi.net:8443/',
+        'sqlServerHostnameSuffix': '.database.usgovcloudapi.net',
+        'galleryEndpointUrl': 'https://gallery.usgovcloudapi.net/',
+        'activeDirectoryEndpointUrl': 'https://login-us.microsoftonline.com',
+        'activeDirectoryResourceId':
+            'https://management.core.usgovcloudapi.net/',
+        'activeDirectoryGraphResourceId': 'https://graph.windows.net/',
+        'activeDirectoryGraphApiVersion': '2013-04-05',
+        'storageEndpointSuffix': '.core.usgovcloudapi.net',
+        'keyVaultDnsSuffix': '.vault.usgovcloudapi.net',
+        'azureDataLakeStoreFileSystemEndpointSuffix': 'N/A',
+        'azureDataLakeAnalyticsCatalogAndJobEndpointSuffix': 'N/A'
+    },
+    "AzureGermanCloud": {
+        'name': 'AzureGermanCloud',
+        'portalUrl': 'http://portal.microsoftazure.de/',
+        'publishingProfileUrl':
+        'https://manage.microsoftazure.de/publishsettings/index',
+        'managementEndpointUrl': 'https://management.core.cloudapi.de',
+        'resourceManagerEndpointUrl': 'https://management.microsoftazure.de',
+        'sqlManagementEndpointUrl':
+            'https://management.core.cloudapi.de:8443/',
+        'sqlServerHostnameSuffix': '.database.cloudapi.de',
+        'galleryEndpointUrl': 'https://gallery.cloudapi.de/',
+        'activeDirectoryEndpointUrl': 'https://login.microsoftonline.de',
+        'activeDirectoryResourceId': 'https://management.core.cloudapi.de/',
+        'activeDirectoryGraphResourceId': 'https://graph.cloudapi.de/',
+        'activeDirectoryGraphApiVersion': '2013-04-05',
+        'storageEndpointSuffix': '.core.cloudapi.de',
+        'keyVaultDnsSuffix': '.vault.microsoftazure.de',
+        'azureDataLakeStoreFileSystemEndpointSuffix': 'N/A',
+        'azureDataLakeAnalyticsCatalogAndJobEndpointSuffix': 'N/A'
+    }
+}
+
 
 class AzureResourceManagementConnection(ConnectionUserAndKey):
     """
@@ -157,8 +172,10 @@ class AzureResourceManagementConnection(ConnectionUserAndKey):
                             "'activeDirectoryResourceId', "
                             "'storageEndpointSuffix'" % (
                                 "', '".join(publicEnvironments.keys())))
-        self.host = urlparse(cloud_environment['resourceManagerEndpointUrl']).hostname
-        self.login_host = urlparse(cloud_environment['activeDirectoryEndpointUrl']).hostname
+        self.host = urlparse.urlparse(
+            cloud_environment['resourceManagerEndpointUrl']).hostname
+        self.login_host = urlparse.urlparse(
+            cloud_environment['activeDirectoryEndpointUrl']).hostname
         self.login_resource = cloud_environment['activeDirectoryResourceId']
         self.storage_suffix = cloud_environment['storageEndpointSuffix']
         self.tenant_id = tenant_id

http://git-wip-us.apache.org/repos/asf/libcloud/blob/16a2611a/libcloud/compute/drivers/azure_arm.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/azure_arm.py b/libcloud/compute/drivers/azure_arm.py
index 2048daf..3f2a3e2 100644
--- a/libcloud/compute/drivers/azure_arm.py
+++ b/libcloud/compute/drivers/azure_arm.py
@@ -1339,9 +1339,11 @@ class AzureNodeDriver(NodeDriver):
             (storageAccount, blobContainer, blob) = _split_blob_uri(uri)
             keys = self.ex_get_storage_account_keys(resource_group,
                                                     storageAccount)
-            blobdriver = AzureBlobsStorageDriver(storageAccount,
-                                                 keys["key1"],
-                                                 host="%s.blob%s" % (storageAccount, self.connection.storage_suffix))
+            blobdriver = AzureBlobsStorageDriver(
+                storageAccount,
+                keys["key1"],
+                host="%s.blob%s" % (storageAccount,
+                                    self.connection.storage_suffix))
             blobdriver.delete_object(blobdriver.get_object(blobContainer,
                                                            blob))
             return True


[8/9] libcloud git commit: Merge branch 'github-969' into trunk Closes #969 Signed-off-by: Anthony Shaw

Posted by an...@apache.org.
Merge branch 'github-969' into trunk
Closes #969
Signed-off-by: Anthony Shaw <an...@apache.org>


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

Branch: refs/heads/trunk
Commit: a5f4c98b2f9d991ad4e81bae310793bc3b8bb261
Parents: 55e5e82 16a2611
Author: Anthony Shaw <an...@apache.org>
Authored: Sat Apr 22 08:11:11 2017 +1000
Committer: Anthony Shaw <an...@apache.org>
Committed: Sat Apr 22 08:11:11 2017 +1000

----------------------------------------------------------------------
 docs/compute/drivers/azure_arm.rst    |  10 +++
 libcloud/common/azure_arm.py          | 112 +++++++++++++++++++++++++++--
 libcloud/compute/drivers/azure_arm.py |  19 +++--
 3 files changed, 131 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/a5f4c98b/libcloud/compute/drivers/azure_arm.py
----------------------------------------------------------------------


[6/9] libcloud git commit: Fix publicEnvironments to be a dict as intended.

Posted by an...@apache.org.
Fix publicEnvironments to be a dict as intended.


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

Branch: refs/heads/trunk
Commit: a5654cb4d0f2b1d4c727fe22e0e791b6f10b71c4
Parents: e1cc5c7
Author: Peter Amstutz <pe...@curoverse.com>
Authored: Fri Jan 13 16:08:22 2017 -0500
Committer: Peter Amstutz <pe...@curoverse.com>
Committed: Thu Apr 20 14:46:22 2017 -0400

----------------------------------------------------------------------
 libcloud/common/azure_arm.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/a5654cb4/libcloud/common/azure_arm.py
----------------------------------------------------------------------
diff --git a/libcloud/common/azure_arm.py b/libcloud/common/azure_arm.py
index d4984a5..a73a905 100644
--- a/libcloud/common/azure_arm.py
+++ b/libcloud/common/azure_arm.py
@@ -57,7 +57,7 @@ class AzureAuthJsonResponse(JsonResponse):
             return str(b)
 
 # Based on https://github.com/Azure/azure-xplat-cli/blob/master/lib/util/profile/environment.js
-publicEnvironments = [
+publicEnvironments = {v['name']: v for v in [
   {
     'name': 'default',
     'portalUrl': 'http://go.microsoft.com/fwlink/?LinkId=254433',
@@ -129,7 +129,7 @@ publicEnvironments = [
     'keyVaultDnsSuffix': '.vault.microsoftazure.de',
     'azureDataLakeStoreFileSystemEndpointSuffix': 'N/A',
     'azureDataLakeAnalyticsCatalogAndJobEndpointSuffix': 'N/A'
-  }]
+  }]}
 
 class AzureResourceManagementConnection(ConnectionUserAndKey):
     """


[5/9] libcloud git commit: Propagate cloud_environment to Connection class.

Posted by an...@apache.org.
Propagate cloud_environment to Connection class.


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

Branch: refs/heads/trunk
Commit: 018e09f62d02ba930639e230f08c562229f63eee
Parents: a5654cb
Author: Peter Amstutz <pe...@curoverse.com>
Authored: Fri Jan 13 16:58:29 2017 -0500
Committer: Peter Amstutz <pe...@curoverse.com>
Committed: Thu Apr 20 14:46:22 2017 -0400

----------------------------------------------------------------------
 libcloud/common/azure_arm.py          | 5 +++--
 libcloud/compute/drivers/azure_arm.py | 2 ++
 2 files changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/018e09f6/libcloud/common/azure_arm.py
----------------------------------------------------------------------
diff --git a/libcloud/common/azure_arm.py b/libcloud/common/azure_arm.py
index a73a905..1dcf817 100644
--- a/libcloud/common/azure_arm.py
+++ b/libcloud/common/azure_arm.py
@@ -143,10 +143,11 @@ class AzureResourceManagementConnection(ConnectionUserAndKey):
     rawResponseCls = RawResponse
 
     def __init__(self, key, secret, secure=True, tenant_id=None,
-                 subscription_id=None, **kwargs):
+                 subscription_id=None, cloud_environment=None, **kwargs):
         super(AzureResourceManagementConnection, self) \
             .__init__(key, secret, **kwargs)
-        cloud_environment = kwargs.get("cloud_environment", "default")
+        if not cloud_environment:
+            cloud_environment = "default"
         if isinstance(cloud_environment, basestring):
             cloud_environment = publicEnvironments[cloud_environment]
         if not isinstance(cloud_environment, dict):

http://git-wip-us.apache.org/repos/asf/libcloud/blob/018e09f6/libcloud/compute/drivers/azure_arm.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/azure_arm.py b/libcloud/compute/drivers/azure_arm.py
index 6fb5684..2048daf 100644
--- a/libcloud/compute/drivers/azure_arm.py
+++ b/libcloud/compute/drivers/azure_arm.py
@@ -191,6 +191,7 @@ class AzureNodeDriver(NodeDriver):
                  api_version=None, region=None, **kwargs):
         self.tenant_id = tenant_id
         self.subscription_id = subscription_id
+        self.cloud_environment = kwargs.get("cloud_environment")
         super(AzureNodeDriver, self).__init__(key=key, secret=secret,
                                               secure=secure,
                                               host=host, port=port,
@@ -1351,6 +1352,7 @@ class AzureNodeDriver(NodeDriver):
         kwargs = super(AzureNodeDriver, self)._ex_connection_class_kwargs()
         kwargs['tenant_id'] = self.tenant_id
         kwargs['subscription_id'] = self.subscription_id
+        kwargs["cloud_environment"] = self.cloud_environment
         return kwargs
 
     def _to_node(self, data, fetch_nic=True):


[9/9] libcloud git commit: changes for #969

Posted by an...@apache.org.
changes for #969


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

Branch: refs/heads/trunk
Commit: 660a144da2a063e1a52f8e18a4157c6217e09ccc
Parents: a5f4c98
Author: Anthony Shaw <an...@apache.org>
Authored: Sat Apr 22 08:12:30 2017 +1000
Committer: Anthony Shaw <an...@apache.org>
Committed: Sat Apr 22 08:12:30 2017 +1000

----------------------------------------------------------------------
 CHANGES.rst | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/660a144d/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index d7d51f2..03d8990 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -25,6 +25,10 @@ Common
 Compute
 ~~~~~~~
 
+- [ARM] Add support for Azure Cloud Environments as well as Locations
+  [GITHUB-969]
+  (Peter Amstutz)
+
 - [EC2] Add support for ModifyVolume and DescribeVolumesModifications
   [GITHUB-1036]
   (Hennadii Stas)


[2/9] libcloud git commit: Add support for selecting alternate cloud_environments AzureChinaCloud, AzureUSGovernment, and AzureGermanCloud.

Posted by an...@apache.org.
Add support for selecting alternate cloud_environments AzureChinaCloud,
AzureUSGovernment, and AzureGermanCloud.


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

Branch: refs/heads/trunk
Commit: 59153c375918f925400714a82d29d69725308060
Parents: 1a07215
Author: Peter Amstutz <pe...@curoverse.com>
Authored: Thu Jan 5 16:42:33 2017 -0500
Committer: Peter Amstutz <pe...@curoverse.com>
Committed: Thu Apr 20 14:46:21 2017 -0400

----------------------------------------------------------------------
 libcloud/common/azure_arm.py | 82 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 79 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/59153c37/libcloud/common/azure_arm.py
----------------------------------------------------------------------
diff --git a/libcloud/common/azure_arm.py b/libcloud/common/azure_arm.py
index d8c07c1..48031a5 100644
--- a/libcloud/common/azure_arm.py
+++ b/libcloud/common/azure_arm.py
@@ -19,6 +19,7 @@ except ImportError:
     import json
 
 import time
+from urlparse import urlparse
 
 from libcloud.common.base import (ConnectionUserAndKey,
                                   JsonResponse,
@@ -55,6 +56,80 @@ class AzureAuthJsonResponse(JsonResponse):
         else:
             return str(b)
 
+# Based on https://github.com/Azure/azure-xplat-cli/blob/master/lib/util/profile/environment.js
+publicEnvironments = [
+  {
+    'name': 'default',
+    'portalUrl': 'http://go.microsoft.com/fwlink/?LinkId=254433',
+    'publishingProfileUrl': 'http://go.microsoft.com/fwlink/?LinkId=254432',
+    'managementEndpointUrl': 'https://management.core.windows.net',
+    'resourceManagerEndpointUrl': 'https://management.azure.com/',
+    'sqlManagementEndpointUrl': 'https://management.core.windows.net:8443/',
+    'sqlServerHostnameSuffix': '.database.windows.net',
+    'galleryEndpointUrl': 'https://gallery.azure.com/',
+    'activeDirectoryEndpointUrl': 'https://login.microsoftonline.com',
+    'activeDirectoryResourceId': 'https://management.core.windows.net/',
+    'activeDirectoryGraphResourceId': 'https://graph.windows.net/',
+    'activeDirectoryGraphApiVersion': '2013-04-05',
+    'storageEndpointSuffix': '.core.windows.net',
+    'keyVaultDnsSuffix': '.vault.azure.net',
+    'azureDataLakeStoreFileSystemEndpointSuffix': 'azuredatalakestore.net',
+    'azureDataLakeAnalyticsCatalogAndJobEndpointSuffix': 'azuredatalakeanalytics.net'
+  },
+  {
+    'name': 'AzureChinaCloud',
+    'portalUrl': 'http://go.microsoft.com/fwlink/?LinkId=301902',
+    'publishingProfileUrl': 'http://go.microsoft.com/fwlink/?LinkID=301774',
+    'managementEndpointUrl': 'https://management.core.chinacloudapi.cn',
+    'resourceManagerEndpointUrl': 'https://management.chinacloudapi.cn',
+    'sqlManagementEndpointUrl': 'https://management.core.chinacloudapi.cn:8443/',
+    'sqlServerHostnameSuffix': '.database.chinacloudapi.cn',
+    'galleryEndpointUrl': 'https://gallery.chinacloudapi.cn/',
+    'activeDirectoryEndpointUrl': 'https://login.chinacloudapi.cn',
+    'activeDirectoryResourceId': 'https://management.core.chinacloudapi.cn/',
+    'activeDirectoryGraphResourceId': 'https://graph.chinacloudapi.cn/',
+    'activeDirectoryGraphApiVersion': '2013-04-05',
+    'storageEndpointSuffix': '.core.chinacloudapi.cn',
+    'keyVaultDnsSuffix': '.vault.azure.cn',
+    'azureDataLakeStoreFileSystemEndpointSuffix': 'N/A',
+    'azureDataLakeAnalyticsCatalogAndJobEndpointSuffix': 'N/A'
+  },
+  {
+    'name': 'AzureUSGovernment',
+    'portalUrl': 'https://manage.windowsazure.us',
+    'publishingProfileUrl': 'https://manage.windowsazure.us/publishsettings/index',
+    'managementEndpointUrl': 'https://management.core.usgovcloudapi.net',
+    'resourceManagerEndpointUrl': 'https://management.usgovcloudapi.net',
+    'sqlManagementEndpointUrl': 'https://management.core.usgovcloudapi.net:8443/',
+    'sqlServerHostnameSuffix': '.database.usgovcloudapi.net',
+    'galleryEndpointUrl': 'https://gallery.usgovcloudapi.net/',
+    'activeDirectoryEndpointUrl': 'https://login-us.microsoftonline.com',
+    'activeDirectoryResourceId': 'https://management.core.usgovcloudapi.net/',
+    'activeDirectoryGraphResourceId': 'https://graph.windows.net/',
+    'activeDirectoryGraphApiVersion': '2013-04-05',
+    'storageEndpointSuffix': '.core.usgovcloudapi.net',
+    'keyVaultDnsSuffix': '.vault.usgovcloudapi.net',
+    'azureDataLakeStoreFileSystemEndpointSuffix': 'N/A',
+    'azureDataLakeAnalyticsCatalogAndJobEndpointSuffix': 'N/A'
+  },
+  {
+    'name': 'AzureGermanCloud',
+    'portalUrl': 'http://portal.microsoftazure.de/',
+    'publishingProfileUrl': 'https://manage.microsoftazure.de/publishsettings/index',
+    'managementEndpointUrl': 'https://management.core.cloudapi.de',
+    'resourceManagerEndpointUrl': 'https://management.microsoftazure.de',
+    'sqlManagementEndpointUrl': 'https://management.core.cloudapi.de:8443/',
+    'sqlServerHostnameSuffix': '.database.cloudapi.de',
+    'galleryEndpointUrl': 'https://gallery.cloudapi.de/',
+    'activeDirectoryEndpointUrl': 'https://login.microsoftonline.de',
+    'activeDirectoryResourceId': 'https://management.core.cloudapi.de/',
+    'activeDirectoryGraphResourceId': 'https://graph.cloudapi.de/',
+    'activeDirectoryGraphApiVersion': '2013-04-05',
+    'storageEndpointSuffix': '.core.cloudapi.de',
+    'keyVaultDnsSuffix': '.vault.microsoftazure.de',
+    'azureDataLakeStoreFileSystemEndpointSuffix': 'N/A',
+    'azureDataLakeAnalyticsCatalogAndJobEndpointSuffix': 'N/A'
+  }]
 
 class AzureResourceManagementConnection(ConnectionUserAndKey):
     """
@@ -66,14 +141,15 @@ class AzureResourceManagementConnection(ConnectionUserAndKey):
     name = 'Azure AD Auth'
     responseCls = AzureJsonResponse
     rawResponseCls = RawResponse
-    host = 'management.azure.com'
-    login_host = 'login.windows.net'
-    login_resource = 'https://management.core.windows.net/'
 
     def __init__(self, key, secret, secure=True, tenant_id=None,
                  subscription_id=None, **kwargs):
         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']
         self.tenant_id = tenant_id
         self.subscription_id = subscription_id
 


[4/9] libcloud git commit: Compute driver should correctly access blob storage in alternate cloud environments.

Posted by an...@apache.org.
Compute driver should correctly access blob storage in alternate cloud
environments.


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

Branch: refs/heads/trunk
Commit: 37e709c98d8db059673d437f9a5e49e003afc427
Parents: 6aa7bb4
Author: Peter Amstutz <pe...@curoverse.com>
Authored: Fri Jan 6 11:03:00 2017 -0500
Committer: Peter Amstutz <pe...@curoverse.com>
Committed: Thu Apr 20 14:46:22 2017 -0400

----------------------------------------------------------------------
 docs/compute/drivers/azure_arm.rst    |  4 ++--
 libcloud/common/azure_arm.py          |  4 +++-
 libcloud/compute/drivers/azure_arm.py | 13 ++++++++-----
 3 files changed, 13 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/37e709c9/docs/compute/drivers/azure_arm.rst
----------------------------------------------------------------------
diff --git a/docs/compute/drivers/azure_arm.rst b/docs/compute/drivers/azure_arm.rst
index ff974ab..74ecf72 100644
--- a/docs/compute/drivers/azure_arm.rst
+++ b/docs/compute/drivers/azure_arm.rst
@@ -49,8 +49,8 @@ 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'.
+'resourceManagerEndpointUrl', 'activeDirectoryEndpointUrl',
+'activeDirectoryResourceId' and 'storageEndpointSuffix'.
 
 API Docs
 --------

http://git-wip-us.apache.org/repos/asf/libcloud/blob/37e709c9/libcloud/common/azure_arm.py
----------------------------------------------------------------------
diff --git a/libcloud/common/azure_arm.py b/libcloud/common/azure_arm.py
index cbd42f8..d4984a5 100644
--- a/libcloud/common/azure_arm.py
+++ b/libcloud/common/azure_arm.py
@@ -153,11 +153,13 @@ class AzureResourceManagementConnection(ConnectionUserAndKey):
             raise Exception("cloud_environment must be one of '%s' or a dict "
                             "containing keys 'resourceManagerEndpointUrl', "
                             "'activeDirectoryEndpointUrl', "
-                            "'activeDirectoryResourceId'" % (
+                            "'activeDirectoryResourceId', "
+                            "'storageEndpointSuffix'" % (
                                 "', '".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.storage_suffix = cloud_environment['storageEndpointSuffix']
         self.tenant_id = tenant_id
         self.subscription_id = subscription_id
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/37e709c9/libcloud/compute/drivers/azure_arm.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/azure_arm.py b/libcloud/compute/drivers/azure_arm.py
index c7bed5e..d261d20 100644
--- a/libcloud/compute/drivers/azure_arm.py
+++ b/libcloud/compute/drivers/azure_arm.py
@@ -61,9 +61,10 @@ class AzureVhdImage(NodeImage):
     """Represents a VHD node image that an Azure VM can boot from."""
 
     def __init__(self, storage_account, blob_container, name, driver):
-        urn = "https://%s.blob.core.windows.net/%s/%s" % (storage_account,
-                                                          blob_container,
-                                                          name)
+        urn = "https://%s.blob%s/%s/%s" % (storage_account,
+                                           driver.connection.storage_suffix,
+                                           blob_container,
+                                           name)
         super(AzureVhdImage, self).__init__(urn, name, driver)
 
     def __repr__(self):
@@ -511,9 +512,10 @@ class AzureNodeDriver(NodeDriver):
         n = 0
         while True:
             try:
-                instance_vhd = "https://%s.blob.core.windows.net" \
+                instance_vhd = "https://%s.blob%s" \
                                "/%s/%s-os_%i.vhd" \
                                % (ex_storage_account,
+                                  self.connection.storage_suffix,
                                   ex_blob_container,
                                   name,
                                   n)
@@ -1337,7 +1339,8 @@ class AzureNodeDriver(NodeDriver):
             keys = self.ex_get_storage_account_keys(resource_group,
                                                     storageAccount)
             blobdriver = AzureBlobsStorageDriver(storageAccount,
-                                                 keys["key1"])
+                                                 keys["key1"],
+                                                 host="blob%s" % (self.connection.storage_suffix))
             blobdriver.delete_object(blobdriver.get_object(blobContainer,
                                                            blob))
             return True


[3/9] libcloud git commit: Explicit host provided to AzureBlobsStorageDriver needs to include storage account.

Posted by an...@apache.org.
Explicit host provided to AzureBlobsStorageDriver needs to include storage account.


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

Branch: refs/heads/trunk
Commit: e1cc5c7ad796645d2e5688acb1fd28059140f841
Parents: 37e709c
Author: Peter Amstutz <pe...@curoverse.com>
Authored: Fri Jan 6 11:08:25 2017 -0500
Committer: Peter Amstutz <pe...@curoverse.com>
Committed: Thu Apr 20 14:46:22 2017 -0400

----------------------------------------------------------------------
 libcloud/compute/drivers/azure_arm.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/e1cc5c7a/libcloud/compute/drivers/azure_arm.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/azure_arm.py b/libcloud/compute/drivers/azure_arm.py
index d261d20..6fb5684 100644
--- a/libcloud/compute/drivers/azure_arm.py
+++ b/libcloud/compute/drivers/azure_arm.py
@@ -1340,7 +1340,7 @@ class AzureNodeDriver(NodeDriver):
                                                     storageAccount)
             blobdriver = AzureBlobsStorageDriver(storageAccount,
                                                  keys["key1"],
-                                                 host="blob%s" % (self.connection.storage_suffix))
+                                                 host="%s.blob%s" % (storageAccount, self.connection.storage_suffix))
             blobdriver.delete_object(blobdriver.get_object(blobContainer,
                                                            blob))
             return True