Merge pull request #32080 from s-schweer/nova_cloud

fixed auto assigning of floating_ips for clouds.nova
This commit is contained in:
Nicole Thomas 2016-03-23 15:30:54 -06:00
commit 7116fd6f3c

View File

@ -668,24 +668,24 @@ def request_instance(vm_=None, call=None):
default={})
if floating_ip_conf.get('auto_assign', False):
pool = floating_ip_conf.get('pool', 'public')
floating_ip = None
for fl_ip, opts in conn.floating_ip_list().iteritems():
if opts['instance_id'] is None and opts['pool'] == pool:
if opts['fixed_ip'] is None and opts['pool'] == pool:
floating_ip = fl_ip
break
else:
floating_ip = conn.floating_ip_create(pool)
if floating_ip is None:
floating_ip = conn.floating_ip_create(pool)['ip']
try:
conn.floating_ip_associate(kwargs['name'], floating_ip)
vm_['floating_ip'] = floating_ip
except Exception as exc:
raise SaltCloudSystemExit(
'Error assigning floating_ip for {0} on Nova\n\n'
'The following exception was thrown by libcloud when trying to '
'assing a floating ip: {1}\n'.format(
vm_['name'], exc
'Error assigning floating_ip for {0} on Nova\n\n'
'The following exception was thrown by libcloud when trying to '
'assing a floating ip: {1}\n'.format(
vm_['name'], exc
)
)
)
vm_['password'] = data.extra.get('password', '')