[Update] 支持Windows批量命令

This commit is contained in:
BaiJiangJie
2019-12-21 19:44:25 +08:00
parent 78a227af3e
commit 1d30c1900d
3 changed files with 22 additions and 14 deletions

View File

@@ -228,7 +228,7 @@ class AdHocRunner:
class CommandRunner(AdHocRunner):
results_callback_class = CommandResultCallback
modules_choices = ('shell', 'raw', 'command', 'script')
modules_choices = ('shell', 'raw', 'command', 'script', 'win_shell')
def execute(self, cmd, pattern, module='shell'):
if module and module not in self.modules_choices:

View File

@@ -63,7 +63,12 @@ class CommandExecution(models.Model):
if ok:
runner = CommandRunner(self.inventory)
try:
result = runner.execute(self.command, 'all')
host = self.hosts[0]
if host.is_windows():
shell = 'win_shell'
else:
shell = 'shell'
result = runner.execute(self.command, 'all', module=shell)
self.result = result.results_command
except SoftTimeLimitExceeded as e:
print("Run timeout than 60s")