From c6531ad5564c39917c19dcff54c20fe739e94f03 Mon Sep 17 00:00:00 2001 From: Zhijun Zhao Date: Mon, 25 Dec 2017 15:58:26 +0800 Subject: [PATCH] pin api version of azure storage models --- lib/ansible/module_utils/azure_rm_common.py | 5 +++++ .../modules/cloud/azure/azure_rm_virtualmachine.py | 10 ++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/ansible/module_utils/azure_rm_common.py b/lib/ansible/module_utils/azure_rm_common.py index dcc9d312b71..d3a95a33345 100644 --- a/lib/ansible/module_utils/azure_rm_common.py +++ b/lib/ansible/module_utils/azure_rm_common.py @@ -753,6 +753,11 @@ class AzureRMModuleBase(object): api_version='2017-10-01') return self._storage_client + @property + def storage_accounts_models(self): + self.log('Getting storage models...') + return self.storage_client.storage_accounts.models + @property def network_client(self): self.log('Getting network client') diff --git a/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py b/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py index 9ac237ed5fe..df66d0c3685 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py @@ -606,8 +606,6 @@ try: DiskCreateOptionTypes, Plan, SubResource from azure.mgmt.network.models import PublicIPAddress, NetworkSecurityGroup, NetworkInterface, \ NetworkInterfaceIPConfiguration, Subnet - from azure.mgmt.storage.models import StorageAccountCreateParameters, Sku - from azure.mgmt.storage.models import Kind, SkuTier, SkuName except ImportError: # This is handled in azure_rm_common pass @@ -1530,10 +1528,10 @@ class AzureRMVirtualMachine(AzureRMModuleBase): self.log("Storage account {0} found.".format(storage_account_name)) self.check_provisioning_state(account) return account - sku = Sku(SkuName.standard_lrs) - Sku.tier = SkuTier.standard - kind = Kind.storage - parameters = StorageAccountCreateParameters(sku, kind, self.location) + sku = self.storage_accounts_models.Sku(self.storage_accounts_models.SkuName.standard_lrs) + sku.tier = self.storage_accounts_models.SkuTier.standard + kind = self.storage_accounts_models.Kind.storage + parameters = self.storage_accounts_models.StorageAccountCreateParameters(sku, kind, self.location) self.log("Creating storage account {0} in location {1}".format(storage_account_name, self.location)) self.results['actions'].append("Created storage account {0}".format(storage_account_name)) try: