diff --git a/contrib/inventory/windows_azure.py b/contrib/inventory/windows_azure.py index d566b0c4d3..d2999f1876 100755 --- a/contrib/inventory/windows_azure.py +++ b/contrib/inventory/windows_azure.py @@ -47,13 +47,9 @@ except ImportError: import simplejson as json try: - import azure - from azure import WindowsAzureError from azure.servicemanagement import ServiceManagementService except ImportError as e: - print("failed=True msg='`azure` library required for this script'") - sys.exit(1) - + sys.exit("ImportError: {0}".format(str(e))) # Imports for ansible import ConfigParser @@ -194,11 +190,8 @@ class AzureInventory(object): try: for cloud_service in self.sms.list_hosted_services(): self.add_deployments(cloud_service) - except WindowsAzureError as e: - print("Looks like Azure's API is down:") - print("") - print(e) - sys.exit(1) + except Exception as e: + sys.exit("Error: Failed to access cloud services - {0}".format(str(e))) def add_deployments(self, cloud_service): """Makes an Azure API call to get the list of virtual machines @@ -207,11 +200,8 @@ class AzureInventory(object): try: for deployment in self.sms.get_hosted_service_properties(cloud_service.service_name,embed_detail=True).deployments.deployments: self.add_deployment(cloud_service, deployment) - except WindowsAzureError as e: - print("Looks like Azure's API is down:") - print("") - print(e) - sys.exit(1) + except Exception as e: + sys.exit("Error: Failed to access deployments - {0}".format(str(e))) def add_deployment(self, cloud_service, deployment): """Adds a deployment to the inventory and index"""