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
eea56ea0
Commit
eea56ea0
authored
9 years ago
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
定义通用模块执行
parent
ab313aac
master
auditor_jym
audits
dev
dev_beta
dev_beta_db
gengmei
lagacy-0.4.0
node_service
password
rbac
restrict_access
test
v52
wph
1.5.2
1.5.1
1.5.0
1.4.10
1.4.9
1.4.8
1.4.7
1.4.6
1.4.5
1.4.4
1.4.3
1.4.2
1.4.1
1.4.0
1.3.3
1.3.2
1.3.1
1.3.0
1.2.1
1.2.0
1.1.1
1.1.0
1.0.0
0.3.3
0.3.2
0.3.2-rc2
0.3.1
0.3.0-beta
v1.4.10
v1.4.7
v1.4.4
No related merge requests found
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
7 deletions
+20
-7
ansible_api.py
jperm/ansible_api.py
+3
-4
perm_api.py
jperm/perm_api.py
+5
-0
api.py
jumpserver/api.py
+11
-2
user_api.py
juser/user_api.py
+1
-1
No files found.
jperm/ansible_api.py
View file @
eea56ea0
...
...
@@ -82,11 +82,13 @@ class MyInventory(object):
hostport
=
host
.
get
(
"port"
)
username
=
host
.
get
(
"username"
)
password
=
host
.
get
(
"password"
)
ssh_key
=
host
.
get
(
"ssh_key"
)
my_host
=
Host
(
name
=
hostname
,
port
=
hostport
)
my_host
.
set_variable
(
'ansible_ssh_host'
,
hostname
)
my_host
.
set_variable
(
'ansible_ssh_port'
,
hostport
)
my_host
.
set_variable
(
'ansible_ssh_user'
,
username
)
my_host
.
set_variable
(
'ansible_ssh_pass'
,
password
)
my_host
.
set_variable
(
'ansible_ssh_private_key_file'
,
ssh_key
)
# set other variables
for
key
,
value
in
host
.
iteritems
():
if
key
not
in
[
"hostname"
,
"port"
,
"username"
,
"password"
]:
...
...
@@ -156,7 +158,7 @@ class Command(MyInventory):
if
module_name
not
in
[
"raw"
,
"command"
,
"shell"
]:
raise
CommandValueError
(
"module_name"
,
"module_name must be of the 'raw, command, shell'"
)
hoc
=
My
Runner
(
module_name
=
module_name
,
hoc
=
Runner
(
module_name
=
module_name
,
module_args
=
command
,
timeout
=
timeout
,
inventory
=
self
.
inventory
,
...
...
@@ -418,8 +420,6 @@ class Tasks(Command):
return
{
"status"
:
"failed"
,
"msg"
:
self
.
msg
}
if
self
.
msg
else
{
"status"
:
"ok"
,
"result"
:
result
}
class
CustomAggregateStats
(
callbacks
.
AggregateStats
):
"""
Holds stats about per-host activity during playbook runs.
...
...
@@ -438,7 +438,6 @@ class CustomAggregateStats(callbacks.AggregateStats):
self
.
results
.
append
(
runner_results
)
def
summarize
(
self
,
host
):
"""
Return information about a particular host
...
...
This diff is collapsed.
Click to expand it.
jperm/perm_api.py
View file @
eea56ea0
...
...
@@ -10,6 +10,11 @@ from jperm.models import PermRole
from
jperm.models
import
PermRule
class
PermGet
(
object
):
def
__init__
(
self
):
pass
def
get_object_list
(
model
,
id_list
):
"""根据id列表获取对象列表"""
object_list
=
[]
...
...
This diff is collapsed.
Click to expand it.
jumpserver/api.py
View file @
eea56ea0
...
...
@@ -3,6 +3,7 @@
import
os
,
sys
,
time
,
re
from
Crypto.Cipher
import
AES
import
crypt
import
pwd
from
binascii
import
b2a_hex
,
a2b_hex
import
hashlib
import
datetime
...
...
@@ -44,6 +45,14 @@ def set_log(level):
return
logger_f
def
chown
(
path
,
user
,
group
=
''
,
):
if
not
group
:
group
=
user
uid
=
pwd
.
getpwnam
(
user
)
.
pwd_uid
gid
=
pwd
.
getpwnam
(
group
)
.
gr_gid
os
.
chown
(
path
,
uid
,
gid
)
def
page_list_return
(
total
,
current
=
1
):
"""
page
...
...
@@ -390,7 +399,7 @@ def bash(cmd):
return
subprocess
.
call
(
cmd
,
shell
=
True
)
def
mkdir
(
dir_name
,
username
=
'
root
'
,
mode
=
0755
):
def
mkdir
(
dir_name
,
username
=
''
,
mode
=
0755
):
"""
insure the dir exist and mode ok
目录存在,如果不存在就建立,并且权限正确
...
...
@@ -399,7 +408,7 @@ def mkdir(dir_name, username='root', mode=0755):
os
.
makedirs
(
dir_name
)
os
.
chmod
(
dir_name
,
mode
)
if
username
:
bash
(
'chown
%
s:
%
s
%
s'
%
(
username
,
username
,
dir_name
)
)
chown
(
dir_name
,
username
)
def
http_success
(
request
,
msg
):
...
...
This diff is collapsed.
Click to expand it.
juser/user_api.py
View file @
eea56ea0
...
...
@@ -143,7 +143,7 @@ def gen_ssh_key(username, password='',
with
open
(
authorized_key_file
,
'w'
)
as
auth_f
:
auth_f
.
write
(
pub_f
.
read
())
os
.
chmod
(
authorized_key_file
,
0600
)
bash
(
'chown
%
s:
%
s
%
s'
%
(
username
,
username
,
authorized_key_file
)
)
chown
(
authorized_key_file
,
username
)
def
server_add_user
(
username
,
password
,
ssh_key_pwd
,
ssh_key_login_need
):
...
...
This diff is collapsed.
Click to expand it.
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