From 1173a8d6af50bb48e38bf5ad307a5754e0293cd0 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Thu, 12 Jun 2014 10:25:31 -0500 Subject: [PATCH] Catch error in azure related to a failed deployment when creating a vm --- library/cloud/azure | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/library/cloud/azure b/library/cloud/azure index ec9aa9ec901..3e193e215dc 100644 --- a/library/cloud/azure +++ b/library/cloud/azure @@ -301,8 +301,11 @@ def create_virtual_machine(module, azure): module.fail_json(msg="failed to create the new virtual machine, error was: %s" % str(e)) - deployment = azure.get_deployment_by_name(service_name=name, deployment_name=name) - return (changed, urlparse(deployment.url).hostname, deployment) + try: + deployment = azure.get_deployment_by_name(service_name=name, deployment_name=name) + return (changed, urlparse(deployment.url).hostname, deployment) + except WindowsAzureError as e: + module.fail_json(msg="failed to lookup the deployment information for %s, error was: %s" % (name, str(e))) def terminate_virtual_machine(module, azure): @@ -399,7 +402,7 @@ def main(): wait_timeout_redirects = int(module.params.get('wait_timeout_redirects')) if LooseVersion(windows_azure.__version__) <= "0.8.0": - #wrapper for handling redirects which the sdk <= 0.8.0 is not following + # wrapper for handling redirects which the sdk <= 0.8.0 is not following azure = Wrapper(ServiceManagementService(subscription_id, management_cert_path), wait_timeout_redirects) else: azure = ServiceManagementService(subscription_id, management_cert_path), wait_timeout_redirects