Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
1d30c190
Commit
1d30c190
authored
Dec 21, 2019
by
BaiJiangJie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 支持Windows批量命令
parent
78a227af
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
11 deletions
+19
-11
asset.py
apps/assets/models/asset.py
+12
-9
runner.py
apps/ops/ansible/runner.py
+1
-1
command.py
apps/ops/models/command.py
+6
-1
No files found.
apps/assets/models/asset.py
View file @
1d30c190
...
...
@@ -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
@lazyproperty
def
platform_base
(
self
):
return
self
.
platform
.
base
def
is_windows
(
self
):
return
self
.
platform
_base
==
"Windows"
return
self
.
platform
.
is_windows
()
def
is_unixlike
(
self
):
if
self
.
platform_base
not
in
(
"Windows"
,
"Windows2016"
,
"Other"
):
return
True
else
:
return
False
return
self
.
platform
.
is_unixlike
()
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
@property
def
cpu_info
(
self
):
info
=
""
...
...
apps/ops/ansible/runner.py
View file @
1d30c190
...
...
@@ -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
:
...
...
apps/ops/models/command.py
View file @
1d30c190
...
...
@@ -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"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment