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
a0ae7ff1
Commit
a0ae7ff1
authored
Nov 28, 2015
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改getresource
parent
8ac369b9
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
68 deletions
+21
-68
utils.py
jperm/utils.py
+1
-1
views.py
jperm/views.py
+20
-17
perm_sudo_add.html
templates/jperm/perm_sudo_add.html
+0
-50
No files found.
jperm/utils.py
View file @
a0ae7ff1
...
...
@@ -108,7 +108,7 @@ def get_add_sudo_script(sudo_chosen_aliase, sudo_chosen_obj):
sudo_file
=
NamedTemporaryFile
(
delete
=
False
)
sudo_file
.
write
(
sudo_content
)
sudo_file
.
close
()
print
(
sudo_file
.
name
)
return
sudo_file
.
name
...
...
jperm/views.py
View file @
a0ae7ff1
...
...
@@ -356,7 +356,6 @@ def perm_role_edit(request):
if
request
.
method
==
"GET"
:
return
my_render
(
'jperm/perm_role_edit.html'
,
locals
(),
request
)
if
request
.
method
==
"POST"
:
# 获取 POST 数据
role_name
=
request
.
POST
.
get
(
"role_name"
)
...
...
@@ -423,23 +422,25 @@ def perm_role_push(request):
group_assets_obj
=
[]
for
asset_group
in
asset_groups_obj
:
group_assets_obj
.
extend
(
asset_group
.
asset_set
.
all
())
calc_assets
=
set
(
assets_obj
)
|
set
(
group_assets_obj
)
calc_assets
=
list
(
set
(
assets_obj
)
|
set
(
group_assets_obj
)
)
# 生成Inventory
push_resource
=
[]
for
asset
in
calc_assets
:
if
asset
.
use_default_auth
:
username
=
Setting
.
field1
port
=
Setting
.
field2
password
=
Setting
.
field3
else
:
username
=
asset
.
username
password
=
asset
.
password
port
=
asset
.
port
push_resource
.
append
({
"hostname"
:
asset
.
ip
,
"port"
:
port
,
"username"
:
username
,
"password"
:
password
})
# push_resource = []
# for asset in calc_assets:
# if asset.use_default_auth:
# username = Setting.field1
# port = Setting.field2
# password = Setting.field3
# else:
# username = asset.username
# password = asset.password
# port = asset.port
# push_resource.append({"hostname": asset.ip,
# "port": port,
# "username": username,
# "password": password})
push_resource
=
gen_resource
(
calc_assets
)
print
push_resource
# 获取角色的推送方式,以及推送需要的信息
roles_obj
=
[
PermRole
.
objects
.
get
(
name
=
role_name
)
for
role_name
in
role_names
]
...
...
@@ -486,7 +487,9 @@ def perm_role_push(request):
if
ret_sudo
[
"step1"
]
!=
"ok"
or
ret_sudo
[
"step2"
]
!=
"ok"
:
ret_failed
[
"step3"
]
=
"failed"
os
.
remove
(
add_sudo_script
)
# os.remove(add_sudo_script)
print
ret
# 结果汇总统计
...
...
templates/jperm/perm_sudo_add.html
View file @
a0ae7ff1
{% extends 'base.html' %}
{% block self_head_css_js %}
<link
href=
"/static/css/plugins/datapicker/datepicker3.css"
rel=
"stylesheet"
>
<link
href=
"/static/css/plugins/chosen/chosen.css"
rel=
"stylesheet"
>
<script
src=
"/static/js/plugins/chosen/chosen.jquery.js"
></script>
{% endblock %}
{% load mytags %}
{% block content %}
{% include 'nav_cat_bar.html' %}
...
...
@@ -69,52 +64,7 @@
{% endblock %}
{% block self_footer_js %}
<script>
$
(
document
).
ready
(
function
(){
$
(
"input.role"
).
click
(
function
(){
if
(
$
(
"input.role[value=GA]"
).
is
(
":checked"
)){
$
(
"#admin_groups"
).
css
(
"display"
,
'none'
);
}
else
{
$
(
"#admin_groups"
).
css
(
"display"
,
'block'
);
}
});
$
(
'#use_password'
).
click
(
function
(){
if
(
$
(
this
).
is
(
':checked'
)){
$
(
'#admin_account_password'
).
css
(
'display'
,
'block'
)
}
else
{
$
(
'#admin_account_password'
).
css
(
'display'
,
'none'
)
}
});
$
(
'#use_publicKey'
).
click
(
function
(){
if
(
$
(
this
).
is
(
':checked'
)){
$
(
'#admin_account_publicKey'
).
css
(
'display'
,
'block'
)
}
else
{
$
(
'#admin_account_publicKey'
).
css
(
'display'
,
'none'
)
}
});
});
var
config
=
{
'.chosen-select'
:
{},
'.chosen-select-deselect'
:
{
allow_single_deselect
:
true
},
'.chosen-select-no-single'
:
{
disable_search_threshold
:
10
},
'.chosen-select-no-results'
:
{
no_results_text
:
'Oops, nothing found!'
},
'.chosen-select-width'
:
{
width
:
"95%"
}
};
for
(
var
selector
in
config
)
{
$
(
selector
).
chosen
(
config
[
selector
]);
}
</script>
<script
src=
"/static/js/cropper/cropper.min.js"
></script>
<script
src=
"/static/js/datapicker/bootstrap-datepicker.js"
></script>
{% endblock %}
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