mirror of
https://github.com/ansible/awx.git
synced 2026-03-09 13:39:27 -02:30
add instance state
This commit is contained in:
@@ -118,7 +118,7 @@ class AzureInventory(object):
|
|||||||
the Windows Azure API provides.
|
the Windows Azure API provides.
|
||||||
"""
|
"""
|
||||||
if hostname not in self.host_metadata:
|
if hostname not in self.host_metadata:
|
||||||
return "No host found: %s" % hostname
|
return "No host found: %s" % json.dumps(self.host_metadata)
|
||||||
if jsonify:
|
if jsonify:
|
||||||
return json.dumps(self.host_metadata[hostname])
|
return json.dumps(self.host_metadata[hostname])
|
||||||
return self.host_metadata[hostname]
|
return self.host_metadata[hostname]
|
||||||
@@ -227,12 +227,12 @@ class AzureInventory(object):
|
|||||||
if ie.name == 'SSH':
|
if ie.name == 'SSH':
|
||||||
port = ie.public_port
|
port = ie.public_port
|
||||||
break
|
break
|
||||||
self.add_instance(role.instance_name, deployment, port, cloud_service)
|
|
||||||
except AttributeError as e:
|
except AttributeError as e:
|
||||||
print json.dumps({ 'msg': 'Attribute error %s' % e })
|
pass
|
||||||
return
|
finally:
|
||||||
|
self.add_instance(role.instance_name, deployment, port, cloud_service, role.instance_status)
|
||||||
|
|
||||||
def add_instance(self, hostname, deployment, ssh_port, cloud_service):
|
def add_instance(self, hostname, deployment, ssh_port, cloud_service, status):
|
||||||
"""Adds an instance to the inventory and index"""
|
"""Adds an instance to the inventory and index"""
|
||||||
|
|
||||||
dest = urlparse(deployment.url).hostname
|
dest = urlparse(deployment.url).hostname
|
||||||
@@ -241,7 +241,8 @@ class AzureInventory(object):
|
|||||||
self.index[hostname] = deployment.name
|
self.index[hostname] = deployment.name
|
||||||
|
|
||||||
self.host_metadata[hostname] = dict(ansible_ssh_host=dest,
|
self.host_metadata[hostname] = dict(ansible_ssh_host=dest,
|
||||||
ansible_ssh_port=int(ssh_port))
|
ansible_ssh_port=int(ssh_port),
|
||||||
|
instance_status=status)
|
||||||
|
|
||||||
# List of all azure deployments
|
# List of all azure deployments
|
||||||
self.push(self.inventory, "azure", hostname)
|
self.push(self.inventory, "azure", hostname)
|
||||||
|
|||||||
@@ -513,8 +513,8 @@ AZURE_REGIONS_BLACKLIST = []
|
|||||||
|
|
||||||
# Inventory variable name/value for determining whether a host is active
|
# Inventory variable name/value for determining whether a host is active
|
||||||
# in Microsoft Azure.
|
# in Microsoft Azure.
|
||||||
AZURE_ENABLED_VAR = 'status'
|
AZURE_ENABLED_VAR = 'instance_status'
|
||||||
AZURE_ENABLED_VALUE = 'created'
|
AZURE_ENABLED_VALUE = 'ReadyRole'
|
||||||
|
|
||||||
# Filter for allowed group and host names when importing inventory from
|
# Filter for allowed group and host names when importing inventory from
|
||||||
# Microsoft Azure.
|
# Microsoft Azure.
|
||||||
|
|||||||
Reference in New Issue
Block a user