mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Merge pull request #40929 from rallytime/bp-37696
Back-port #37696 to 2016.11
This commit is contained in:
commit
a622518ad2
@ -717,8 +717,47 @@ def request_instance(vm_=None, call=None):
|
||||
break
|
||||
if floating_ip is None:
|
||||
floating_ip = conn.floating_ip_create(pool)['ip']
|
||||
|
||||
def __query_node_data(vm_):
|
||||
try:
|
||||
node = show_instance(vm_['name'], 'action')
|
||||
log.debug(
|
||||
'Loaded node data for {0}:\n{1}'.format(
|
||||
vm_['name'],
|
||||
pprint.pformat(node)
|
||||
)
|
||||
)
|
||||
except Exception as err:
|
||||
log.error(
|
||||
'Failed to get nodes list: {0}'.format(
|
||||
err
|
||||
),
|
||||
# Show the traceback if the debug logging level is enabled
|
||||
exc_info_on_loglevel=logging.DEBUG
|
||||
)
|
||||
# Trigger a failure in the wait for IP function
|
||||
return False
|
||||
return node['state'] == 'ACTIVE' or None
|
||||
|
||||
# if we associate the floating ip here,then we will fail.
|
||||
# As if we attempt to associate a floating IP before the Nova instance has completed building,
|
||||
# it will fail.So we should associate it after the Nova instance has completed building.
|
||||
try:
|
||||
conn.floating_ip_associate(kwargs['name'], floating_ip)
|
||||
salt.utils.cloud.wait_for_ip(
|
||||
__query_node_data,
|
||||
update_args=(vm_,)
|
||||
)
|
||||
except (SaltCloudExecutionTimeout, SaltCloudExecutionFailure) as exc:
|
||||
try:
|
||||
# It might be already up, let's destroy it!
|
||||
destroy(vm_['name'])
|
||||
except SaltCloudSystemExit:
|
||||
pass
|
||||
finally:
|
||||
raise SaltCloudSystemExit(str(exc))
|
||||
|
||||
try:
|
||||
conn.floating_ip_associate(vm_['name'], floating_ip)
|
||||
vm_['floating_ip'] = floating_ip
|
||||
except Exception as exc:
|
||||
raise SaltCloudSystemExit(
|
||||
@ -729,7 +768,8 @@ def request_instance(vm_=None, call=None):
|
||||
)
|
||||
)
|
||||
|
||||
vm_['password'] = data.extra.get('password', '')
|
||||
if not vm_.get('password', None):
|
||||
vm_['password'] = data.extra.get('password', '')
|
||||
|
||||
return data, vm_
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user