mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Make the salt-cloud actions output more verbose and helpful
Fixes #10157
This commit is contained in:
parent
119f025073
commit
6fa952f16d
1 changed files with 34 additions and 3 deletions
|
@ -1436,6 +1436,7 @@ class Cloud(object):
|
|||
Perform an action on a VM which may be specific to this cloud provider
|
||||
'''
|
||||
ret = {}
|
||||
invalid_functions = {}
|
||||
names = set(names)
|
||||
|
||||
for alias, drivers in six.iteritems(self.map_providers_parallel()):
|
||||
|
@ -1444,6 +1445,7 @@ class Cloud(object):
|
|||
for driver, vms in six.iteritems(drivers):
|
||||
if not names:
|
||||
break
|
||||
valid_function = True
|
||||
fun = '{0}.{1}'.format(driver, self.opts['action'])
|
||||
if fun not in self.clouds:
|
||||
log.info(
|
||||
|
@ -1451,7 +1453,7 @@ class Cloud(object):
|
|||
fun
|
||||
)
|
||||
)
|
||||
continue
|
||||
valid_function = False
|
||||
for vm_name, vm_details in six.iteritems(vms):
|
||||
if not names:
|
||||
break
|
||||
|
@ -1462,6 +1464,14 @@ class Cloud(object):
|
|||
)
|
||||
)
|
||||
continue
|
||||
|
||||
# Build the dictionary of invalid functions with their associated VMs.
|
||||
if valid_function is False:
|
||||
if invalid_functions.get(fun) is None:
|
||||
invalid_functions.update({fun: []})
|
||||
invalid_functions[fun].append(vm_name)
|
||||
continue
|
||||
|
||||
with context.func_globals_inject(
|
||||
self.clouds[fun],
|
||||
__active_provider_name__=':'.join([alias, driver])
|
||||
|
@ -1488,10 +1498,33 @@ class Cloud(object):
|
|||
)
|
||||
names.remove(vm_name)
|
||||
|
||||
# Set the return information for the VMs listed in the invalid_functions dict.
|
||||
missing_vms = set()
|
||||
if invalid_functions:
|
||||
ret['Invalid Actions'] = invalid_functions
|
||||
invalid_func_vms = set()
|
||||
for key, val in six.iteritems(invalid_functions):
|
||||
invalid_func_vms = invalid_func_vms.union(set(val))
|
||||
|
||||
# Find the VMs that are in names, but not in set of invalid functions.
|
||||
missing_vms = names.difference(invalid_func_vms)
|
||||
if missing_vms:
|
||||
ret['Not Found'] = list(missing_vms)
|
||||
ret['Not Actioned/Not Running'] = list(names)
|
||||
|
||||
if not names:
|
||||
return ret
|
||||
|
||||
# Don't return missing VM information for invalid functions until after we've had a
|
||||
# Chance to return successful actions. If a function is valid for one driver, but
|
||||
# Not another, we want to make sure the successful action is returned properly.
|
||||
if missing_vms:
|
||||
return ret
|
||||
|
||||
# If we reach this point, the Not Actioned and Not Found lists will be the same,
|
||||
# But we want to list both for clarity/consistency with the invalid functions lists.
|
||||
ret['Not Actioned/Not Running'] = list(names)
|
||||
ret['Not Found'] = list(names)
|
||||
return ret
|
||||
|
||||
def do_function(self, prov, func, kwargs):
|
||||
|
@ -2325,5 +2358,3 @@ def _destroy_multiprocessing(*args, **kw):
|
|||
|
||||
def _create_multiprocessing(*args, **kw):
|
||||
return communicator(create_multiprocessing)(*args[0], **kw)
|
||||
|
||||
#
|
||||
|
|
Loading…
Add table
Reference in a new issue