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
d42197db
Commit
d42197db
authored
Nov 17, 2015
by
halcyon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix tower bugs
parent
ee7675f7
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
57 additions
and
49 deletions
+57
-49
asset_api.py
jasset/asset_api.py
+1
-1
models.py
jasset/models.py
+2
-2
views.py
jasset/views.py
+15
-7
cmdb_excel_2015_11_17_22_38.xlsx
static/files/excels/cmdb_excel_2015_11_17_22_38.xlsx
+0
-0
cmdb_excel_2015_11_17_22_39.xlsx
static/files/excels/cmdb_excel_2015_11_17_22_39.xlsx
+0
-0
cmdb_excel_2015_11_17_23_19.xlsx
static/files/excels/cmdb_excel_2015_11_17_23_19.xlsx
+0
-0
asset_detail.html
templates/jasset/asset_detail.html
+19
-19
asset_list.html
templates/jasset/asset_list.html
+4
-4
group_add.html
templates/jasset/group_add.html
+6
-6
group_detail.html
templates/jasset/group_detail.html
+7
-7
group_edit.html
templates/jasset/group_edit.html
+2
-2
nav.html
templates/nav.html
+1
-1
No files found.
jasset/asset_api.py
View file @
d42197db
...
...
@@ -381,13 +381,13 @@ def excel_to_db(excel_file):
row
=
table
.
row_values
(
row_num
)
if
row
:
ip
,
port
,
hostname
,
use_default_auth
,
username
,
password
,
group
=
row
print
ip
use_default_auth
=
1
if
use_default_auth
==
u'默认'
else
0
if
get_object
(
Asset
,
ip
=
ip
):
continue
if
ip
and
port
:
asset
=
Asset
(
ip
=
ip
,
port
=
port
,
hostname
=
hostname
,
use_default_auth
=
use_default_auth
,
username
=
username
,
password
=
password
...
...
jasset/models.py
View file @
d42197db
...
...
@@ -37,8 +37,8 @@ class AssetGroup(models.Model):
class
IDC
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
32
,
verbose_name
=
u'机房名称'
)
bandwidth
=
models
.
CharField
(
max_length
=
32
,
blank
=
True
,
null
=
True
,
verbose_name
=
u'机房带宽'
)
linkman
=
models
.
CharField
(
max_length
=
16
,
null
=
True
,
verbose_name
=
u'联系人'
)
phone
=
models
.
CharField
(
max_length
=
32
,
verbose_name
=
u'联系电话'
)
linkman
=
models
.
CharField
(
max_length
=
16
,
blank
=
True
,
null
=
True
,
verbose_name
=
u'联系人'
)
phone
=
models
.
CharField
(
max_length
=
32
,
blank
=
True
,
null
=
True
,
verbose_name
=
u'联系电话'
)
address
=
models
.
CharField
(
max_length
=
128
,
blank
=
True
,
null
=
True
,
verbose_name
=
u"机房地址"
)
network
=
models
.
TextField
(
blank
=
True
,
null
=
True
,
verbose_name
=
u"IP地址段"
)
date_added
=
models
.
DateField
(
auto_now
=
True
,
null
=
True
)
...
...
jasset/views.py
View file @
d42197db
...
...
@@ -2,9 +2,9 @@
import
ast
from
django.db.models
import
Q
from
django.shortcuts
import
get_object_or_404
from
jasset.asset_api
import
*
from
jumpserver.api
import
*
from
jumpserver.models
import
Setting
from
jasset.forms
import
AssetForm
,
IdcForm
from
jasset.models
import
Asset
,
IDC
,
AssetGroup
,
ASSET_TYPE
,
ASSET_STATUS
from
ansible_api
import
Tasks
...
...
@@ -330,13 +330,20 @@ def asset_update(request):
return
HttpResponseRedirect
(
'/jasset/asset_detail/?id=
%
s'
%
asset_id
)
name
=
request
.
session
.
get
(
'username'
,
'admin'
)
if
asset
.
use_default_auth
:
username
=
'root'
password
=
'123456'
default
=
Setting
.
objects
.
all
()
if
default
:
default
=
default
[
0
]
username
=
default
.
default_user
password
=
default
.
default_password
port
=
default
.
default_port
else
:
return
HttpResponse
(
u'没有设置默认用户名和密码!'
)
else
:
username
=
asset
.
username
password
=
asset
.
password
port
=
asset
.
port
resource
=
[{
"hostname"
:
asset
.
ip
,
"port"
:
asset
.
port
,
resource
=
[{
"hostname"
:
asset
.
ip
,
"port"
:
port
,
"username"
:
username
,
"password"
:
password
}]
ansible_instance
=
Tasks
(
resource
)
...
...
@@ -446,9 +453,10 @@ def idc_del(request):
"""
IDC delete view
"""
uuid
=
request
.
GET
.
get
(
'uuid'
,
''
)
idc
=
get_object_or_404
(
IDC
,
uuid
=
uuid
)
idc
.
delete
()
uuid
=
request
.
GET
.
get
(
'id'
,
''
)
idc
=
get_object
(
IDC
,
id
=
uuid
)
if
idc
:
idc
.
delete
()
return
HttpResponseRedirect
(
'/jasset/idc_list/'
)
...
...
static/files/excels/cmdb_excel_2015_11_17_22_38.xlsx
0 → 100644
View file @
d42197db
File added
static/files/excels/cmdb_excel_2015_11_17_22_39.xlsx
0 → 100644
View file @
d42197db
File added
static/files/excels/cmdb_excel_2015_11_17_23_19.xlsx
0 → 100644
View file @
d42197db
File added
templates/jasset/asset_detail.html
View file @
d42197db
...
...
@@ -31,11 +31,11 @@
<table
class=
"table"
>
<tr>
<td
class=
"text-navy"
>
IP
</td>
<td>
{{ asset.ip }}
</td>
<td>
{{ asset.ip
|default_if_none:""
}}
</td>
</tr>
<tr>
<td
class=
"text-navy"
>
主机名
</td>
<td>
{{ asset.hostname }}
</td>
<td>
{{ asset.hostname
|default_if_none:""
}}
</td>
</tr>
<tr>
<td
class=
"text-navy"
>
其他IP
</td>
...
...
@@ -53,11 +53,11 @@
</tr>
<tr>
<td
class=
"text-navy"
>
远控IP
</td>
<td>
{{ asset.remote_ip }}
</td>
<td>
{{ asset.remote_ip
|default_if_none:""
}}
</td>
</tr>
<tr>
<td
class=
"text-navy"
>
端口
</td>
<td>
{{ asset.port }}
</td>
<td>
{{ asset.port
|default_if_none:""
}}
</td>
</tr>
<tr>
...
...
@@ -66,7 +66,7 @@
<table
class=
"table"
>
{% for asset_group in asset.group.all %}
<tr>
<td>
{{ asset_group.name }}
</td>
<td>
{{ asset_group.name
|default_if_none:""
}}
</td>
</tr>
{% endfor %}
</table>
...
...
@@ -79,19 +79,19 @@
</tr>
<tr>
<td
class=
"text-navy"
>
机房
</td>
<td>
{{ asset.idc.name }}
</td>
<td>
{{ asset.idc.name
|default_if_none:""
}}
</td>
</tr>
<tr>
<td
class=
"text-navy"
>
硬件厂商型号
</td>
<td>
{{ asset.brand }}
</td>
<td>
{{ asset.brand
|default_if_none:""
}}
</td>
</tr>
<tr>
<td
class=
"text-navy"
>
CPU
</td>
<td>
{{ asset.cpu }}
</td>
<td>
{{ asset.cpu
|default_if_none:""
}}
</td>
</tr>
<tr>
<td
class=
"text-navy"
>
内存
</td>
<td>
{{ asset.memory
}}M
</td>
<td>
{{ asset.memory
|default_if_none:"" }}
</td>
</tr>
<tr>
<td
class=
"text-navy"
>
硬盘
</td>
...
...
@@ -100,7 +100,7 @@
{% if asset.disk %}
{% for disk, value in asset.disk|str_to_dic %}
<tr>
<td><span
class=
"text-navy"
>
{{ disk
}}
</span>
&
nbsp
&
nbsp
&
nbsp {{ value
}}
</td>
<td><span
class=
"text-navy"
>
{{ disk
|default_if_none:"" }}
</span>
&
nbsp
&
nbsp
&
nbsp {{ value|default_if_none:""
}}
</td>
</tr>
{% endfor %}
{% endif %}
...
...
@@ -109,35 +109,35 @@
</tr>
<tr>
<td
class=
"text-navy"
>
资产编号
</td>
<td>
{{ asset.number }}
</td>
<td>
{{ asset.number
|default_if_none:""
}}
</td>
</tr>
<tr>
<td
class=
"text-navy"
>
SN
</td>
<td>
{{ asset.sn }}
</td>
<td>
{{ asset.sn
|default_if_none:""
}}
</td>
</tr>
<tr>
<td
class=
"text-navy"
>
主机类型
</td>
<td>
{{ asset.get_asset_type_display }}
</td>
<td>
{{ asset.get_asset_type_display
|default_if_none:""
}}
</td>
</tr>
<tr>
<td
class=
"text-navy"
>
系统版本
</td>
<td>
{{ asset.system_type
}} {{ asset.system_version
}}
</td>
<td>
{{ asset.system_type
|default_if_none:"" }} {{ asset.system_version|default_if_none:""
}}
</td>
</tr>
<tr>
<td
class=
"text-navy"
>
运行环境
</td>
<td>
{{ asset.get_env_display }}
</td>
<td>
{{ asset.get_env_display
|default_if_none:""
}}
</td>
</tr>
<tr>
<td
class=
"text-navy"
>
机器状态
</td>
<td>
{{ asset.get_status_display }}
</td>
<td>
{{ asset.get_status_display
|default_if_none:""
}}
</td>
</tr>
<tr>
<td
class=
"text-navy"
>
机柜号
</td>
<td>
{{ asset.cabinet }}
</td>
<td>
{{ asset.cabinet
|default_if_none:""
}}
</td>
</tr>
<tr>
<td
class=
"text-navy"
>
机柜位置
</td>
<td>
{{ asset.position }}
</td>
<td>
{{ asset.position
|default_if_none:""
}}
</td>
</tr>
<tr>
<td
class=
"text-navy"
>
激活
</td>
...
...
@@ -149,7 +149,7 @@
</tr>
<tr>
<td
class=
"text-navy"
>
备注
</td>
<td>
{{ asset.comment }}
</td>
<td>
{{ asset.comment
|default_if_none:""
}}
</td>
</tr>
</table>
</div>
...
...
templates/jasset/asset_list.html
View file @
d42197db
...
...
@@ -119,12 +119,12 @@
<td
class=
"text-center"
name=
"id"
value=
"{{ asset.id }}"
data-editable=
'false'
>
<input
name=
"id"
value=
"{{ asset.id }}"
type=
"checkbox"
class=
"i-checks"
>
</td>
<td
class=
"text-center"
>
{{ asset.ip }}
</td>
<td
class=
"text-center"
>
{{ asset.hostname }}
</td>
<td
class=
"text-center"
>
{{ asset.idc.name }}
</td>
<td
class=
"text-center"
>
{{ asset.ip
|default_if_none:""
}}
</td>
<td
class=
"text-center"
>
{{ asset.hostname
|default_if_none:""
}}
</td>
<td
class=
"text-center"
>
{{ asset.idc.name
|default_if_none:""
}}
</td>
<td
class=
"text-center"
>
{{ asset.group.all|group_str2 }}
</td>
{#
<td
class=
"text-center"
>
{{ asset.cpu }}|{{ asset.memory }}|{{ asset.disk }}
</td>
#}
<td
class=
"text-center"
>
{{ asset.system_type
}}{{ asset.system_version
}}
</td>
<td
class=
"text-center"
>
{{ asset.system_type
|default_if_none:"" }}{{ asset.system_version|default_if_none:""
}}
</td>
<td
class=
"text-center"
>
{{ asset.use_default_auth|bool2str }}
</td>
<td
class=
"text-center"
data-editable=
'false'
>
<a
href=
"/jasset/asset_detail/?id={{ asset.id }}"
class=
"btn btn-xs btn-primary"
>
详情
</a>
...
...
templates/jasset/group_add.html
View file @
d42197db
...
...
@@ -75,12 +75,12 @@
<div
class=
"form-group"
>
<label
for=
""
class=
"col-sm-2 control-label"
>
主机
<
span
class=
"red-fonts"
>
*
</span><
/label>
<label
for=
""
class=
"col-sm-2 control-label"
>
主机
</label>
<div
class=
"col-sm-4"
>
<div>
<select
id=
"assets"
name=
"assets"
class=
"form-control m-b"
size=
"12"
multiple
>
{% for asset in asset_all %}
<option
value=
"{{ asset.id }}"
>
{{ asset.
ip
}}
</option>
<option
value=
"{{ asset.id }}"
>
{{ asset.
hostname|default_if_none:"" }} - {{ asset.ip|default_if_none:"" }} - {{ asset.port|default_if_none:""
}}
</option>
{% endfor %}
</select>
</div>
...
...
@@ -133,12 +133,12 @@
timely
:
2
,
theme
:
"yellow_right_effect"
,
fields
:
{
"
j_group
"
:
{
"
name
"
:
{
rule
:
"required"
,
tip
:
"输入
业务
组名"
,
tip
:
"输入
主机
组名"
,
ok
:
""
,
msg
:
{
required
:
"
业务
组名必须填写!"
},
data
:
{
'data-ok'
:
"
业务
组名可以使用"
}
msg
:
{
required
:
"
主机
组名必须填写!"
},
data
:
{
'data-ok'
:
"
主机
组名可以使用"
}
}
},
valid
:
function
(
form
)
{
...
...
templates/jasset/group_detail.html
View file @
d42197db
...
...
@@ -52,17 +52,17 @@
<tbody>
{% for asset in contacts.object_list %}
<tr
class=
"gradeX"
>
<td
class=
"text-center"
name=
"j_id"
value=
"{{ asset.id }}"
data-editable=
'false'
><input
name=
"id"
value=
"{{ asset.id }}"
type=
"checkbox"
class=
"i-checks"
></td>
<td
class=
"text-center"
name=
"j_ip"
>
{{ asset.ip }}
</td>
<td
class=
"text-center"
name=
"j_port"
>
{{ asset.port }}
</td>
<td
class=
"text-center"
name=
"j_idc"
>
{{ asset.idc.name }}
</td>
<td
class=
"text-center"
name=
"j_id"
value=
"{{ asset.id
|default_if_none:"
"
}}"
data-editable=
'false'
><input
name=
"id"
value=
"{{ asset.id }}"
type=
"checkbox"
class=
"i-checks"
></td>
<td
class=
"text-center"
name=
"j_ip"
>
{{ asset.ip
|default_if_none:""
}}
</td>
<td
class=
"text-center"
name=
"j_port"
>
{{ asset.port
|default_if_none:""
}}
</td>
<td
class=
"text-center"
name=
"j_idc"
>
{{ asset.idc.name
|default_if_none:""
}}
</td>
<td
class=
"text-center"
name=
"j_group"
>
{{ asset.bis_group.all | group_str2 }}
</td>
<td
class=
"text-center"
name=
"j_active"
>
{{ asset.is_active|bool2str }}
</td>
<td
class=
"text-center"
>
{{ asset.date_added|date:"Y-m-d H:i:s" }}
</td>
<td
class=
"text-center"
name=
"j_comment"
>
{{ asset.comment }}
</td>
<td
class=
"text-center"
name=
"j_comment"
>
{{ asset.comment
|default_if_none:""
}}
</td>
<td
class=
"text-center"
data-editable=
'false'
>
<a
href=
"/jasset/
hos
t_detail/?id={{ asset.id }}"
class=
"iframe btn btn-xs btn-primary"
>
详情
</a>
<a
href=
"/jasset/
hos
t_edit/?id={{ asset.id }}"
class=
"btn btn-xs btn-info"
>
编辑
</a>
<a
href=
"/jasset/
asse
t_detail/?id={{ asset.id }}"
class=
"iframe btn btn-xs btn-primary"
>
详情
</a>
<a
href=
"/jasset/
asse
t_edit/?id={{ asset.id }}"
class=
"btn btn-xs btn-info"
>
编辑
</a>
<a
href=
"/jasset/group_del_host/?id={{ asset.id }}&gid={{ group.id }}"
class=
"btn btn-xs btn-danger"
>
删除
</a>
</td>
</tr>
...
...
templates/jasset/group_edit.html
View file @
d42197db
...
...
@@ -86,7 +86,7 @@
<div>
<select
id=
"assets"
name=
"assets"
class=
"form-control m-b"
size=
"12"
multiple
>
{% for asset in asset_no_select %}
<option
value=
"{{ asset.id }}"
>
{{ asset.
ip
}}
</option>
<option
value=
"{{ asset.id }}"
>
{{ asset.
hostname|default_if_none:"" }} - {{ asset.ip|default_if_none:"" }} - {{ asset.port|default_if_none:""
}}
</option>
{% endfor %}
</select>
</div>
...
...
@@ -103,7 +103,7 @@
<div>
<select
id=
"asset_select"
name=
"asset_select"
class=
"form-control m-b"
size=
"12"
multiple
>
{% for asset in asset_select %}
<option
value=
"{{ asset.id }}"
>
{{ asset.
ip
}}
</option>
<option
value=
"{{ asset.id }}"
>
{{ asset.
hostname|default_if_none:"" }} - {{ asset.ip|default_if_none:"" }} - {{ asset.port|default_if_none:""
}}
</option>
{% endfor %}
</select>
</div>
...
...
templates/nav.html
View file @
d42197db
...
...
@@ -76,7 +76,7 @@
<a><i
class=
"fa fa-cube"
></i>
<span
class=
"nav-label"
>
资产管理
</span><span
class=
"fa arrow"
></span></a>
<ul
class=
"nav nav-second-level"
>
{#
<li
class=
"host_add host_add_multi"
><a
href=
"/jasset/host_add/"
>
添加资产
</a></li>
#}
<li
class=
"
host_list host_detail hos
t_edit"
><a
href=
"/jasset/asset_list/"
>
查看资产
<span
class=
"label label-info pull-right"
>
{{ host_active_num }}/{{ host_total_num}}
</span></a></li>
<li
class=
"
asset_list asset_detail asse
t_edit"
><a
href=
"/jasset/asset_list/"
>
查看资产
<span
class=
"label label-info pull-right"
>
{{ host_active_num }}/{{ host_total_num}}
</span></a></li>
<li
class=
"idc_list idc_detail idc_edit"
><a
href=
"/jasset/idc_list/"
>
查看IDC
</a></li>
<li
class=
"group_add"
><a
href=
"/jasset/group_add/"
>
添加主机组
</a></li>
<li
class=
"group_list group_detail group_edit"
><a
href=
"/jasset/group_list/"
>
查看主机组
</a></li>
...
...
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