mirror of https://github.com/jumpserver/jumpserver
[Update] 支持Windows批量命令
parent
78a227af3e
commit
1d30c1900d
|
@ -155,6 +155,12 @@ class Platform(models.Model):
|
|||
)
|
||||
return linux.id
|
||||
|
||||
def is_windows(self):
|
||||
return self.base.lower() in ('windows',)
|
||||
|
||||
def is_unixlike(self):
|
||||
return self.base.lower() in ("linux", "unix", "macos", "bsd")
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
@ -233,22 +239,19 @@ class Asset(ProtocolsMixin, NodesRelationMixin, OrgModelMixin):
|
|||
return False, warning
|
||||
return True, warning
|
||||
|
||||
def is_windows(self):
|
||||
return self.platform_base == "Windows"
|
||||
|
||||
def is_unixlike(self):
|
||||
if self.platform_base not in ("Windows", "Windows2016", "Other"):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def is_support_ansible(self):
|
||||
return self.has_protocol('ssh') and self.platform_base not in ("Other",)
|
||||
|
||||
@lazyproperty
|
||||
def platform_base(self):
|
||||
return self.platform.base
|
||||
|
||||
def is_windows(self):
|
||||
return self.platform.is_windows()
|
||||
|
||||
def is_unixlike(self):
|
||||
return self.platform.is_unixlike()
|
||||
|
||||
def is_support_ansible(self):
|
||||
return self.has_protocol('ssh') and self.platform_base not in ("Other",)
|
||||
|
||||
@property
|
||||
def cpu_info(self):
|
||||
info = ""
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue