Handle hpcloud assigning ips by default.
HPCloud now includes a public ip on every server, but still _also_ has the floating ip extension. Try to identify the public ip (by guessing!) and stop using floating ips if possible. Change-Id: I7c089b94b64cf6ebc168d44b55f43bd07ca12563
This commit is contained in:
@@ -86,11 +86,13 @@ def check_machine(client, machine, error_counts):
|
||||
return
|
||||
|
||||
if server.status == 'ACTIVE':
|
||||
if 'os-floating-ips' in utils.get_extensions(client):
|
||||
utils.add_public_ip(server)
|
||||
ip = utils.get_public_ip(server)
|
||||
if not ip and 'os-floating-ips' in utils.get_extensions(client):
|
||||
utils.add_public_ip(server)
|
||||
ip = utils.get_public_ip(server)
|
||||
if not ip:
|
||||
raise Exception("Unable to find public ip of server")
|
||||
|
||||
machine.ip = ip
|
||||
print "Machine %s is running, testing ssh" % machine.id
|
||||
if utils.ssh_connect(ip, 'jenkins'):
|
||||
|
||||
@@ -121,9 +121,10 @@ def local_prep(distribution):
|
||||
|
||||
def bootstrap_server(provider, server, admin_pass, key):
|
||||
client = server.manager.api
|
||||
if 'os-floating-ips' in utils.get_extensions(client):
|
||||
utils.add_public_ip(server)
|
||||
ip = utils.get_public_ip(server)
|
||||
if not ip and 'os-floating-ips' in utils.get_extensions(client):
|
||||
utils.add_public_ip(server)
|
||||
ip = utils.get_public_ip(server)
|
||||
if not ip:
|
||||
raise Exception("Unable to find public ip of server")
|
||||
|
||||
|
||||
18
utils.py
18
utils.py
@@ -87,14 +87,16 @@ def get_public_ip(server, version=4):
|
||||
if addr.instance_id == server.id:
|
||||
print 'found addr', addr
|
||||
return addr.ip
|
||||
else:
|
||||
print 'no floating ips, addresses:'
|
||||
print server.addresses
|
||||
for addr in server.addresses.get('public', []):
|
||||
if type(addr) == type(u''): # Rackspace/openstack 1.0
|
||||
return addr
|
||||
if addr['version'] == version: #Rackspace/openstack 1.1
|
||||
return addr['addr']
|
||||
print 'no floating ip, addresses:'
|
||||
print server.addresses
|
||||
for addr in server.addresses.get('public', []):
|
||||
if type(addr) == type(u''): # Rackspace/openstack 1.0
|
||||
return addr
|
||||
if addr['version'] == version: #Rackspace/openstack 1.1
|
||||
return addr['addr']
|
||||
for addr in server.addresses.get('private', []):
|
||||
if addr['version'] == version and not addr['addr'].startswith('10.'): #HPcloud
|
||||
return addr['addr']
|
||||
return None
|
||||
|
||||
def add_public_ip(server):
|
||||
|
||||
Reference in New Issue
Block a user