Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to work with latest Azure Python SDK #15467

Merged
merged 2 commits into from
Apr 22, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 5 additions & 15 deletions contrib/inventory/windows_azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,9 @@
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
Expand Down Expand Up @@ -194,11 +190,8 @@ def add_cloud_services(self):
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
Expand All @@ -207,11 +200,8 @@ def add_deployments(self, cloud_service):
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"""
Expand Down