mirror of
https://github.com/valitydev/salt.git
synced 2024-11-09 01:36:48 +00:00
Fix format_call in state module
This commit is contained in:
parent
0552ec691d
commit
af55549232
@ -70,7 +70,7 @@ class State(object):
|
|||||||
|
|
||||||
def format_call(self, data):
|
def format_call(self, data):
|
||||||
'''
|
'''
|
||||||
Formats the data into a list of dicts used to acctually call the state,
|
Formats low data into a list of dicts used to acctually call the state,
|
||||||
returns:
|
returns:
|
||||||
{
|
{
|
||||||
'full': 'module.function',
|
'full': 'module.function',
|
||||||
@ -83,21 +83,30 @@ class State(object):
|
|||||||
verify_data
|
verify_data
|
||||||
'''
|
'''
|
||||||
ret = {}
|
ret = {}
|
||||||
ret['full'] = data['state'] + '.' + fun
|
ret['full'] = data['state'] + '.' + data['fun']
|
||||||
ret['args'] = []
|
ret['args'] = []
|
||||||
aspec = inspect.getargspec(self.states[full])
|
aspec = inspect.getargspec(self.states[ret['full']])
|
||||||
|
arglen = 0
|
||||||
|
deflen = 0
|
||||||
|
if type(aspec[0]) == type(list()):
|
||||||
|
arglen = len(aspec[0])
|
||||||
|
if type(aspec[3]) == type(list()):
|
||||||
|
arglen = len(aspec[3])
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
for ind in range(len(aspec[0] - 1, 0, -1)):
|
for ind in range(arglen - 1, 0, -1):
|
||||||
def_minus = len(aspec[0]) - ind
|
def_minus = arglen - ind
|
||||||
if len(aspec[3]) - def_minus > -1:
|
if deflen - def_minus > -1:
|
||||||
minus = def_minus + 1
|
minus = def_minus + 1
|
||||||
kwargs[aspec[0][ind]] = aspec[3][-minus]
|
kwargs[aspec[0][ind]] = aspec[3][-minus]
|
||||||
for arg in kwargs:
|
for arg in kwargs:
|
||||||
if data.has_key(arg):
|
if data.has_key(arg):
|
||||||
kwargs[arg] = data['arg']
|
kwargs[arg] = data['arg']
|
||||||
for arg in aspec[0]:
|
for arg in aspec[0]:
|
||||||
|
if kwargs.has_key(arg):
|
||||||
ret['args'].append(kwargs[arg])
|
ret['args'].append(kwargs[arg])
|
||||||
return data
|
else:
|
||||||
|
ret['args'].append(data[arg])
|
||||||
|
return ret
|
||||||
|
|
||||||
def compile_high_data(self, high):
|
def compile_high_data(self, high):
|
||||||
'''
|
'''
|
||||||
|
Loading…
Reference in New Issue
Block a user