mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Merge pull request #32080 from s-schweer/nova_cloud
fixed auto assigning of floating_ips for clouds.nova
This commit is contained in:
commit
7116fd6f3c
@ -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', '')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user