mirror of
https://github.com/valitydev/salt.git
synced 2024-11-09 01:36:48 +00:00
Merge pull request #30217 from pass-by-value/cloud_actions_dispatch
Make sure cloud actions can be called via salt run
This commit is contained in:
commit
461a741e14
@ -9,6 +9,7 @@ from __future__ import absolute_import, print_function, generators
|
||||
import os
|
||||
import copy
|
||||
import glob
|
||||
import inspect
|
||||
import time
|
||||
import signal
|
||||
import logging
|
||||
@ -1460,8 +1461,15 @@ class Cloud(object):
|
||||
ret[alias][driver] = {}
|
||||
|
||||
if kwargs:
|
||||
argnames = inspect.getargspec(self.clouds[fun]).args
|
||||
for _ in inspect.getargspec(self.clouds[fun]).defaults:
|
||||
argnames.pop(0)
|
||||
kws = {}
|
||||
for kwarg in argnames:
|
||||
kws[kwarg] = kwargs.get(kwarg, None)
|
||||
kws['call'] = 'action'
|
||||
ret[alias][driver][vm_name] = self.clouds[fun](
|
||||
vm_name, kwargs, call='action'
|
||||
vm_name, **kws
|
||||
)
|
||||
else:
|
||||
ret[alias][driver][vm_name] = self.clouds[fun](
|
||||
|
@ -125,18 +125,23 @@ def destroy(instances):
|
||||
return info
|
||||
|
||||
|
||||
def action(
|
||||
func=None,
|
||||
cloudmap=None,
|
||||
instances=None,
|
||||
provider=None,
|
||||
instance=None,
|
||||
**kwargs):
|
||||
def action(*args, **kwargs):
|
||||
'''
|
||||
Execute a single action on the given map/provider/instance
|
||||
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt-run cloud.actions start my-salt-vm
|
||||
'''
|
||||
client = _get_client()
|
||||
info = client.action(func, cloudmap, instances, provider, instance, kwargs)
|
||||
info = client.action(args[0],
|
||||
kwargs.get('cloudmap', None),
|
||||
args[1:],
|
||||
kwargs.get('provider', None),
|
||||
kwargs.get('instance', None),
|
||||
kwargs)
|
||||
return info
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user