mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Make sure cloud actions can be called via salt run
This commit is contained in:
parent
2000800915
commit
5264449fdb
@ -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,14 @@ class Cloud(object):
|
||||
ret[alias][driver] = {}
|
||||
|
||||
if kwargs:
|
||||
argnames = inspect.getargspec(self.clouds[fun]).args
|
||||
[argnames.pop(0) for _ in inspect.getargspec(self.clouds[fun]).defaults]
|
||||
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,17 @@ 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
|
||||
'''
|
||||
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