mirror of https://github.com/jumpserver/jumpserver
fix bugs
parent
652ea98a2b
commit
d25e23623a
|
@ -359,7 +359,6 @@ def ansible_record(asset, ansible_dic, username):
|
|||
old = asset_dic.get(field)
|
||||
new = ansible_dic.get(field)
|
||||
if unicode(old) != unicode(new):
|
||||
print old, new, type(old), type(new)
|
||||
setattr(asset, field, value)
|
||||
asset.save()
|
||||
alert_dic[field] = [old, new]
|
||||
|
@ -384,16 +383,17 @@ def excel_to_db(excel_file):
|
|||
row = table.row_values(row_num)
|
||||
if row:
|
||||
ip, port, hostname, use_default_auth, username, password, group = row
|
||||
use_default_auth = 1 if use_default_auth == u'默认' else 0
|
||||
if get_object(Asset, hostname=hostname):
|
||||
continue
|
||||
use_default_auth = 1 if use_default_auth == u'默认' else 0
|
||||
password_encode = CRYPTOR.encrypt(password) if password else ''
|
||||
if hostname:
|
||||
asset = Asset(ip=ip,
|
||||
port=port,
|
||||
hostname=hostname,
|
||||
use_default_auth=use_default_auth,
|
||||
username=username,
|
||||
password=password
|
||||
password=password_encode
|
||||
)
|
||||
asset.save()
|
||||
group_list = group.split('/')
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
# coding:utf-8
|
||||
|
||||
import ast
|
||||
from django.db.models import Q
|
||||
from jasset.asset_api import *
|
||||
from jumpserver.api import *
|
||||
|
@ -95,8 +94,6 @@ def group_list(request):
|
|||
"""
|
||||
header_title, path1, path2 = u'查看资产组', u'资产管理', u'查看资产组'
|
||||
keyword = request.GET.get('keyword', '')
|
||||
gid = request.GET.get('gid')
|
||||
sid = request.GET.get('sid')
|
||||
asset_group_list = AssetGroup.objects.all()
|
||||
|
||||
if keyword:
|
||||
|
@ -211,6 +208,7 @@ def asset_edit(request):
|
|||
ip = request.POST.get('ip', '')
|
||||
hostname = request.POST.get('hostname', '')
|
||||
password = request.POST.get('password', '')
|
||||
is_active = True if request.POST.get('is_active') == '1' else False
|
||||
use_default_auth = request.POST.get('use_default_auth', '')
|
||||
|
||||
try:
|
||||
|
@ -230,6 +228,7 @@ def asset_edit(request):
|
|||
if password_old != password:
|
||||
password_encode = CRYPTOR.encrypt(password)
|
||||
af_save.password = password_encode
|
||||
af_save.is_active = True if is_active else False
|
||||
af_save.save()
|
||||
af_post.save_m2m()
|
||||
# asset_new = get_object(Asset, id=asset_id)
|
||||
|
@ -250,6 +249,7 @@ def asset_list(request):
|
|||
"""
|
||||
asset list view
|
||||
"""
|
||||
header_title, path1, path2 = u'查看资产', u'资产管理', u'查看资产'
|
||||
idc_all = IDC.objects.filter()
|
||||
asset_group_all = AssetGroup.objects.all()
|
||||
asset_types = ASSET_TYPE
|
||||
|
@ -382,9 +382,8 @@ def asset_edit_batch(request):
|
|||
asset.save()
|
||||
|
||||
if alert_list:
|
||||
username = unicode(name) + ' - ' + u'批量'
|
||||
print alert_list
|
||||
AssetRecord.objects.create(asset=asset, username=username, content=alert_list)
|
||||
recode_name = unicode(name) + ' - ' + u'批量'
|
||||
AssetRecord.objects.create(asset=asset, username=recode_name, content=alert_list)
|
||||
return HttpResponse('ok')
|
||||
|
||||
return my_render('jasset/asset_edit_batch.html', locals(), request)
|
||||
|
@ -410,21 +409,21 @@ def asset_update(request):
|
|||
"""
|
||||
asset_id = request.GET.get('id', '')
|
||||
asset = get_object(Asset, id=asset_id)
|
||||
name = request.session.get('username', 'admin')
|
||||
if not asset:
|
||||
return HttpResponseRedirect('/jasset/asset_detail/?id=%s' % asset_id)
|
||||
name = request.session.get('username', 'admin')
|
||||
if asset.use_default_auth:
|
||||
default = Setting.objects.all()
|
||||
if default:
|
||||
default = default[0]
|
||||
username = default.default_user
|
||||
password = default.default_password
|
||||
password = CRYPTOR.decrypt(default.default_password)
|
||||
port = default.default_port
|
||||
else:
|
||||
return HttpResponse(u'没有设置默认用户名和密码!')
|
||||
else:
|
||||
username = asset.username
|
||||
password = asset.password
|
||||
password = CRYPTOR.decrypt(asset.password)
|
||||
port = asset.port
|
||||
|
||||
resource = [{"hostname": asset.ip, "port": port,
|
||||
|
@ -436,7 +435,9 @@ def asset_update(request):
|
|||
asset_info = ansible_asset_info['result'][asset.ip]
|
||||
if asset_info:
|
||||
hostname = asset_info.get('hostname')
|
||||
other_ip = ','.join(asset_info.get('other_ip'))
|
||||
all_ip = asset_info.get('other_ip')
|
||||
other_ip_list = all_ip.remove(asset.ip) if asset.ip in all_ip else []
|
||||
other_ip = ','.join(other_ip_list) if other_ip_list else ''
|
||||
cpu_type = asset_info.get('cpu_type')[1]
|
||||
cpu_cores = asset_info.get('cpu_cores')
|
||||
cpu = cpu_type + ' * ' + unicode(cpu_cores)
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -29,14 +29,14 @@
|
|||
<div>
|
||||
<div class="text-left">
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td class="text-navy">IP</td>
|
||||
<td>{{ asset.ip|default_if_none:"" }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-navy">主机名</td>
|
||||
<td>{{ asset.hostname|default_if_none:"" }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-navy">IP</td>
|
||||
<td>{{ asset.ip|default_if_none:"" }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-navy">其他IP</td>
|
||||
<td>
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
<div class="hr-line-dashed"></div>
|
||||
<label class="col-sm-2 control-label"> 端口<span class="red-fonts">*</span> </label>
|
||||
<div class="col-sm-8">
|
||||
<input type="text" placeholder="Port" value="{{ asset.port }}" name="port" class="form-control">
|
||||
<input type="text" placeholder="Port" value="{{ asset.port|default_if_none:"" }}" name="port" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -142,6 +142,7 @@
|
|||
<div class="col-sm-6">
|
||||
<input type="button" id="asset_del" class="btn btn-danger btn-sm" name="del_button" value="删除"/>
|
||||
<a value="/jasset/asset_edit_batch/" type="button" class="btn btn-sm btn-warning iframe">修改</a>
|
||||
<a value="/jasset/asset_update_batch/" type="button" class="btn btn-sm btn-info">更新</a>
|
||||
</div>
|
||||
{% include 'paginator.html' %}
|
||||
</div>
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
<div class="ibox-content">
|
||||
<div class="">
|
||||
<a target="_blank" href="/jasset/idc_add" class="btn btn-sm btn-primary "> 添加IDC </a>
|
||||
<input type="button" id="del_check" class="btn btn-danger btn-sm" name="del_button" value="删除所选"/>
|
||||
<form id="search_form" method="get" action="" class="pull-right mail-search">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control input-sm" id="search_input" name="keyword" placeholder="Search">
|
||||
|
@ -78,10 +79,9 @@
|
|||
</table>
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
{% ifequal session_role_id 2 %}
|
||||
<input type="button" id="del_check" class="btn btn-danger btn-sm" name="del_button" value="删除"/>
|
||||
<!--<input type="button" id="alter_button" class="btn btn-warning btn-sm" name="alter_button" value="修改" onclick="alter('contents_form')" />-->
|
||||
{% endifequal %}
|
||||
<div class="dataTables_info" id="editable_info" role="status" aria-live="polite">
|
||||
Showing {{ contacts.start_index }} to {{ contacts.end_index }} of {{ p.count }} entries
|
||||
</div>
|
||||
</div>
|
||||
{% include 'paginator.html' %}
|
||||
</div>
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
<script>
|
||||
$(".iframe_user").on('click', function(){
|
||||
var url= $(this).attr("value");
|
||||
$.layer({
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '个人信息',
|
||||
maxmin: true,
|
||||
|
@ -45,7 +45,7 @@
|
|||
shade: [0.5, '#000000'],
|
||||
shadeClose: true,
|
||||
area : ['800px' , '600px'],
|
||||
iframe: {src: url}
|
||||
content: url
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue