Allow to work with latest Azure Python SDK (#15467)

* Allow to work with latest Azure Python SDK

* Fixed so that errors are sent to stderr
pull/15485/head
Chris Houseknecht 9 years ago committed by Brian Coca
parent 76f73dc81f
commit 2b7f4395d6

@ -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"""

Loading…
Cancel
Save