Port azure_rm_common.py to py3 syntax (#15880)
Since the rest of the file already use a non 2.4 syntax
(such as format), I didn't bother using the 2.4 syntax for
exceptions.
(cherry picked from commit eb52dc9af0
)
This commit is contained in:
parent
6b84306f70
commit
ff601f4161
1 changed files with 9 additions and 9 deletions
|
@ -88,7 +88,7 @@ try:
|
|||
from azure.mgmt.storage.storage_management_client import StorageManagementClient
|
||||
from azure.mgmt.compute.compute_management_client import ComputeManagementClient
|
||||
from azure.storage.cloudstorageaccount import CloudStorageAccount
|
||||
except ImportError, exc:
|
||||
except ImportError as exc:
|
||||
HAS_AZURE_EXC = exc
|
||||
HAS_AZURE = False
|
||||
|
||||
|
@ -294,7 +294,7 @@ class AzureRMModuleBase(object):
|
|||
return self.rm_client.resource_groups.get(resource_group)
|
||||
except CloudError:
|
||||
self.fail("Parameter error: resource group {0} not found".format(resource_group))
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
self.fail("Error retrieving resource group {0} - {1}".format(resource_group, str(exc)))
|
||||
|
||||
def _get_profile(self, profile="default"):
|
||||
|
@ -302,7 +302,7 @@ class AzureRMModuleBase(object):
|
|||
try:
|
||||
config = ConfigParser.ConfigParser()
|
||||
config.read(path)
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
self.fail("Failed to access {0}. Check that the file exists and you have read "
|
||||
"access. {1}".format(path, str(exc)))
|
||||
credentials = dict()
|
||||
|
@ -398,7 +398,7 @@ class AzureRMModuleBase(object):
|
|||
self.log("Waiting for {0} sec".format(delay))
|
||||
poller.wait(timeout=delay)
|
||||
return poller.result()
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
self.log(str(exc))
|
||||
raise
|
||||
|
||||
|
@ -443,13 +443,13 @@ class AzureRMModuleBase(object):
|
|||
# Get keys from the storage account
|
||||
self.log('Getting keys')
|
||||
account_keys = self.storage_client.storage_accounts.list_keys(resource_group_name, storage_account_name)
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
self.fail("Error getting keys for account {0} - {1}".format(storage_account_name, str(exc)))
|
||||
|
||||
try:
|
||||
self.log('Create blob service')
|
||||
return CloudStorageAccount(storage_account_name, account_keys.keys[0].value).create_block_blob_service()
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
self.fail("Error creating blob service client for storage account {0} - {1}".format(storage_account_name,
|
||||
str(exc)))
|
||||
|
||||
|
@ -486,7 +486,7 @@ class AzureRMModuleBase(object):
|
|||
self.log('Creating default public IP {0}'.format(public_ip_name))
|
||||
try:
|
||||
poller = self.network_client.public_ip_addresses.create_or_update(resource_group, public_ip_name, params)
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
self.fail("Error creating {0} - {1}".format(public_ip_name, str(exc)))
|
||||
|
||||
return self.get_poller_result(poller)
|
||||
|
@ -556,7 +556,7 @@ class AzureRMModuleBase(object):
|
|||
poller = self.network_client.network_security_groups.create_or_update(resource_group,
|
||||
security_group_name,
|
||||
parameters)
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
self.fail("Error creating default security rule {0} - {1}".format(security_group_name, str(exc)))
|
||||
|
||||
return self.get_poller_result(poller)
|
||||
|
@ -567,7 +567,7 @@ class AzureRMModuleBase(object):
|
|||
# time we attempt to use the requested client.
|
||||
resource_client = self.rm_client
|
||||
resource_client.providers.register(key)
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
self.fail("One-time registration of {0} failed - {1}".format(key, str(exc)))
|
||||
|
||||
@property
|
||||
|
|
Loading…
Reference in a new issue