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
fed00d04
Commit
fed00d04
authored
9 years ago
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(cli nav align) Max Hostname length 30, else will be truncate.
parent
d05e9d0b
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-rc2
v1.4.10
v1.4.7
v1.4.4
No related merge requests found
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
connect.py
connect.py
+17
-3
No files found.
connect.py
View file @
fed00d04
...
...
@@ -508,16 +508,30 @@ class Nav(object):
# 如果没有输入就展现所有
self
.
search_result
=
self
.
perm_assets
@staticmethod
def
truncate_str
(
str_
,
length
=
30
):
str_
=
str_
.
decode
(
'utf-8'
)
if
len
(
str_
)
>
length
:
return
str_
[:
14
]
+
'..'
+
str_
[
-
14
:]
else
:
return
str_
@staticmethod
def
get_max_asset_property_length
(
assets
,
property_
=
'hostname'
):
return
max
([
len
(
getattr
(
asset
,
property_
))
for
asset
in
assets
])
def
print_search_result
(
self
):
color_print
(
'[
%-3
s]
%-12
s
%-15
s
%-5
s
%-10
s
%
s'
%
(
'ID'
,
'主机名'
,
'IP'
,
'端口'
,
'系统用户'
,
'备注'
),
'title'
)
hostname_max_length
=
self
.
get_max_asset_property_length
(
self
.
search_result
)
line
=
'[
%-3
s]
%-16
s
%-5
s
%-
'
+
str
(
hostname_max_length
)
+
's
%-10
s
%
s'
color_print
(
line
%
(
'ID'
,
'IP'
,
'Port'
,
'Hostname'
,
'SysUser'
,
'Comment'
),
'title'
)
if
hasattr
(
self
.
search_result
,
'__iter__'
):
for
index
,
asset
in
enumerate
(
self
.
search_result
):
# 获取该资产信息
asset_info
=
get_asset_info
(
asset
)
# 获取该资产包含的角色
role
=
[
str
(
role
.
name
)
for
role
in
self
.
user_perm
.
get
(
'asset'
)
.
get
(
asset
)
.
get
(
'role'
)]
print
'[
%-3
s]
%-15
s
%-15
s
%-5
s
%-10
s
%
s'
%
(
index
,
asset
.
hostname
,
asset
.
ip
,
asset_info
.
get
(
'port'
),
role
,
asset
.
comment
)
print
line
%
(
index
,
asset
.
ip
,
asset_info
.
get
(
'port'
),
self
.
truncate_str
(
asset
.
hostname
),
str
(
role
)
.
replace
(
"'"
,
''
)
,
asset
.
comment
)
print
def
try_connect
(
self
):
...
...
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