From 02a3ad818e556cc08c8f163b798dcdc12d8945fc Mon Sep 17 00:00:00 2001 From: Steven Joseph Date: Thu, 10 Aug 2017 13:15:29 +1000 Subject: [PATCH 1/4] Update salt-cloud azurearm to work with latest sdk - allows compatibility with azure-cli --- salt/cloud/clouds/azurearm.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/salt/cloud/clouds/azurearm.py b/salt/cloud/clouds/azurearm.py index 68d1d91847..8d65b9c9c0 100644 --- a/salt/cloud/clouds/azurearm.py +++ b/salt/cloud/clouds/azurearm.py @@ -79,7 +79,6 @@ HAS_LIBS = False try: import salt.utils.msazure from salt.utils.msazure import object_to_dict - import azure.storage from azure.common.credentials import ( UserPassCredentials, ServicePrincipalCredentials, @@ -115,6 +114,7 @@ try: from azure.mgmt.storage import StorageManagementClient from azure.mgmt.web import WebSiteManagementClient from msrestazure.azure_exceptions import CloudError + from azure.multiapi.storage.v2016_05_31 import CloudStorageAccount HAS_LIBS = True except ImportError: pass @@ -1728,7 +1728,7 @@ def list_containers(call=None, kwargs=None): # pylint: disable=unused-argument if not storconn: storconn = get_conn(StorageManagementClient) - storageaccount = azure.storage.CloudStorageAccount( + storageaccount = CloudStorageAccount( config.get_cloud_config_value( 'storage_account', get_configured_provider(), __opts__, search_global=False @@ -1769,7 +1769,7 @@ def list_blobs(call=None, kwargs=None): # pylint: disable=unused-argument 'A container must be specified' ) - storageaccount = azure.storage.CloudStorageAccount( + storageaccount = CloudStorageAccount( config.get_cloud_config_value( 'storage_account', get_configured_provider(), __opts__, search_global=False @@ -1809,7 +1809,7 @@ def delete_blob(call=None, kwargs=None): # pylint: disable=unused-argument 'A blob must be specified' ) - storageaccount = azure.storage.CloudStorageAccount( + storageaccount = CloudStorageAccount( config.get_cloud_config_value( 'storage_account', get_configured_provider(), __opts__, search_global=False From 50f1691cd8147666d09a0c216eac473bb37508bf Mon Sep 17 00:00:00 2001 From: Steven Joseph Date: Thu, 10 Aug 2017 13:19:45 +1000 Subject: [PATCH 2/4] Update documentation for azure arm dependencies --- doc/topics/cloud/azurearm.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/doc/topics/cloud/azurearm.rst b/doc/topics/cloud/azurearm.rst index 278cdc314e..f77895475a 100644 --- a/doc/topics/cloud/azurearm.rst +++ b/doc/topics/cloud/azurearm.rst @@ -15,9 +15,7 @@ More information about Azure is located at `http://www.windowsazure.com/ Dependencies ============ -* `Microsoft Azure SDK for Python `_ >= 2.0rc6 -* `Microsoft Azure Storage SDK for Python `_ >= 0.32 -* The python-requests library, for Python < 2.7.9. +* Azure Cli ```pip install 'azure-cli>=2.0.12'``` * A Microsoft Azure account * `Salt `_ From 30bde1d7f3f2180e491b9b7980257bd6abeb3959 Mon Sep 17 00:00:00 2001 From: Steven Joseph Date: Wed, 23 Aug 2017 00:21:03 +1000 Subject: [PATCH 3/4] Updated as per PR comments, - add version checking - add doco --- doc/topics/releases/oxygen.rst | 5 +++++ salt/cloud/clouds/azurearm.py | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/doc/topics/releases/oxygen.rst b/doc/topics/releases/oxygen.rst index 4dda3bab84..0b75a9fcb8 100644 --- a/doc/topics/releases/oxygen.rst +++ b/doc/topics/releases/oxygen.rst @@ -113,6 +113,11 @@ Profitbricks Cloud Updated Dependency The minimum version of the `profitbrick` python package for the `profitbricks` cloud driver has changed from 3.0.0 to 3.1.0. +Azure Cloud Updated Dependency +------------------------------ + +The azure sdk used for the ``azurearm`` cloud driver now depends on ``azure-cli>=2.0.12`` + Module Deprecations ------------------- diff --git a/salt/cloud/clouds/azurearm.py b/salt/cloud/clouds/azurearm.py index 8d65b9c9c0..c3f5777a64 100644 --- a/salt/cloud/clouds/azurearm.py +++ b/salt/cloud/clouds/azurearm.py @@ -73,6 +73,7 @@ from salt.exceptions import ( SaltCloudExecutionTimeout, ) from salt.ext.six.moves import filter +from distutils.version import LooseVersion # Import 3rd-party libs HAS_LIBS = False @@ -115,7 +116,8 @@ try: from azure.mgmt.web import WebSiteManagementClient from msrestazure.azure_exceptions import CloudError from azure.multiapi.storage.v2016_05_31 import CloudStorageAccount - HAS_LIBS = True + from azure.cli import core + HAS_LIBS = LooseVersion(core.__version__) >= LooseVersion("2.0.12") except ImportError: pass # pylint: enable=wrong-import-position,wrong-import-order From fbfbe316874a3c45bc22db9bf6b22be79ad36755 Mon Sep 17 00:00:00 2001 From: Nicole Thomas Date: Wed, 30 Aug 2017 10:02:39 -0400 Subject: [PATCH 4/4] Lint: use salt.utils.versions instead of distutils.version for LooseVersion --- salt/cloud/clouds/azurearm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/cloud/clouds/azurearm.py b/salt/cloud/clouds/azurearm.py index c3f5777a64..0397aaed44 100644 --- a/salt/cloud/clouds/azurearm.py +++ b/salt/cloud/clouds/azurearm.py @@ -65,6 +65,7 @@ import salt.config as config import salt.utils import salt.utils.cloud import salt.utils.files +from salt.utils.versions import LooseVersion from salt.ext import six import salt.version from salt.exceptions import ( @@ -73,7 +74,6 @@ from salt.exceptions import ( SaltCloudExecutionTimeout, ) from salt.ext.six.moves import filter -from distutils.version import LooseVersion # Import 3rd-party libs HAS_LIBS = False