From 48c194f2a9342294037c779a4f3ef43435302350 Mon Sep 17 00:00:00 2001 From: Chris Meyers Date: Thu, 16 Apr 2015 18:06:55 -0400 Subject: [PATCH] handle shutdown azure instances --- awx/plugins/inventory/windows_azure.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/awx/plugins/inventory/windows_azure.py b/awx/plugins/inventory/windows_azure.py index 8a53fadfa1..2edd3baf29 100755 --- a/awx/plugins/inventory/windows_azure.py +++ b/awx/plugins/inventory/windows_azure.py @@ -220,10 +220,15 @@ class AzureInventory(object): def add_deployment(self, cloud_service, deployment): """Adds a deployment to the inventory and index""" for role in deployment.role_instance_list.role_instances: - for ie in role.instance_endpoints.instance_endpoints: - if ie.name == 'SSH': - self.add_instance(role.instance_name, deployment, ie.public_port, cloud_service) - break + try: + # Only consider ready vm instances (not StoppedDeallocated, not RoleStateUnknown, not StoppedVM) + if role.instance_status == 'ReadyRole': + for ie in role.instance_endpoints.instance_endpoints: + if ie.name == 'SSH': + self.add_instance(role.instance_name, deployment, ie.public_port, cloud_service) + break + except AttributeError: + return def add_instance(self, hostname, deployment, ssh_port, cloud_service): """Adds an instance to the inventory and index"""