prefer port with name SSH but don't require it

This commit is contained in:
Chris Meyers
2015-04-20 15:39:21 -04:00
parent 48c194f2a9
commit f2b58af125

View File

@@ -221,13 +221,15 @@ class AzureInventory(object):
"""Adds a deployment to the inventory and index""" """Adds a deployment to the inventory and index"""
for role in deployment.role_instance_list.role_instances: for role in deployment.role_instance_list.role_instances:
try: try:
# Only consider ready vm instances (not StoppedDeallocated, not RoleStateUnknown, not StoppedVM) # Default port 22 unless port found with name 'SSH'
if role.instance_status == 'ReadyRole': port = '22'
for ie in role.instance_endpoints.instance_endpoints: for ie in role.instance_endpoints.instance_endpoints:
if ie.name == 'SSH': if ie.name == 'SSH':
self.add_instance(role.instance_name, deployment, ie.public_port, cloud_service) port = ie.public_port
break break
except AttributeError: self.add_instance(role.instance_name, deployment, port, cloud_service)
except AttributeError as e:
print json.dumps({ 'msg': 'Attribute error %s' % e })
return return
def add_instance(self, hostname, deployment, ssh_port, cloud_service): def add_instance(self, hostname, deployment, ssh_port, cloud_service):