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
c022c811
Commit
c022c811
authored
Mar 18, 2016
by
liuzheng712
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of github.com:jumpserver/jumpserver into issue_52_bugfix
parents
5af9dd65
abdf9c72
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
22 deletions
+39
-22
connect.py
connect.py
+0
-0
asset_api.py
jasset/asset_api.py
+37
-20
index.html
templates/index.html
+2
-2
No files found.
connect.py
View file @
c022c811
This diff is collapsed.
Click to expand it.
jasset/asset_api.py
View file @
c022c811
...
@@ -9,6 +9,8 @@ from jperm.ansible_api import MyRunner
...
@@ -9,6 +9,8 @@ from jperm.ansible_api import MyRunner
from
jperm.perm_api
import
gen_resource
from
jperm.perm_api
import
gen_resource
from
jumpserver.templatetags.mytags
import
get_disk_info
from
jumpserver.templatetags.mytags
import
get_disk_info
import
traceback
def
group_add_asset
(
group
,
asset_id
=
None
,
asset_ip
=
None
):
def
group_add_asset
(
group
,
asset_id
=
None
,
asset_ip
=
None
):
"""
"""
...
@@ -332,9 +334,11 @@ def get_ansible_asset_info(asset_ip, setup_info):
...
@@ -332,9 +334,11 @@ def get_ansible_asset_info(asset_ip, setup_info):
# ip = setup_info.get("ansible_default_ipv4").get("address")
# ip = setup_info.get("ansible_default_ipv4").get("address")
mac
=
setup_info
.
get
(
"ansible_default_ipv4"
)
.
get
(
"macaddress"
)
mac
=
setup_info
.
get
(
"ansible_default_ipv4"
)
.
get
(
"macaddress"
)
brand
=
setup_info
.
get
(
"ansible_product_name"
)
brand
=
setup_info
.
get
(
"ansible_product_name"
)
cpu_type
=
setup_info
.
get
(
"ansible_processor"
)[
1
]
try
:
cpu_cores
=
setup_info
.
get
(
"ansible_processor_vcpus"
)
cpu_type
=
setup_info
.
get
(
"ansible_processor"
)[
1
]
cpu
=
cpu_type
+
' * '
+
unicode
(
cpu_cores
)
except
IndexError
:
cpu_type
=
' '
.
join
(
setup_info
.
get
(
"ansible_processor"
)[
0
]
.
split
(
' '
)[:
6
])
memory
=
setup_info
.
get
(
"ansible_memtotal_mb"
)
memory
=
setup_info
.
get
(
"ansible_memtotal_mb"
)
try
:
try
:
memory_format
=
int
(
round
((
int
(
memory
)
/
1000
),
0
))
memory_format
=
int
(
round
((
int
(
memory
)
/
1000
),
0
))
...
@@ -342,7 +346,13 @@ def get_ansible_asset_info(asset_ip, setup_info):
...
@@ -342,7 +346,13 @@ def get_ansible_asset_info(asset_ip, setup_info):
memory_format
=
memory
memory_format
=
memory
disk
=
disk_need
disk
=
disk_need
system_type
=
setup_info
.
get
(
"ansible_distribution"
)
system_type
=
setup_info
.
get
(
"ansible_distribution"
)
system_version
=
setup_info
.
get
(
"ansible_distribution_version"
)
if
system_type
.
lower
()
==
"freebsd"
:
system_version
=
setup_info
.
get
(
"ansible_distribution_release"
)
cpu_cores
=
setup_info
.
get
(
"ansible_processor_count"
)
else
:
system_version
=
setup_info
.
get
(
"ansible_distribution_version"
)
cpu_cores
=
setup_info
.
get
(
"ansible_processor_vcpus"
)
cpu
=
cpu_type
+
' * '
+
unicode
(
cpu_cores
)
system_arch
=
setup_info
.
get
(
"ansible_architecture"
)
system_arch
=
setup_info
.
get
(
"ansible_architecture"
)
# asset_type = setup_info.get("ansible_system")
# asset_type = setup_info.get("ansible_system")
sn
=
setup_info
.
get
(
"ansible_product_serial"
)
sn
=
setup_info
.
get
(
"ansible_product_serial"
)
...
@@ -358,24 +368,31 @@ def asset_ansible_update(obj_list, name=''):
...
@@ -358,24 +368,31 @@ def asset_ansible_update(obj_list, name=''):
for
asset
in
obj_list
:
for
asset
in
obj_list
:
try
:
try
:
setup_info
=
ansible_asset_info
[
'contacted'
][
asset
.
hostname
][
'ansible_facts'
]
setup_info
=
ansible_asset_info
[
'contacted'
][
asset
.
hostname
][
'ansible_facts'
]
except
KeyError
:
logger
.
debug
(
"setup_info:
%
s"
%
setup_info
)
except
KeyError
,
e
:
logger
.
error
(
"获取setup_info失败:
%
s"
%
e
)
continue
continue
else
:
else
:
asset_info
=
get_ansible_asset_info
(
asset
.
ip
,
setup_info
)
try
:
other_ip
,
mac
,
cpu
,
memory
,
disk
,
sn
,
system_type
,
system_version
,
brand
,
system_arch
=
asset_info
asset_info
=
get_ansible_asset_info
(
asset
.
ip
,
setup_info
)
asset_dic
=
{
"other_ip"
:
other_ip
,
print
asset_info
"mac"
:
mac
,
other_ip
,
mac
,
cpu
,
memory
,
disk
,
sn
,
system_type
,
system_version
,
brand
,
system_arch
=
asset_info
"cpu"
:
cpu
,
asset_dic
=
{
"other_ip"
:
other_ip
,
"memory"
:
memory
,
"mac"
:
mac
,
"disk"
:
disk
,
"cpu"
:
cpu
,
"sn"
:
sn
,
"memory"
:
memory
,
"system_type"
:
system_type
,
"disk"
:
disk
,
"system_version"
:
system_version
,
"sn"
:
sn
,
"system_arch"
:
system_arch
,
"system_type"
:
system_type
,
"brand"
:
brand
"system_version"
:
system_version
,
}
"system_arch"
:
system_arch
,
"brand"
:
brand
ansible_record
(
asset
,
asset_dic
,
name
)
}
ansible_record
(
asset
,
asset_dic
,
name
)
except
Exception
as
e
:
logger
.
error
(
"save setup info failed!
%
s"
%
e
)
traceback
.
print_exc
()
def
asset_ansible_update_all
():
def
asset_ansible_update_all
():
...
...
templates/index.html
View file @
c022c811
...
@@ -210,7 +210,7 @@
...
@@ -210,7 +210,7 @@
{% if login_10 %}
{% if login_10 %}
{% for login in login_10 %}
{% for login in login_10 %}
<div
class=
"feed-element"
>
<div
class=
"feed-element"
>
<a
href=
"
profile.html
"
class=
"pull-left"
>
<a
href=
"
#
"
class=
"pull-left"
>
<img
alt=
"image"
class=
"img-circle"
src=
"/static/img/root.png"
>
<img
alt=
"image"
class=
"img-circle"
src=
"/static/img/root.png"
>
</a>
</a>
<div
class=
"media-body "
>
<div
class=
"media-body "
>
...
@@ -232,7 +232,7 @@
...
@@ -232,7 +232,7 @@
<div
class=
"feed-activity-list"
>
<div
class=
"feed-activity-list"
>
{% for login in login_more_10 %}
{% for login in login_more_10 %}
<div
class=
"feed-element"
>
<div
class=
"feed-element"
>
<a
href=
"
profile.html
"
class=
"pull-left"
>
<a
href=
"
#
"
class=
"pull-left"
>
<img
alt=
"image"
class=
"img-circle"
src=
"/static/img/root.png"
>
<img
alt=
"image"
class=
"img-circle"
src=
"/static/img/root.png"
>
</a>
</a>
<div
class=
"media-body "
>
<div
class=
"media-body "
>
...
...
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