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
4cdc7f33
Commit
4cdc7f33
authored
Nov 22, 2015
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加注释
parent
a143797a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
17 deletions
+29
-17
connect.py
connect.py
+19
-5
nav.html
templates/nav.html
+0
-2
setting.html
templates/setting.html
+10
-10
No files found.
connect.py
View file @
4cdc7f33
...
...
@@ -504,24 +504,33 @@ class Nav(object):
def
search
(
self
,
str_r
=
''
):
gid_pattern
=
re
.
compile
(
r'^g\d+$'
)
# 获取用户授权的所有主机信息
if
not
self
.
user_perm
:
self
.
user_perm
=
get_group_user_perm
(
self
.
user
)
user_asset_all
=
self
.
user_perm
.
get
(
'asset'
)
.
keys
()
# 搜索结果保存
user_asset_search
=
[]
if
str_r
:
# 资产组组id匹配
if
gid_pattern
.
match
(
str_r
):
user_asset_search
=
list
(
Asset
.
objects
.
all
())
gid
=
int
(
str_r
.
lstrip
(
'g'
))
# 获取资产组包含的资产
user_asset_search
=
get_object
(
AssetGroup
,
id
=
gid
)
.
asset_set
.
all
()
else
:
# 匹配 ip, hostname, 备注
for
asset
in
user_asset_all
:
if
str_r
in
asset
.
ip
or
str_r
in
str
(
asset
.
comment
):
if
str_r
in
asset
.
ip
or
str_r
in
str
(
asset
.
hostname
)
or
str_r
in
str
(
asset
.
comment
):
user_asset_search
.
append
(
asset
)
else
:
# 如果没有输入就展现所有
user_asset_search
=
user_asset_all
self
.
search_result
=
dict
(
zip
(
range
(
len
(
user_asset_search
)),
user_asset_search
))
print
'
\033
[32m[
%-3
s]
%-15
s
%-15
s
%-5
s
%-10
s
%
s
\033
[0m'
%
(
'ID'
,
'AssetName'
,
'IP'
,
'Port'
,
'Role'
,
'Comment'
)
for
index
,
asset
in
self
.
search_result
.
items
():
# 获取该资产信息
asset_info
=
get_asset_info
(
asset
)
# 获取该资产包含的角色
role
=
[
str
(
role
.
name
)
for
role
in
self
.
user_perm
.
get
(
'asset'
)
.
get
(
asset
)
.
get
(
'role'
)]
if
asset
.
comment
:
print
'[
%-3
s]
%-15
s
%-15
s
%-5
s
%-10
s
%
s'
%
(
index
,
asset
.
hostname
,
asset
.
ip
,
asset_info
.
get
(
'port'
),
...
...
@@ -530,9 +539,11 @@ class Nav(object):
print
'[
%-3
s]
%-15
s
%-15
s
%-5
s
%-10
s'
%
(
index
,
asset
.
hostname
,
asset
.
ip
,
asset_info
.
get
(
'port'
),
role
)
print
@staticmethod
def
print_asset_group
():
user_asset_group_all
=
AssetGroup
.
objects
.
all
()
def
print_asset_group
(
self
):
"""
打印用户授权的资产组
"""
user_asset_group_all
=
get_group_user_perm
(
self
.
user
)
.
get
(
'asset_group'
,
[])
print
'
\033
[32m[
%-3
s]
%-15
s
%
s
\033
[0m'
%
(
'ID'
,
'GroupName'
,
'Comment'
)
for
asset_group
in
user_asset_group_all
:
...
...
@@ -543,6 +554,9 @@ class Nav(object):
print
def
exec_cmd
(
self
):
"""
批量执行命令
"""
self
.
search
()
while
True
:
print
"请输入主机名、IP或ansile支持的pattern, q退出"
...
...
templates/nav.html
View file @
4cdc7f33
...
...
@@ -36,8 +36,6 @@
<li
class=
"role"
>
<a
href=
"/jperm/role/"
>
系统角色
</a>
</li>
<li
class=
"apply_show online"
><a
href=
"/jperm/apply_show/online/"
>
权限审批
</a></li>
<li
class=
"apply_show online"
><a
href=
"/jperm/log/"
>
授权记录
</a></li>
</ul>
</li>
<li
id=
"jlog"
>
...
...
templates/setting.html
View file @
4cdc7f33
...
...
@@ -29,7 +29,7 @@
<div
class=
"panel-options"
>
<ul
class=
"nav nav-tabs"
>
<li
id=
"tab1"
class=
"active"
><a
data-toggle=
"tab"
href=
"#tab-default"
aria-expanded=
"true"
>
默认设置
</a></li>
<li
id=
"tab2"
class=
""
><a
data-toggle=
"tab"
href=
"#tab-email"
aria-expanded=
"true"
>
邮箱设置
</a></li>
{#
<li
id=
"tab2"
class=
""
><a
data-toggle=
"tab"
href=
"#tab-email"
aria-expanded=
"true"
>
邮箱设置
</a></li>
#}
</ul>
</div>
</div>
...
...
@@ -82,15 +82,15 @@
</form>
</div>
<div
id=
"tab-email"
class=
"tab-pane"
>
<table
class=
"table table-striped table-bordered table-hover "
id=
"editable"
>
<thead>
<tr>
<th
class=
"text-center"
>
组名
</th>
</tr>
</thead>
</table>
</div>
{#
<div
id=
"tab-email"
class=
"tab-pane"
>
#}
{#
<table
class=
"table table-striped table-bordered table-hover "
id=
"editable"
>
#}
{#
<thead>
#}
{#
<tr>
#}
{#
<th
class=
"text-center"
>
组名
</th>
#}
{#
</tr>
#}
{#
</thead>
#}
{#
</table>
#}
{#
</div>
#}
</div>
</div>
</div>
...
...
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