Make sure cloud actions can be called via salt run

This commit is contained in:
Aditya Kulkarni 2016-01-07 21:31:11 +00:00
parent 2000800915
commit 5264449fdb
2 changed files with 15 additions and 9 deletions

View File

@ -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](

View File

@ -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