Skip to content

Commit

Permalink
saltmodule
Browse files Browse the repository at this point in the history
  • Loading branch information
yueyongyue committed Jun 13, 2016
1 parent 81619d8 commit b92a522
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions execute/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ def salt_result(request):
host_str = ",".join(host_list)
logger.info(host_str)
if salt_arg == '':
result = sapi.remote_noarg_execution(host_str, salt_fun)
result = sapi.remote_noarg_execution_notgt(host_str, salt_fun)
else:
result = sapi.remote_execution(host_str, salt_fun, salt_arg)
result = sapi.remote_execution_notgt(host_str, salt_fun, salt_arg)

cmd_history = Command_history()
cmd_history.user = _u
Expand Down
20 changes: 20 additions & 0 deletions shaker/shaker_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ def remote_noarg_execution(self,tgt,fun):
except Exception as e:
pass
return ret
def remote_noarg_execution_notgt(self,tgt,fun):
''' Execute commands without parameters '''
params = {'client': 'local', 'tgt': tgt, 'fun': fun, 'expr_form': 'list'}
obj = urllib.urlencode(params)
content = self.postRequest(obj)
try:
ret = content['return'][0]
except Exception as e:
pass
return ret
def remote_execution(self,tgt,fun,arg):
''' Command execution with parameters '''
params = {'client': 'local', 'tgt': tgt, 'fun': fun, 'arg': arg, 'expr_form': 'list'}
Expand All @@ -85,6 +95,16 @@ def remote_execution(self,tgt,fun,arg):
except Exception as e:
pass
return ret
def remote_execution_notgt(self,tgt,fun,arg):
''' Command execution with parameters '''
params = {'client': 'local', 'tgt': tgt, 'fun': fun, 'arg': arg, 'expr_form': 'list'}
obj = urllib.urlencode(params)
content = self.postRequest(obj)
try:
ret = content['return'][0]
except Exception as e:
pass
return ret
def shell_remote_execution(self,tgt,arg):
''' Shell command execution with parameters '''
params = {'client': 'local', 'tgt': tgt, 'fun': 'cmd.run', 'arg': arg, 'expr_form': 'list'}
Expand Down

0 comments on commit b92a522

Please sign in to comment.