mirror of https://github.com/jumpserver/jumpserver
merge with wangyong
commit
3d1df73a99
|
@ -5,15 +5,18 @@ from jasset.views import *
|
||||||
urlpatterns = patterns('',
|
urlpatterns = patterns('',
|
||||||
url(r'^$', index),
|
url(r'^$', index),
|
||||||
url(r'^host_add/$', jadd_host),
|
url(r'^host_add/$', jadd_host),
|
||||||
|
url(r'^host_add_multi/$', jadd_host_multi),
|
||||||
url(r'^host_list/$', jlist_host),
|
url(r'^host_list/$', jlist_host),
|
||||||
url(r"^(\d+.\d+.\d+.\d+)/$",jlist_ip),
|
url(r"^(\d+.\d+.\d+.\d+)/$",jlist_ip),
|
||||||
url(r'^idc_add/$', jadd_idc),
|
url(r'^idc_add/$', jadd_idc),
|
||||||
url(r'^idc_list/$', jlist_idc),
|
url(r'^idc_list/$', jlist_idc),
|
||||||
|
url(r'^idc_detail/(\d+)$', idc_detail),
|
||||||
url(r'^idc_del/(\d+)/$', idc_del),
|
url(r'^idc_del/(\d+)/$', idc_del),
|
||||||
url(r'^group_add/$', jadd_group),
|
url(r'^group_add/$', jadd_group),
|
||||||
url(r'^group_list/$', jlist_group),
|
url(r'^group_list/$', jlist_group),
|
||||||
|
url(r'^group_detail/(\d)/$', group_detail),
|
||||||
url(r'^group_del/(\d+)/$', group_del),
|
url(r'^group_del/(\d+)/$', group_del),
|
||||||
url(r'^host_del/(\d+)/$', host_del),
|
url(r'^host_del/(\w+)/$', host_del),
|
||||||
url(r'^host_edit/(\d+)$', host_edit),
|
url(r'^host_edit/(\d+)$', host_edit),
|
||||||
url(r'^host_edit/batch/$', batch_host_edit),
|
url(r'^host_edit/batch/$', batch_host_edit),
|
||||||
url(r'^test/$', test),
|
url(r'^test/$', test),
|
||||||
|
|
149
jasset/views.py
149
jasset/views.py
|
@ -8,7 +8,6 @@ from models import IDC, Asset, BisGroup
|
||||||
from juser.models import UserGroup
|
from juser.models import UserGroup
|
||||||
from connect import PyCrypt, KEY
|
from connect import PyCrypt, KEY
|
||||||
from jumpserver.views import jasset_group_add, jasset_host_edit
|
from jumpserver.views import jasset_group_add, jasset_host_edit
|
||||||
from jperm.models import Perm
|
|
||||||
|
|
||||||
cryptor = PyCrypt(KEY)
|
cryptor = PyCrypt(KEY)
|
||||||
|
|
||||||
|
@ -35,27 +34,25 @@ def jadd_host(request):
|
||||||
j_comment = request.POST.get('j_comment')
|
j_comment = request.POST.get('j_comment')
|
||||||
j_idc = IDC.objects.get(name=j_idc)
|
j_idc = IDC.objects.get(name=j_idc)
|
||||||
|
|
||||||
|
all_group = BisGroup.objects.get(name='ALL')
|
||||||
for group in j_group:
|
for group in j_group:
|
||||||
c = BisGroup.objects.get(name=group)
|
c = BisGroup.objects.get(name=group)
|
||||||
groups.append(c)
|
groups.append(c)
|
||||||
|
groups.append(all_group)
|
||||||
|
|
||||||
if Asset.objects.filter(ip=str(j_ip)):
|
if Asset.objects.filter(ip=str(j_ip)):
|
||||||
emg = u'该IP已存在!'
|
emg = u'该IP %s 已存在!' %j_ip
|
||||||
return render_to_response('jasset/host_add.html', locals(), context_instance=RequestContext(request))
|
return render_to_response('jasset/host_add.html', locals(), context_instance=RequestContext(request))
|
||||||
|
|
||||||
if j_type == 'M':
|
if j_type == 'M':
|
||||||
j_user = request.POST.get('j_user')
|
j_user = request.POST.get('j_user')
|
||||||
j_password = cryptor.encrypt(request.POST.get('j_password'))
|
j_password = cryptor.encrypt(request.POST.get('j_password'))
|
||||||
j_root = request.POST.get('j_root')
|
|
||||||
j_passwd = cryptor.encrypt(request.POST.get('j_passwd'))
|
|
||||||
a = Asset(ip=j_ip, port=j_port,
|
a = Asset(ip=j_ip, port=j_port,
|
||||||
login_type=j_type, idc=j_idc,
|
login_type=j_type, idc=j_idc,
|
||||||
is_active=int(j_active),
|
is_active=int(j_active),
|
||||||
comment=j_comment,
|
comment=j_comment,
|
||||||
username_common=j_user,
|
username_common=j_user,
|
||||||
password_common=j_password,
|
password_common=j_password)
|
||||||
username_super=j_root,
|
|
||||||
password_super=j_passwd,)
|
|
||||||
else:
|
else:
|
||||||
a = Asset(ip=j_ip, port=j_port,
|
a = Asset(ip=j_ip, port=j_port,
|
||||||
login_type=j_type, idc=j_idc,
|
login_type=j_type, idc=j_idc,
|
||||||
|
@ -66,13 +63,63 @@ def jadd_host(request):
|
||||||
a.bis_group = groups
|
a.bis_group = groups
|
||||||
a.save()
|
a.save()
|
||||||
smg = u'主机 %s 添加成功' %j_ip
|
smg = u'主机 %s 添加成功' %j_ip
|
||||||
|
|
||||||
return render_to_response('jasset/host_add.html', locals(), context_instance=RequestContext(request))
|
return render_to_response('jasset/host_add.html', locals(), context_instance=RequestContext(request))
|
||||||
|
|
||||||
|
|
||||||
|
def jadd_host_multi(request):
|
||||||
|
header_title, path1, path2 = u'批量添加主机 | Add Hosts', u'资产管理', u'批量添加主机'
|
||||||
|
login_types = {'LDAP': 'L', 'SSH_KEY': 'S', 'PASSWORD': 'P', 'MAP': 'M'}
|
||||||
|
if request.method == 'POST':
|
||||||
|
multi_hosts = request.POST.get('j_multi').split('\n')
|
||||||
|
for host in multi_hosts:
|
||||||
|
if host == '':
|
||||||
|
break
|
||||||
|
groups = []
|
||||||
|
j_ip, j_port, j_type, j_idc, j_group, j_user_group, j_active, j_comment = host.split()
|
||||||
|
j_idc = IDC.objects.get(name=j_idc)
|
||||||
|
j_type = login_types[j_type]
|
||||||
|
all_group = BisGroup.objects.get(name='ALL')
|
||||||
|
j_group = j_group.split(',')
|
||||||
|
for group in j_group:
|
||||||
|
g = group.strip('[]')
|
||||||
|
print g
|
||||||
|
c = BisGroup.objects.get(name=g)
|
||||||
|
groups.append(c)
|
||||||
|
groups.append(all_group)
|
||||||
|
|
||||||
|
if Asset.objects.filter(ip=str(j_ip)):
|
||||||
|
emg = u'该IP %s 已存在!' %j_ip
|
||||||
|
return render_to_response('jasset/host_add_multi.html', locals(), context_instance=RequestContext(request))
|
||||||
|
|
||||||
|
if j_type == 'M':
|
||||||
|
j_user = request.POST.get('j_user')
|
||||||
|
j_password = cryptor.encrypt(request.POST.get('j_password'))
|
||||||
|
a = Asset(ip=j_ip, port=j_port,
|
||||||
|
login_type=j_type, idc=j_idc,
|
||||||
|
is_active=int(j_active),
|
||||||
|
comment=j_comment,
|
||||||
|
username_common=j_user,
|
||||||
|
password_common=j_password)
|
||||||
|
else:
|
||||||
|
a = Asset(ip=j_ip, port=j_port,
|
||||||
|
login_type=j_type, idc=j_idc,
|
||||||
|
is_active=int(j_active),
|
||||||
|
comment=j_comment)
|
||||||
|
jasset_group_add(j_ip, j_ip, 'P')
|
||||||
|
a.save()
|
||||||
|
a.bis_group = groups
|
||||||
|
a.save()
|
||||||
|
smg = u'批量添加添加成功'
|
||||||
|
return HttpResponseRedirect('/jasset/host_list/')
|
||||||
|
return render_to_response('jasset/host_add_multi.html', locals(), context_instance=RequestContext(request))
|
||||||
|
|
||||||
|
|
||||||
def batch_host_edit(request):
|
def batch_host_edit(request):
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
len_table = request.POST.get('len_table')
|
len_table = request.POST.get('len_table')
|
||||||
print len_table
|
|
||||||
for i in range(int(len_table)):
|
for i in range(int(len_table)):
|
||||||
|
j_id = "editable["+str(i)+"][j_id]"
|
||||||
j_ip = "editable["+str(i)+"][j_ip]"
|
j_ip = "editable["+str(i)+"][j_ip]"
|
||||||
j_port = "editable["+str(i)+"][j_port]"
|
j_port = "editable["+str(i)+"][j_port]"
|
||||||
j_idc = "editable["+str(i)+"][j_idc]"
|
j_idc = "editable["+str(i)+"][j_idc]"
|
||||||
|
@ -81,6 +128,7 @@ def batch_host_edit(request):
|
||||||
j_active = "editable["+str(i)+"][j_active]"
|
j_active = "editable["+str(i)+"][j_active]"
|
||||||
j_comment = "editable["+str(i)+"][j_comment]"
|
j_comment = "editable["+str(i)+"][j_comment]"
|
||||||
|
|
||||||
|
j_id = request.POST.get(j_id).strip()
|
||||||
j_ip = request.POST.get(j_ip).strip()
|
j_ip = request.POST.get(j_ip).strip()
|
||||||
j_port = request.POST.get(j_port).strip()
|
j_port = request.POST.get(j_port).strip()
|
||||||
j_idc = request.POST.get(j_idc).strip()
|
j_idc = request.POST.get(j_idc).strip()
|
||||||
|
@ -90,7 +138,7 @@ def batch_host_edit(request):
|
||||||
j_comment = request.POST.get(j_comment).strip()
|
j_comment = request.POST.get(j_comment).strip()
|
||||||
print j_ip
|
print j_ip
|
||||||
|
|
||||||
jasset_host_edit(j_ip, j_idc, j_port, j_type, j_group, j_active, j_comment)
|
jasset_host_edit(j_id, j_ip, j_idc, j_port, j_type, j_group, j_active, j_comment)
|
||||||
|
|
||||||
return render_to_response('jasset/host_list.html')
|
return render_to_response('jasset/host_list.html')
|
||||||
|
|
||||||
|
@ -100,7 +148,7 @@ def jlist_host(request):
|
||||||
login_types = {'L': 'LDAP', 'S': 'SSH_KEY', 'P': 'PASSWORD', 'M': 'MAP'}
|
login_types = {'L': 'LDAP', 'S': 'SSH_KEY', 'P': 'PASSWORD', 'M': 'MAP'}
|
||||||
posts = contact_list = Asset.objects.all().order_by('ip')
|
posts = contact_list = Asset.objects.all().order_by('ip')
|
||||||
print posts
|
print posts
|
||||||
p = paginator = Paginator(contact_list, 5)
|
p = paginator = Paginator(contact_list, 20)
|
||||||
try:
|
try:
|
||||||
page = int(request.GET.get('page', '1'))
|
page = int(request.GET.get('page', '1'))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
@ -113,16 +161,23 @@ def jlist_host(request):
|
||||||
|
|
||||||
return render_to_response('jasset/host_list.html', locals(), context_instance=RequestContext(request))
|
return render_to_response('jasset/host_list.html', locals(), context_instance=RequestContext(request))
|
||||||
|
|
||||||
|
|
||||||
def host_del(request, offset):
|
def host_del(request, offset):
|
||||||
len_list = request.POST.get("len_list")
|
print offset
|
||||||
for i in range(int(len_list)):
|
if offset == 'multi':
|
||||||
key = "id_list["+str(i)+"]"
|
len_list = request.POST.get("len_list")
|
||||||
print key
|
for i in range(int(len_list)):
|
||||||
jid = request.POST.get(key)
|
key = "id_list["+str(i)+"]"
|
||||||
print jid
|
print key
|
||||||
|
jid = request.POST.get(key)
|
||||||
|
print jid
|
||||||
|
Asset.objects.filter(id=jid).delete()
|
||||||
|
else:
|
||||||
|
jid = int(offset)
|
||||||
Asset.objects.filter(id=jid).delete()
|
Asset.objects.filter(id=jid).delete()
|
||||||
return HttpResponseRedirect('/jasset/host_list/')
|
return HttpResponseRedirect('/jasset/host_list/')
|
||||||
|
|
||||||
|
|
||||||
def host_edit(request, offset):
|
def host_edit(request, offset):
|
||||||
actives = {1: u'激活', 0: u'禁用'}
|
actives = {1: u'激活', 0: u'禁用'}
|
||||||
login_types = {'L': 'LDAP', 'S': 'SSH_KEY', 'P': 'PASSWORD', 'M': 'MAP'}
|
login_types = {'L': 'LDAP', 'S': 'SSH_KEY', 'P': 'PASSWORD', 'M': 'MAP'}
|
||||||
|
@ -132,7 +187,7 @@ def host_edit(request, offset):
|
||||||
egroup = BisGroup.objects.filter(type='A')
|
egroup = BisGroup.objects.filter(type='A')
|
||||||
for g in Asset.objects.get(id=int(offset)).bis_group.all():
|
for g in Asset.objects.get(id=int(offset)).bis_group.all():
|
||||||
e_group.append(g)
|
e_group.append(g)
|
||||||
post = Asset.objects.get(id = int(offset))
|
post = Asset.objects.get(id=int(offset))
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
j_ip = request.POST.get('j_ip')
|
j_ip = request.POST.get('j_ip')
|
||||||
j_idc = request.POST.get('j_idc')
|
j_idc = request.POST.get('j_idc')
|
||||||
|
@ -142,27 +197,24 @@ def host_edit(request, offset):
|
||||||
j_active = request.POST.get('j_active')
|
j_active = request.POST.get('j_active')
|
||||||
j_comment = request.POST.get('j_comment')
|
j_comment = request.POST.get('j_comment')
|
||||||
j_idc = IDC.objects.get(name=j_idc)
|
j_idc = IDC.objects.get(name=j_idc)
|
||||||
|
print j_group
|
||||||
for group in j_group:
|
for group in j_group:
|
||||||
c = BisGroup.objects.get(name=group)
|
c = BisGroup.objects.get(name=group)
|
||||||
groups.append(c)
|
groups.append(c)
|
||||||
|
|
||||||
a = Asset.objects.get(ip=int(offset))
|
a = Asset.objects.get(id=int(offset))
|
||||||
|
|
||||||
if j_type == 'M':
|
if j_type == 'M':
|
||||||
j_user = request.POST.get('j_user')
|
j_user = request.POST.get('j_user')
|
||||||
j_password = cryptor.encrypt(request.POST.get('j_password'))
|
j_password = cryptor.encrypt(request.POST.get('j_password'))
|
||||||
j_root = request.POST.get('j_root')
|
|
||||||
j_passwd = cryptor.encrypt(request.POST.get('j_passwd'))
|
|
||||||
a.ip = j_ip
|
a.ip = j_ip
|
||||||
a.port = j_port
|
a.port = j_port
|
||||||
a.login_type = j_type
|
a.login_type = j_type
|
||||||
a.idc = j_idc
|
a.idc = j_idc
|
||||||
a.is_active = j_active
|
a.is_active = j_active
|
||||||
a.comment = j_comment
|
a.comment = j_comment
|
||||||
a.username_common = j_user
|
a.username = j_user
|
||||||
a.password_common = j_password
|
a.password = j_password
|
||||||
a.username_super = j_root
|
|
||||||
a.password_super = j_passwd
|
|
||||||
else:
|
else:
|
||||||
a.ip = j_ip
|
a.ip = j_ip
|
||||||
a.port = j_port
|
a.port = j_port
|
||||||
|
@ -183,9 +235,10 @@ def host_edit(request, offset):
|
||||||
def jlist_ip(request, offset):
|
def jlist_ip(request, offset):
|
||||||
header_title, path1, path2 = u'主机详细信息 | Host Detail.', u'资产管理', u'主机详情'
|
header_title, path1, path2 = u'主机详细信息 | Host Detail.', u'资产管理', u'主机详情'
|
||||||
print offset
|
print offset
|
||||||
post = contact_list = Asset.objects.get(ip = str(offset))
|
post = contact_list = Asset.objects.get(ip=str(offset))
|
||||||
return render_to_response('jasset/jlist_ip.html', locals(), context_instance=RequestContext(request))
|
return render_to_response('jasset/jlist_ip.html', locals(), context_instance=RequestContext(request))
|
||||||
|
|
||||||
|
|
||||||
def jadd_idc(request):
|
def jadd_idc(request):
|
||||||
header_title, path1, path2 = u'添加IDC | Add IDC', u'资产管理', u'添加IDC'
|
header_title, path1, path2 = u'添加IDC | Add IDC', u'资产管理', u'添加IDC'
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
|
@ -204,14 +257,16 @@ def jadd_idc(request):
|
||||||
|
|
||||||
|
|
||||||
def jlist_idc(request):
|
def jlist_idc(request):
|
||||||
header_title, path1, path2 = u'查看IDC | List Host', u'资产管理', u'查看IDC'
|
header_title, path1, path2 = u'查看IDC | List IDC', u'资产管理', u'查看IDC'
|
||||||
posts = IDC.objects.all().order_by('id')
|
posts = IDC.objects.all().order_by('id')
|
||||||
return render_to_response('jasset/idc_list.html', locals(), context_instance=RequestContext(request))
|
return render_to_response('jasset/idc_list.html', locals(), context_instance=RequestContext(request))
|
||||||
|
|
||||||
|
|
||||||
def idc_del(request, offset):
|
def idc_del(request, offset):
|
||||||
IDC.objects.filter(id=offset).delete()
|
IDC.objects.filter(id=offset).delete()
|
||||||
return HttpResponseRedirect('/jasset/idc_list/')
|
return HttpResponseRedirect('/jasset/idc_list/')
|
||||||
|
|
||||||
|
|
||||||
def jadd_group(request):
|
def jadd_group(request):
|
||||||
header_title, path1, path2 = u'添加主机组 | Add Group', u'资产管理', u'添加主机组'
|
header_title, path1, path2 = u'添加主机组 | Add Group', u'资产管理', u'添加主机组'
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
|
@ -229,13 +284,53 @@ def jadd_group(request):
|
||||||
|
|
||||||
|
|
||||||
def jlist_group(request):
|
def jlist_group(request):
|
||||||
header_title, path1, path2 = u'查看业务组 | Add Group', u'资产管理', u'查看业务组'
|
header_title, path1, path2 = u'查看主机组 | List Group', u'资产管理', u'查看主机组'
|
||||||
posts = BisGroup.objects.filter(type='A').order_by('id')
|
posts = BisGroup.objects.filter(type='A').order_by('id')
|
||||||
return render_to_response('jasset/group_list.html', locals(), context_instance=RequestContext(request))
|
return render_to_response('jasset/group_list.html', locals(), context_instance=RequestContext(request))
|
||||||
|
|
||||||
|
|
||||||
|
def group_detail(request, offset):
|
||||||
|
header_title, path1, path2 = u'主机组详情 | Group Detail', u'资产管理', u'主机组详情'
|
||||||
|
login_types = {'L': 'LDAP', 'S': 'SSH_KEY', 'P': 'PASSWORD', 'M': 'MAP'}
|
||||||
|
group_name = BisGroup.objects.get(id=offset).name
|
||||||
|
b = BisGroup.objects.get(id=offset)
|
||||||
|
posts = contact_list = Asset.objects.filter(bis_group=b).order_by('ip')
|
||||||
|
p = paginator = Paginator(contact_list, 5)
|
||||||
|
try:
|
||||||
|
page = int(request.GET.get('page', '1'))
|
||||||
|
except ValueError:
|
||||||
|
page = 1
|
||||||
|
|
||||||
|
try:
|
||||||
|
contacts = paginator.page(page)
|
||||||
|
except (EmptyPage, InvalidPage):
|
||||||
|
contacts = paginator.page(paginator.num_pages)
|
||||||
|
return render_to_response('jasset/group_detail.html', locals(), context_instance=RequestContext(request))
|
||||||
|
|
||||||
|
|
||||||
|
def idc_detail(request, offset):
|
||||||
|
header_title, path1, path2 = u'主机组详情 | Group Detail', u'资产管理', u'主机组详情'
|
||||||
|
login_types = {'L': 'LDAP', 'S': 'SSH_KEY', 'P': 'PASSWORD', 'M': 'MAP'}
|
||||||
|
idc_name = IDC.objects.get(id=offset).name
|
||||||
|
b = IDC.objects.get(id=offset)
|
||||||
|
posts = contact_list = Asset.objects.filter(idc=b).order_by('ip')
|
||||||
|
p = paginator = Paginator(contact_list, 5)
|
||||||
|
try:
|
||||||
|
page = int(request.GET.get('page', '1'))
|
||||||
|
except ValueError:
|
||||||
|
page = 1
|
||||||
|
|
||||||
|
try:
|
||||||
|
contacts = paginator.page(page)
|
||||||
|
except (EmptyPage, InvalidPage):
|
||||||
|
contacts = paginator.page(paginator.num_pages)
|
||||||
|
return render_to_response('jasset/idc_detail.html', locals(), context_instance=RequestContext(request))
|
||||||
|
|
||||||
|
|
||||||
def group_del(request, offset):
|
def group_del(request, offset):
|
||||||
BisGroup.objects.filter(id=offset).delete()
|
BisGroup.objects.filter(id=offset).delete()
|
||||||
return HttpResponseRedirect('/jasset/group_list/')
|
return HttpResponseRedirect('/jasset/group_list/')
|
||||||
|
|
||||||
|
|
||||||
def test(request):
|
def test(request):
|
||||||
return render_to_response('jasset/test.html', locals())
|
return render_to_response('jasset/test.html', locals())
|
||||||
|
|
|
@ -4,6 +4,6 @@ from jlog.views import *
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
urlpatterns = patterns('',
|
||||||
url(r'^$', jlog_list),
|
url(r'^$', jlog_list),
|
||||||
url(r'^log_list/$', jlog_list),
|
url(r'^log_list/(\w+)/$', jlog_list),
|
||||||
url(r'^log_kill/(\d+)', jlog_kill),
|
url(r'^log_kill/(\d+)', jlog_kill),
|
||||||
)
|
)
|
||||||
|
|
|
@ -13,12 +13,14 @@ from jlog.models import Log
|
||||||
CONF = ConfigParser.ConfigParser()
|
CONF = ConfigParser.ConfigParser()
|
||||||
CONF.read('%s/jumpserver.conf' % BASE_DIR)
|
CONF.read('%s/jumpserver.conf' % BASE_DIR)
|
||||||
|
|
||||||
def jlog_list(request):
|
|
||||||
|
def jlog_list(request, offset='online'):
|
||||||
header_title, path1, path2 = u'查看日志 | Log List.', u'查看日志', u'日志列表'
|
header_title, path1, path2 = u'查看日志 | Log List.', u'查看日志', u'日志列表'
|
||||||
|
web_socket_host = CONF.get('websocket', 'web_socket_host')
|
||||||
online = Log.objects.filter(is_finished=0)
|
online = Log.objects.filter(is_finished=0)
|
||||||
offline = Log.objects.filter(is_finished=1)
|
offline = Log.objects.filter(is_finished=1)
|
||||||
web_socket_host = CONF.get('websocket', 'web_socket_host')
|
|
||||||
return render_to_response('jlog/log_list.html',locals())
|
return render_to_response('jlog/log_list.html', locals())
|
||||||
|
|
||||||
|
|
||||||
def jlog_kill(request, offset):
|
def jlog_kill(request, offset):
|
||||||
|
@ -26,4 +28,4 @@ def jlog_kill(request, offset):
|
||||||
if pid:
|
if pid:
|
||||||
os.kill(int(pid), 9)
|
os.kill(int(pid), 9)
|
||||||
Log.objects.filter(pid=pid).update(is_finished=1, end_time=datetime.now())
|
Log.objects.filter(pid=pid).update(is_finished=1, end_time=datetime.now())
|
||||||
return render_to_response('jlog/log_list.html', locals())
|
return HttpResponseRedirect('jlog/log_list.html', locals())
|
|
@ -5,6 +5,7 @@ from django import template
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from juser.models import User, UserGroup
|
from juser.models import User, UserGroup
|
||||||
from jperm.views import perm_user_asset
|
from jperm.views import perm_user_asset
|
||||||
|
from jasset.models import BisGroup
|
||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
|
||||||
|
@ -85,6 +86,15 @@ def group_type_to_str(type_name):
|
||||||
}
|
}
|
||||||
return group_types.get(type_name)
|
return group_types.get(type_name)
|
||||||
|
|
||||||
|
|
||||||
@register.filter(name='perm_asset_count')
|
@register.filter(name='perm_asset_count')
|
||||||
def perm_asset_count(user_id):
|
def perm_asset_count(user_id):
|
||||||
return len(perm_user_asset(user_id))
|
return len(perm_user_asset(user_id))
|
||||||
|
|
||||||
|
|
||||||
|
@register.filter(name='filter_private')
|
||||||
|
def filter_private(group):
|
||||||
|
agroup = []
|
||||||
|
p = BisGroup.objects.get(name='ALL')
|
||||||
|
[agroup.append(g) for g in group if g != p]
|
||||||
|
return agroup
|
||||||
|
|
|
@ -30,17 +30,23 @@ def jasset_group_add(name, comment, type):
|
||||||
BisGroup.objects.create(name=name, comment=comment, type=type)
|
BisGroup.objects.create(name=name, comment=comment, type=type)
|
||||||
smg = u'业务组%s添加成功' %name
|
smg = u'业务组%s添加成功' %name
|
||||||
|
|
||||||
def jasset_host_edit(j_ip, j_idc, j_port, j_type, j_group, j_active, j_comment):
|
|
||||||
|
def jasset_host_edit(j_id, j_ip, j_idc, j_port, j_type, j_group, j_active, j_comment):
|
||||||
|
print 'ok'
|
||||||
groups = []
|
groups = []
|
||||||
is_active = {u'是': '1', u'否': '2'}
|
is_active = {u'是': '1', u'否': '2'}
|
||||||
login_types = {'LDAP': 'L', 'SSH_KEY': 'S', 'PASSWORD': 'P', 'MAP': 'M'}
|
login_types = {'LDAP': 'L', 'SSH_KEY': 'S', 'PASSWORD': 'P', 'MAP': 'M'}
|
||||||
for group in j_group:
|
for group in j_group[0].split():
|
||||||
|
print group.strip()
|
||||||
c = BisGroup.objects.get(name=group.strip())
|
c = BisGroup.objects.get(name=group.strip())
|
||||||
groups.append(c)
|
groups.append(c)
|
||||||
j_type = login_types[j_type]
|
j_type = login_types[j_type]
|
||||||
|
print j_type
|
||||||
j_idc = IDC.objects.get(name=j_idc)
|
j_idc = IDC.objects.get(name=j_idc)
|
||||||
a = Asset.objects.get(ip=str(j_ip))
|
print j_idc
|
||||||
|
print
|
||||||
|
a = Asset.objects.get(id=j_id)
|
||||||
|
print '123'
|
||||||
if j_type == 'M':
|
if j_type == 'M':
|
||||||
a.ip = j_ip
|
a.ip = j_ip
|
||||||
a.port = j_port
|
a.port = j_port
|
||||||
|
@ -48,10 +54,8 @@ def jasset_host_edit(j_ip, j_idc, j_port, j_type, j_group, j_active, j_comment):
|
||||||
a.idc = j_idc
|
a.idc = j_idc
|
||||||
a.is_active = j_active
|
a.is_active = j_active
|
||||||
a.comment = j_comment
|
a.comment = j_comment
|
||||||
a.username_common = j_user
|
a.username = j_user
|
||||||
a.password_common = j_password
|
a.password = j_password
|
||||||
a.username_super = j_root
|
|
||||||
a.password_super = j_passwd
|
|
||||||
else:
|
else:
|
||||||
a.ip = j_ip
|
a.ip = j_ip
|
||||||
a.port = j_port
|
a.port = j_port
|
||||||
|
@ -59,7 +63,6 @@ def jasset_host_edit(j_ip, j_idc, j_port, j_type, j_group, j_active, j_comment):
|
||||||
a.login_type = j_type
|
a.login_type = j_type
|
||||||
a.is_active = is_active[j_active]
|
a.is_active = is_active[j_active]
|
||||||
a.comment = j_comment
|
a.comment = j_comment
|
||||||
|
|
||||||
a.save()
|
a.save()
|
||||||
a.bis_group = groups
|
a.bis_group = groups
|
||||||
a.save()
|
a.save()
|
||||||
|
|
|
@ -1,48 +1,54 @@
|
||||||
<script src="/static/js/jquery-2.1.1.js"></script>
|
<script src="/static/js/jquery-2.1.1.js"></script>
|
||||||
<script src="/static/js/bootstrap.min.js"></script>
|
<script src="/static/js/bootstrap.min.js"></script>
|
||||||
|
<script src="/static/js/base.js"></script>
|
||||||
|
<!--<script>-->
|
||||||
|
<!--$(document).ready(function(){-->
|
||||||
|
<!--$('.i-checks').iCheck({-->
|
||||||
|
<!--checkboxClass: 'icheckbox_square-green',-->
|
||||||
|
<!--radioClass: 'iradio_square-green'-->
|
||||||
|
<!--});-->
|
||||||
|
<!--});-->
|
||||||
|
|
||||||
<script>
|
<!--function selectAll(){-->
|
||||||
|
<!--var checklist = document.getElementsByName ("selected");-->
|
||||||
|
<!--if(document.getElementById("select_all").checked)-->
|
||||||
|
<!--{-->
|
||||||
|
<!--for(var i=0;i<checklist.length;i++)-->
|
||||||
|
<!--{-->
|
||||||
|
<!--checklist[i].checked = 1;-->
|
||||||
|
<!--}-->
|
||||||
|
<!--}else{-->
|
||||||
|
<!--for(var j=0;j<checklist.length;j++)-->
|
||||||
|
<!--{-->
|
||||||
|
<!--checklist[j].checked = 0;-->
|
||||||
|
<!--}-->
|
||||||
|
<!--}-->
|
||||||
|
|
||||||
function selectAll(){
|
<!--}-->
|
||||||
var checklist = document.getElementsByName ("selected");
|
|
||||||
if(document.getElementById("select_all").checked)
|
|
||||||
{
|
|
||||||
for(var i=0;i<checklist.length;i++)
|
|
||||||
{
|
|
||||||
checklist[i].checked = 1;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
for(var j=0;j<checklist.length;j++)
|
|
||||||
{
|
|
||||||
checklist[j].checked = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
<!--function move(from, to) {-->
|
||||||
|
<!--$("#"+from+" option").each(function(){-->
|
||||||
|
<!--if ( $(this).prop("selected") == true ) {-->
|
||||||
|
<!--$("#"+to).append(this);-->
|
||||||
|
<!--}-->
|
||||||
|
<!--});-->
|
||||||
|
<!--}-->
|
||||||
|
|
||||||
function move(from, to) {
|
<!--function move_all(from, to){-->
|
||||||
$("#"+from+" option").each(function(){
|
<!--$("#"+from).children().each(function(){-->
|
||||||
if ( $(this).prop("selected") == true ) {
|
<!--$("#"+to).append(this);-->
|
||||||
$("#"+to).append(this);
|
<!--});-->
|
||||||
}
|
<!--}-->
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function move_all(from, to){
|
|
||||||
$("#"+from).children().each(function(){
|
|
||||||
$("#"+to).append(this);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- validator js -->
|
|
||||||
<script src="/static/js/validator/jquery.validator.js"></script>
|
|
||||||
<script src="/static/js/validator/zh_CN.js"></script>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- pop windows -->
|
<!-- pop windows -->
|
||||||
<script src="/static/js/jquery.colorbox.js"></script>
|
<script src="/static/js/jquery.colorbox.js"></script>
|
||||||
|
|
||||||
|
<!-- validator js -->
|
||||||
|
<script src="/static/js/validator/jquery.validator.js"></script>
|
||||||
|
<script src="/static/js/validator/zh_CN.js"></script>
|
||||||
|
|
|
@ -0,0 +1,151 @@
|
||||||
|
{% extends 'base.html' %}
|
||||||
|
{% load mytags %}
|
||||||
|
{% block content %}
|
||||||
|
{% include 'nav_cat_bar.html' %}
|
||||||
|
|
||||||
|
<div class="wrapper wrapper-content animated fadeInRight">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<div class="ibox float-e-margins" id="all">
|
||||||
|
<div class="ibox-title">
|
||||||
|
<h5> 主机组<span class="text-info">{{ group_name }}</span>详细信息列表 </h5>
|
||||||
|
<div class="ibox-tools">
|
||||||
|
<a class="collapse-link">
|
||||||
|
<i class="fa fa-chevron-up"></i>
|
||||||
|
</a>
|
||||||
|
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
|
||||||
|
<i class="fa fa-wrench"></i>
|
||||||
|
</a>
|
||||||
|
<ul class="dropdown-menu dropdown-user">
|
||||||
|
<li><a href="#">未启用 1</a>
|
||||||
|
</li>
|
||||||
|
<li><a href="#">未启用 2</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<a class="close-link">
|
||||||
|
<i class="fa fa-times"></i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="ibox-content">
|
||||||
|
<div class="">
|
||||||
|
<a target="_blank" href="/jasset/host_add" class="btn btn-sm btn-primary "> 添加 </a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form id="contents_form" name="contents_form">
|
||||||
|
<table class="table table-striped table-bordered table-hover " id="editable" name="editable">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="text-center"><input id="checkall" type="checkbox" class="i-checks" name="checkall" value="checkall" data-editable='false' onclick="check_all('contents_form')"></th>
|
||||||
|
<th class="text-center" name="j_ip"> IP地址 </th>
|
||||||
|
<th class="text-center"> 端口号 </th>
|
||||||
|
<th class="text-center" name="j_type"> 登录方式 </th>
|
||||||
|
<th class="text-center" name="j_idc"> 所属IDC </th>
|
||||||
|
<th class="text-center"> 所属业务组 </th>
|
||||||
|
<th class="text-center"> 是否激活 </th>
|
||||||
|
<th class="text-center" name="j_time"> 添加时间 </th>
|
||||||
|
<th class="text-center" name="j_comment"> 备注 </th>
|
||||||
|
<th class="text-center"> 操作 </th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for post in contacts.object_list %}
|
||||||
|
<tr class="gradeX">
|
||||||
|
<td class="text-center" name="j_id" value="{{ post.id }}" data-editable='false'><input name="id" value="{{ post.id }}" type="checkbox" class="i-checks"></td>
|
||||||
|
<td class="text-center" name="j_ip"> {{ post.ip }} </td>
|
||||||
|
<td class="text-center" name="j_port"> {{ post.port }} </td>
|
||||||
|
<td class="text-center" name="j_type"> {{ login_types|get_item:post.login_type }} </td>
|
||||||
|
<td class="text-center" name="j_idc"> {{ post.idc.name }} </td>
|
||||||
|
<td class="text-center" name="j_group">{% for group in post.bis_group.all %} {{ group }} {% endfor %}</td>
|
||||||
|
<td class="text-center" name="j_active"> {{ post.is_active|bool2str }} </td>
|
||||||
|
<td class="text-center"> {{ post.date_added|date:"Y-m-d H:i:s" }} </td>
|
||||||
|
<td class="text-center" name="j_comment"> {{ post.comment }} </td>
|
||||||
|
<td class="text-center" data-editable='false'>
|
||||||
|
<a href="/jasset/{{ post.ip }}/" class="iframe btn btn-xs btn-primary">详情</a>
|
||||||
|
<a href="/jasset/host_edit/{{ post.id }}" class="btn btn-xs btn-info">编辑</a>
|
||||||
|
<a href="/jasset/host_del/{{ post.id }}" class="btn btn-xs btn-danger">删除</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<input type="button" id="del_button" class="btn btn-danger btn-sm" name="del_button" value="删除" onclick="del('contents_form')" />
|
||||||
|
<input type="button" id="alter_button" class="btn btn-warning btn-sm" name="alter_button" value="修改" onclick="alter('contents_form')" />
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="dataTables_paginate paging_simple_numbers" id="editable_paginate">
|
||||||
|
<ul class="pagination" style="margin-top: 0; float: right">
|
||||||
|
|
||||||
|
{% if contacts.has_previous %}
|
||||||
|
<li><a href="?page={{ contacts.previous_page_number }}">«</a></li>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% for page in p.page_range %}
|
||||||
|
{% ifequal offset1 page %}
|
||||||
|
<li class="active"><a href="?page={{ page }}" title="第{{ page }}页">{{ page }}</a></li>
|
||||||
|
{% else %}
|
||||||
|
<li><a href="?page={{ page }}" title="第{{ page }}页">{{ page }}</a></li>
|
||||||
|
{% endifequal %}
|
||||||
|
{% endfor %}
|
||||||
|
{% if contacts.has_next %}
|
||||||
|
<li><a href="?page={{ contacts.next_page_number }}">»</a></li>
|
||||||
|
{% endif %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(document).ready(function(){
|
||||||
|
$(".iframe").colorbox({iframe:true, width:"70%", height:"70%"});
|
||||||
|
$('#editable').editableTableWidget();
|
||||||
|
});
|
||||||
|
|
||||||
|
function alter(form) {
|
||||||
|
selectData = GetTableDataBox();
|
||||||
|
if (selectData[1] != 0) {
|
||||||
|
$.ajax({
|
||||||
|
type: "post",
|
||||||
|
url: "/jasset/host_edit/batch/",
|
||||||
|
data: {"editable": selectData[0], "len_table": selectData[1]},
|
||||||
|
success: function (data) {
|
||||||
|
alert("修改成功");
|
||||||
|
window.open("/jasset/host_list/", "_self");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function del(form) {
|
||||||
|
var checkboxes = document.getElementById(form);
|
||||||
|
var id_list = {};
|
||||||
|
var j = 0;
|
||||||
|
for (var i = 0; i < checkboxes.elements.length; i++) {
|
||||||
|
if (checkboxes.elements[i].type == "checkbox" && checkboxes.elements[i].checked == true && checkboxes.elements[i].value != "checkall") {
|
||||||
|
id_list[j] = checkboxes.elements[i].value;
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (confirm("确定删除")) {
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: "/jasset/host_del/",
|
||||||
|
data: {"id_list": id_list, "len_list": j},
|
||||||
|
success: function (data) {
|
||||||
|
window.open("/jasset/host_list/", "_self");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{% endblock %}
|
|
@ -22,6 +22,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th class="text-center"> ID </th>
|
<th class="text-center"> ID </th>
|
||||||
<th class="text-center"> 主机组名 </th>
|
<th class="text-center"> 主机组名 </th>
|
||||||
|
<th class="text-center"> 主机数量 </th>
|
||||||
<th class="text-center"> 备注 </th>
|
<th class="text-center"> 备注 </th>
|
||||||
<th class="text-center"> 操作 </th>
|
<th class="text-center"> 操作 </th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -31,10 +32,10 @@
|
||||||
<tr class="gradeX">
|
<tr class="gradeX">
|
||||||
<td class="text-center"> {{ post.id }} </td>
|
<td class="text-center"> {{ post.id }} </td>
|
||||||
<td class="text-center"> {{ post.name }} </td>
|
<td class="text-center"> {{ post.name }} </td>
|
||||||
|
<td class="text-center"> <a href="/jasset/group_detail/{{ post.id }}">{{ post.asset_set.count }}</a> </td>
|
||||||
<td class="text-center"> {{ post.comment }} </td>
|
<td class="text-center"> {{ post.comment }} </td>
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
<a href="/jasset/{{ post.ip }}/" class="iframe btn btn-xs btn-primary">详情</a>
|
<a href="/jasset/group_detail/{{ post.id }}" class="btn btn-xs btn-info">详情</a>
|
||||||
<a href="/jasset/host_edit/{{ post.ip }}" class="btn btn-xs btn-info">编辑</a>
|
|
||||||
<a href="/jasset/group_del/{{ post.id }}" class="btn btn-xs btn-danger">删除</a>
|
<a href="/jasset/group_del/{{ post.id }}" class="btn btn-xs btn-danger">删除</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -4,13 +4,7 @@
|
||||||
<div class="wrapper wrapper-content animated fadeInRight">
|
<div class="wrapper wrapper-content animated fadeInRight">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<div class="text-center">
|
<div class="ibox float-e-margins">
|
||||||
<span>请选择添加内容: </span>
|
|
||||||
<a href="#" class="btn btn-xs btn-primary" onclick='change("addhost")'>添加主机</a>
|
|
||||||
<a href="#" class="btn btn-xs btn-primary" onclick='change("addidc")'>添加IDC</a>
|
|
||||||
<a href="#" class="btn btn-xs btn-primary" onclick='change("addgroup")'>添加业务组</a>
|
|
||||||
</div>
|
|
||||||
<div id="add_asset" class="ibox float-e-margins">
|
|
||||||
<div id="ibox-content" class="ibox-title">
|
<div id="ibox-content" class="ibox-title">
|
||||||
<h5> 填写主机基本信息 </h5>
|
<h5> 填写主机基本信息 </h5>
|
||||||
<div class="ibox-tools">
|
<div class="ibox-tools">
|
||||||
|
@ -33,107 +27,112 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ibox-content">
|
<div class="ibox-content">
|
||||||
{% if emg %}
|
<div class="panel blank-panel">
|
||||||
<div class="alert alert-warning text-center">{{ emg }}</div>
|
<div class="panel-options">
|
||||||
{% endif %}
|
<ul class="nav nav-tabs">
|
||||||
{% if smg %}
|
<li class="active"><a href="/jasset/host_add/" class="text-center"><i class="fa fa-laptop"></i> 单台添加 </a></li>
|
||||||
<div class="alert alert-success text-center">{{ smg }}</div>
|
<li><a href="/jasset/host_add_multi" class="text-center"><i class="fa fa-bar-chart-o"></i> 批量添加 </a></li>
|
||||||
{% endif %}
|
</ul>
|
||||||
<form id="assetForm" method="post" class="form-horizontal">
|
|
||||||
<div class="form-group"><label class="col-sm-2 control-label"> IP地址 </label>
|
|
||||||
<div class="col-sm-8"><input type="text" name="j_ip" placeholder="192.168.1.1" class="form-control"></div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<div class="tab-content">
|
||||||
|
<div id="tab-1" class="ibox float-e-margins tab-pane active">
|
||||||
|
{% if emg %}
|
||||||
|
<div class="alert alert-warning text-center">{{ emg }}</div>
|
||||||
|
{% endif %}
|
||||||
|
{% if smg %}
|
||||||
|
<div class="alert alert-success text-center">{{ smg }}</div>
|
||||||
|
{% endif %}
|
||||||
|
<form id="assetForm" method="post" class="form-horizontal">
|
||||||
|
<div class="form-group"><label class="col-sm-2 control-label"> IP地址<span class="red-fonts">*</span> </label>
|
||||||
|
<div class="col-sm-8"><input type="text" name="j_ip" placeholder="192.168.1.1" class="form-control"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="hr-line-dashed"></div>
|
<div class="hr-line-dashed"></div>
|
||||||
<div class="form-group"><label class="col-sm-2 control-label"> 端口号 </label>
|
<div class="form-group"><label class="col-sm-2 control-label"> 端口号<span class="red-fonts">*</span> </label>
|
||||||
<div class="col-sm-8"><input type="text" placeholder="22" name="j_port" class="form-control"></div>
|
<div class="col-sm-8"><input type="text" placeholder="22" name="j_port" class="form-control"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="hr-line-dashed"></div>
|
<div class="hr-line-dashed"></div>
|
||||||
<div class="form-group"><label class="col-sm-2 control-label"> 登录方式 </label>
|
<div class="form-group"><label class="col-sm-2 control-label"> 登录方式<span class="red-fonts">*</span> </label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<div class="radio i-checks"><label> <input type="radio" id="L" checked="" value="L" name="j_type" onclick="show(this)"> <i> LDAP </i></label></div>
|
<div class="radio i-checks"><label> <input type="radio" id="L" checked="" value="L" name="j_type" onclick="show(this)"> <i> LDAP </i></label></div>
|
||||||
<div class="radio i-checks"><label> <input type="radio" id="S" value="S" name="j_type" onclick="show(this)"> <i> SSH_KEY </i></label></div>
|
<div class="radio i-checks"><label> <input type="radio" id="S" value="S" name="j_type" onclick="show(this)"> <i> SSH_KEY </i></label></div>
|
||||||
<div class="radio i-checks"><label> <input type="radio" id="P" value="P" name="j_type" onclick="show(this)"> <i> PASSWORD </i></label></div>
|
<div class="radio i-checks"><label> <input type="radio" id="P" value="P" name="j_type" onclick="show(this)"> <i> PASSWORD </i></label></div>
|
||||||
<div class="radio i-checks"><label> <input type="radio" id="M" value="M" name="j_type" onclick="show(this)"> <i> MAP </i></label></div>
|
<div class="radio i-checks"><label> <input type="radio" id="M" value="M" name="j_type" onclick="show(this)"> <i> MAP </i></label></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div name="a1" id=a1 style="display:none;">
|
<div name="a1" id=a1 style="display:none;">
|
||||||
<div class="form-group"><label class="col-sm-2 col-sm-offset-1 control-label"> 普通用户名 </label>
|
<div class="form-group"><label class="col-sm-2 col-sm-offset-1 control-label"> 普通用户名 </label>
|
||||||
<div class="col-sm-6"><input type="text" name="j_user" placeholder="lilei" class="form-control"></div>
|
<div class="col-sm-6"><input type="text" name="j_user" placeholder="lilei" class="form-control"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group"><label class="col-sm-2 col-sm-offset-1 control-label"> 普通用户密码 </label>
|
||||||
|
<div class="col-sm-6"><input type="password" name="j_password" placeholder="Password" class="form-control"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="hr-line-dashed"></div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="j_idc" class="col-lg-2 control-label"> 所属IDC<span class="red-fonts">*</span> </label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<select id="j_idc" name="j_idc" class="form-control m-b">
|
||||||
|
{% for i in eidc %}
|
||||||
|
<option> {{ i }} </option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="hr-line-dashed"></div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="j_group" class="col-lg-2 control-label">所属主机组<span class="red-fonts">*</span></label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<select id="j_group" name="j_group" class="form-control m-b" multiple size="10">
|
||||||
|
{% for g in egroup %}
|
||||||
|
<option type="checkbox" value="{{ g.name }}">{{ g.name }} --- {{ g.comment }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="hr-line-dashed"></div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="j_group" class="col-sm-2 control-label"> 所属用户组<span class="red-fonts">*</span> </label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
{% for g in eusergroup %}
|
||||||
|
<label class="checkbox-inline"><input type="checkbox" id="j_usergroup" value="{{ g }}" name="j_usergroup"> {{ g }} </label>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="hr-line-dashed"></div>
|
||||||
|
<div class="form-group"><label class="col-sm-2 control-label"> 是否激活<span class="red-fonts">*</span> </label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<div class="radio i-checks"><label> <input type="radio" checked="" value="1" name="j_active"> <i> 激活 </i></label></div>
|
||||||
|
<div class="radio i-checks"><label> <input type="radio" value="0" name="j_active"> <i> 禁用 </i></label></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="hr-line-dashed"></div>
|
||||||
|
<div class="form-group"><label class="col-sm-2 control-label"> 备注 </label>
|
||||||
|
<div class="col-sm-8"><input type="text" placeholder="hadoop01" name="j_comment" class="form-control"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="hr-line-dashed"></div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-4 col-sm-offset-5">
|
||||||
|
<button class="btn btn-white" type="submit"> 重置 </button>
|
||||||
|
<button class="btn btn-primary" type="submit"> 提交 </button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="hr-line-dashed"></div>
|
|
||||||
<div class="form-group"><label class="col-sm-2 col-sm-offset-1 control-label"> 普通用户密码 </label>
|
|
||||||
<div class="col-sm-6"><input type="password" name="j_password" placeholder="Password" class="form-control"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="hr-line-dashed"></div>
|
|
||||||
<div class="form-group"><label class="col-sm-2 col-sm-offset-1 control-label"> 超管用户名 </label>
|
|
||||||
<div class="col-sm-6"><input type="text" name="j_root" placeholder="root" class="form-control"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="hr-line-dashed"></div>
|
|
||||||
<div class="form-group"><label class="col-sm-2 col-sm-offset-1 control-label"> 超管用户密码 </label>
|
|
||||||
<div class="col-sm-6"><input type="password" name="j_passwd" placeholder="Password" class="form-control"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="hr-line-dashed"></div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="j_idc" class="col-lg-2 control-label"> 所属IDC </label>
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<select id="j_idc" name="j_idc" class="form-control m-b">
|
|
||||||
{% for i in eidc %}
|
|
||||||
<option> {{ i }} </option>
|
|
||||||
{% endfor %}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="hr-line-dashed"></div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="j_group" class="col-sm-2 control-label"> 所属业务组 </label>
|
|
||||||
<div class="col-sm-8">
|
|
||||||
{% for g in egroup %}
|
|
||||||
<label class="checkbox-inline"><input type="checkbox" id="j_group" value="{{ g }}" name="j_group"> {{ g }} </label>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="hr-line-dashed"></div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="j_group" class="col-sm-2 control-label"> 所属用户组 </label>
|
|
||||||
<div class="col-sm-8">
|
|
||||||
{% for g in eusergroup %}
|
|
||||||
<label class="checkbox-inline"><input type="checkbox" id="j_usergroup" value="{{ g }}" name="j_usergroup"> {{ g }} </label>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="hr-line-dashed"></div>
|
|
||||||
<div class="form-group"><label class="col-sm-2 control-label"> 是否激活 </label>
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<div class="radio i-checks"><label> <input type="radio" checked="" value="1" name="j_active"> <i> 激活 </i></label></div>
|
|
||||||
<div class="radio i-checks"><label> <input type="radio" value="0" name="j_active"> <i> 禁用 </i></label></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="hr-line-dashed"></div>
|
|
||||||
<div class="form-group"><label class="col-sm-2 control-label"> 备注 </label>
|
|
||||||
<div class="col-sm-8"><input type="text" placeholder="hadoop01" name="j_comment" class="form-control"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="hr-line-dashed"></div>
|
|
||||||
<div class="form-group">
|
|
||||||
<div class="col-sm-4 col-sm-offset-5">
|
|
||||||
<!--<button class="btn btn-white" type="submit"> 重置 </button>-->
|
|
||||||
<button class="btn btn-primary" type="submit"> 提交 </button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -151,17 +150,6 @@
|
||||||
document.getElementById("a1").style.display="none";
|
document.getElementById("a1").style.display="none";
|
||||||
}};
|
}};
|
||||||
|
|
||||||
function change(type){
|
|
||||||
if (type == 'addhost') {
|
|
||||||
var data = $('#add_asset');
|
|
||||||
} else if (type == 'addidc') {
|
|
||||||
var data = $('#addidc');
|
|
||||||
} else {
|
|
||||||
var data = $('addgroup');
|
|
||||||
}
|
|
||||||
$("#add_asset").html(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#assetForm').validator({
|
$('#assetForm').validator({
|
||||||
timely: 2,
|
timely: 2,
|
||||||
theme: "yellow_right_effect",
|
theme: "yellow_right_effect",
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
{% extends 'base.html' %}
|
||||||
|
{% block content %}
|
||||||
|
{% include 'nav_cat_bar.html' %}
|
||||||
|
<div class="wrapper wrapper-content animated fadeInRight">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-10">
|
||||||
|
<div class="ibox float-e-margins">
|
||||||
|
<div id="ibox-content" class="ibox-title">
|
||||||
|
<h5> 填写主机基本信息 </h5>
|
||||||
|
<div class="ibox-tools">
|
||||||
|
<a class="collapse-link">
|
||||||
|
<i class="fa fa-chevron-up"></i>
|
||||||
|
</a>
|
||||||
|
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
|
||||||
|
<i class="fa fa-wrench"></i>
|
||||||
|
</a>
|
||||||
|
<ul class="dropdown-menu dropdown-user">
|
||||||
|
<li><a href="#">未启用 1</a>
|
||||||
|
</li>
|
||||||
|
<li><a href="#">未启用 2</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<a class="close-link">
|
||||||
|
<i class="fa fa-times"></i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="ibox-content">
|
||||||
|
<div class="panel blank-panel">
|
||||||
|
<div class="panel-options">
|
||||||
|
<ul class="nav nav-tabs">
|
||||||
|
<li><a href="/jasset/host_add/" class="text-center"><i class="fa fa-laptop"></i> 单台添加 </a></li>
|
||||||
|
<li class="active"><a href="/jasset/host_add_multi/" class="text-center"><i class="fa fa-bar-chart-o"></i> 批量添加 </a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<div id="tab-2" class="ibox float-e-margins tab-pane active">
|
||||||
|
{% if emg %}
|
||||||
|
<div class="alert alert-warning text-center">{{ emg }}</div>
|
||||||
|
{% endif %}
|
||||||
|
{% if smg %}
|
||||||
|
<div class="alert alert-success text-center">{{ smg }}</div>
|
||||||
|
{% endif %}
|
||||||
|
<h4>按照文本框内主机信息格式填写, 多台主机回车换行</h4>
|
||||||
|
<form id="assetMulti" method="post" class="form-horizontal">
|
||||||
|
<div><textarea id="j_multi" name="j_multi" type="text" placeholder="192.168.1.1 22 LDAP 北京联通 [网站,数据库] admin 1 网站服务器" class="form-control" style="width:700px;height:500px"></textarea></div>
|
||||||
|
<div class="hr-line-dashed"></div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-4 col-sm-offset-4">
|
||||||
|
<button class="btn btn-white" type="submit"> 重置 </button>
|
||||||
|
<button class="btn btn-primary" type="submit"> 提交 </button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
|
@ -35,17 +35,17 @@
|
||||||
<div class="alert alert-success text-center">{{ smg }}</div>
|
<div class="alert alert-success text-center">{{ smg }}</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<form id="assetForm" method="post" class="form-horizontal" autocomplete="off">
|
<form id="assetForm" method="post" class="form-horizontal" autocomplete="off">
|
||||||
<div class="form-group"><label class="col-sm-2 control-label"> IP地址 </label>
|
<div class="form-group"><label class="col-sm-2 control-label"> IP地址<span class="red-fonts">*</span> </label>
|
||||||
<div class="col-sm-8"><input type="text" name="j_ip" value="{{ post.ip }}" placeholder="192.168.1.1" class="form-control"></div>
|
<div class="col-sm-8"><input type="text" name="j_ip" value="{{ post.ip }}" placeholder="192.168.1.1" class="form-control"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="hr-line-dashed"></div>
|
<div class="hr-line-dashed"></div>
|
||||||
<div class="form-group"><label class="col-sm-2 control-label"> 端口号 </label>
|
<div class="form-group"><label class="col-sm-2 control-label"> 端口号<span class="red-fonts">*</span> </label>
|
||||||
<div class="col-sm-8"><input type="text" placeholder="22" name="j_port" value="{{ post.port }}" class="form-control"></div>
|
<div class="col-sm-8"><input type="text" placeholder="22" name="j_port" value="{{ post.port }}" class="form-control"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="hr-line-dashed"></div>
|
<div class="hr-line-dashed"></div>
|
||||||
<div class="form-group"><label class="col-sm-2 control-label"> 登录方式 </label>
|
<div class="form-group"><label class="col-sm-2 control-label"> 登录方式<span class="red-fonts">*</span> </label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
{% for t, type in login_types.items %}
|
{% for t, type in login_types.items %}
|
||||||
{% ifequal t post.login_type %}
|
{% ifequal t post.login_type %}
|
||||||
|
@ -61,27 +61,15 @@
|
||||||
<div class="col-sm-6"><input type="text" name="j_user" placeholder="lilei" class="form-control"></div>
|
<div class="col-sm-6"><input type="text" name="j_user" placeholder="lilei" class="form-control"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="hr-line-dashed"></div>
|
|
||||||
<div class="form-group"><label class="col-sm-2 col-sm-offset-1 control-label"> 普通用户密码 </label>
|
<div class="form-group"><label class="col-sm-2 col-sm-offset-1 control-label"> 普通用户密码 </label>
|
||||||
<div class="col-sm-6"><input type="password" name="j_password" placeholder="Password" class="form-control"></div>
|
<div class="col-sm-6"><input type="password" name="j_password" placeholder="Password" class="form-control"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="hr-line-dashed"></div>
|
|
||||||
<div class="form-group"><label class="col-sm-2 col-sm-offset-1 control-label"> 超管用户名 </label>
|
|
||||||
<div class="col-sm-6"><input type="text" name="j_root" placeholder="root" class="form-control"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="hr-line-dashed"></div>
|
|
||||||
<div class="form-group"><label class="col-sm-2 col-sm-offset-1 control-label"> 超管用户密码 </label>
|
|
||||||
<div class="col-sm-6"><input type="password" name="j_passwd" placeholder="Password" class="form-control"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="hr-line-dashed"></div>
|
<div class="hr-line-dashed"></div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="j_idc" class="col-lg-2 control-label"> 所属IDC </label>
|
<label for="j_idc" class="col-lg-2 control-label"> 所属IDC<span class="red-fonts">*</span> </label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<select id="j_idc" name="j_idc" class="form-control m-b">
|
<select id="j_idc" name="j_idc" class="form-control m-b">
|
||||||
{% for i in eidc %}
|
{% for i in eidc %}
|
||||||
|
@ -97,20 +85,22 @@
|
||||||
|
|
||||||
<div class="hr-line-dashed"></div>
|
<div class="hr-line-dashed"></div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="j_group" class="col-sm-2 control-label"> 所属业务组 </label>
|
<label for="j_group" class="col-lg-2 control-label"> 所属主机组<span class="red-fonts">*</span> </label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
{% for g in egroup %}
|
<select id="j_group" name="j_group" class="form-control m-b" multiple size="10">
|
||||||
{% if g in e_group %}
|
{% for g in egroup %}
|
||||||
<label class="checkbox-inline"><input type="checkbox" id="j_group" checked value="{{ g }}" name="j_group"> {{ g }} </label>
|
{% if g in e_group %}
|
||||||
{% else %}
|
<option type="checkbox" value="{{ g.name }}" selected>{{ g.name }} --- {{ g.comment }}</option>
|
||||||
<label class="checkbox-inline"><input type="checkbox" id="j_group" value="{{ g }}" name="j_group"> {{ g }} </label>
|
{% else %}
|
||||||
{% endif %}
|
<option type="checkbox" value="{{ g.name }}" >{{ g.name }} --- {{ g.comment }}</option>
|
||||||
{% endfor %}
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="hr-line-dashed"></div>
|
<div class="hr-line-dashed"></div>
|
||||||
<div class="form-group"><label class="col-sm-2 control-label"> 是否激活 </label>
|
<div class="form-group"><label class="col-sm-2 control-label"> 是否激活<span class="red-fonts">*</span> </label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
{% for a,active in actives.items %}
|
{% for a,active in actives.items %}
|
||||||
{% ifequal a post.is_active %}
|
{% ifequal a post.is_active %}
|
||||||
|
|
|
@ -52,12 +52,12 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for post in contacts.object_list %}
|
{% for post in contacts.object_list %}
|
||||||
<tr class="gradeX">
|
<tr class="gradeX">
|
||||||
<td class="text-center" data-editable='false'><input name="id" value="{{ post.id }}" type="checkbox" class="i-checks"></td>
|
<td class="text-center" name="j_id" value="{{ post.id }}" data-editable='false'><input name="id" value="{{ post.id }}" type="checkbox" class="i-checks"></td>
|
||||||
<td class="text-center" name="j_ip"> {{ post.ip }} </td>
|
<td class="text-center" name="j_ip"> {{ post.ip }} </td>
|
||||||
<td class="text-center" name="j_port"> {{ post.port }} </td>
|
<td class="text-center" name="j_port"> {{ post.port }} </td>
|
||||||
<td class="text-center" name="j_type"> {{ login_types|get_item:post.login_type }} </td>
|
<td class="text-center" name="j_type"> {{ login_types|get_item:post.login_type }} </td>
|
||||||
<td class="text-center" name="j_idc"> {{ post.idc.name }} </td>
|
<td class="text-center" name="j_idc"> {{ post.idc.name }} </td>
|
||||||
<td class="text-center" name="j_group">{% for group in post.bis_group.all %} {{ group }} {% endfor %}</td>
|
<td class="text-center" name="j_group">{% for group in post.bis_group.all|filter_private %} {{ group }} {% endfor %}</td>
|
||||||
<td class="text-center" name="j_active"> {{ post.is_active|bool2str }} </td>
|
<td class="text-center" name="j_active"> {{ post.is_active|bool2str }} </td>
|
||||||
<td class="text-center"> {{ post.date_added|date:"Y-m-d H:i:s" }} </td>
|
<td class="text-center"> {{ post.date_added|date:"Y-m-d H:i:s" }} </td>
|
||||||
<td class="text-center" name="j_comment"> {{ post.comment }} </td>
|
<td class="text-center" name="j_comment"> {{ post.comment }} </td>
|
||||||
|
@ -112,40 +112,40 @@
|
||||||
|
|
||||||
function alter(form) {
|
function alter(form) {
|
||||||
selectData = GetTableDataBox();
|
selectData = GetTableDataBox();
|
||||||
if (selectData[1] != 0){
|
if (selectData[1] != 0) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "post",
|
type: "post",
|
||||||
url: "/jasset/host_edit/batch/",
|
url: "/jasset/host_edit/batch/",
|
||||||
data : {"editable":selectData[0],"len_table":selectData[1]},
|
data: {"editable": selectData[0], "len_table": selectData[1]},
|
||||||
success: function(data){
|
|
||||||
alert("修改成功");
|
|
||||||
window.open("/jasset/host_list/","_self");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function del(form) {
|
|
||||||
var checkboxes = document.getElementById(form);
|
|
||||||
var id_list = {};
|
|
||||||
var j = 0;
|
|
||||||
for (var i = 0; i < checkboxes.elements.length; i++) {
|
|
||||||
if (checkboxes.elements[i].type == "checkbox" && checkboxes.elements[i].checked == true && checkboxes.elements[i].value != "checkall") {
|
|
||||||
id_list[j] = checkboxes.elements[i].value;
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (confirm("确定删除")) {
|
|
||||||
$.ajax({
|
|
||||||
type: "POST",
|
|
||||||
url: "/jasset/host_del/",
|
|
||||||
data: {"id_list": id_list, "len_list": j},
|
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
|
alert("修改成功");
|
||||||
window.open("/jasset/host_list/", "_self");
|
window.open("/jasset/host_list/", "_self");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
function del(form) {
|
||||||
|
var checkboxes = document.getElementById(form);
|
||||||
|
var id_list = {};
|
||||||
|
var j = 0;
|
||||||
|
for (var i = 0; i < checkboxes.elements.length; i++) {
|
||||||
|
if (checkboxes.elements[i].type == "checkbox" && checkboxes.elements[i].checked == true && checkboxes.elements[i].value != "checkall") {
|
||||||
|
id_list[j] = checkboxes.elements[i].value;
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (confirm("确定删除")) {
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: "/jasset/host_del/multi/",
|
||||||
|
data: {"id_list": id_list, "len_list": j},
|
||||||
|
success: function (data) {
|
||||||
|
window.open("/jasset/host_list/", "_self");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -0,0 +1,150 @@
|
||||||
|
{% extends 'base.html' %}
|
||||||
|
{% load mytags %}
|
||||||
|
{% block content %}
|
||||||
|
{% include 'nav_cat_bar.html' %}
|
||||||
|
|
||||||
|
<div class="wrapper wrapper-content animated fadeInRight">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<div class="ibox float-e-margins" id="all">
|
||||||
|
<div class="ibox-title">
|
||||||
|
<h5> IDC<span class="text-info"> {{ idc_name }} </span>详细信息列表 </h5>
|
||||||
|
<div class="ibox-tools">
|
||||||
|
<a class="collapse-link">
|
||||||
|
<i class="fa fa-chevron-up"></i>
|
||||||
|
</a>
|
||||||
|
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
|
||||||
|
<i class="fa fa-wrench"></i>
|
||||||
|
</a>
|
||||||
|
<ul class="dropdown-menu dropdown-user">
|
||||||
|
<li><a href="#">未启用 1</a>
|
||||||
|
</li>
|
||||||
|
<li><a href="#">未启用 2</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<a class="close-link">
|
||||||
|
<i class="fa fa-times"></i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="ibox-content">
|
||||||
|
<div class="">
|
||||||
|
<a target="_blank" href="/jasset/host_add" class="btn btn-sm btn-primary "> 添加 </a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form id="contents_form" name="contents_form">
|
||||||
|
<table class="table table-striped table-bordered table-hover " id="editable" name="editable">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="text-center"><input id="checkall" type="checkbox" class="i-checks" name="checkall" value="checkall" data-editable='false' onclick="check_all('contents_form')"></th>
|
||||||
|
<th class="text-center" name="j_ip"> IP地址 </th>
|
||||||
|
<th class="text-center"> 端口号 </th>
|
||||||
|
<th class="text-center" name="j_type"> 登录方式 </th>
|
||||||
|
<th class="text-center" name="j_idc"> 所属IDC </th>
|
||||||
|
<th class="text-center"> 所属业务组 </th>
|
||||||
|
<th class="text-center"> 是否激活 </th>
|
||||||
|
<th class="text-center" name="j_time"> 添加时间 </th>
|
||||||
|
<th class="text-center" name="j_comment"> 备注 </th>
|
||||||
|
<th class="text-center"> 操作 </th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for post in contacts.object_list %}
|
||||||
|
<tr class="gradeX">
|
||||||
|
<td class="text-center" name="j_id" value="{{ post.id }}" data-editable='false'><input name="id" value="{{ post.id }}" type="checkbox" class="i-checks"></td>
|
||||||
|
<td class="text-center" name="j_ip"> {{ post.ip }} </td>
|
||||||
|
<td class="text-center" name="j_port"> {{ post.port }} </td>
|
||||||
|
<td class="text-center" name="j_type"> {{ login_types|get_item:post.login_type }} </td>
|
||||||
|
<td class="text-center" name="j_idc"> {{ post.idc.name }} </td>
|
||||||
|
<td class="text-center" name="j_group">{% for group in post.bis_group.all %} {{ group }} {% endfor %}</td>
|
||||||
|
<td class="text-center" name="j_active"> {{ post.is_active|bool2str }} </td>
|
||||||
|
<td class="text-center"> {{ post.date_added|date:"Y-m-d H:i:s" }} </td>
|
||||||
|
<td class="text-center" name="j_comment"> {{ post.comment }} </td>
|
||||||
|
<td class="text-center" data-editable='false'>
|
||||||
|
<a href="/jasset/{{ post.ip }}/" class="iframe btn btn-xs btn-primary">详情</a>
|
||||||
|
<a href="/jasset/host_del/{{ post.id }}" class="btn btn-xs btn-danger">删除</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<input type="button" id="del_button" class="btn btn-danger btn-sm" name="del_button" value="删除" onclick="del('contents_form')" />
|
||||||
|
<input type="button" id="alter_button" class="btn btn-warning btn-sm" name="alter_button" value="修改" onclick="alter('contents_form')" />
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="dataTables_paginate paging_simple_numbers" id="editable_paginate">
|
||||||
|
<ul class="pagination" style="margin-top: 0; float: right">
|
||||||
|
|
||||||
|
{% if contacts.has_previous %}
|
||||||
|
<li><a href="?page={{ contacts.previous_page_number }}">«</a></li>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% for page in p.page_range %}
|
||||||
|
{% ifequal offset1 page %}
|
||||||
|
<li class="active"><a href="?page={{ page }}" title="第{{ page }}页">{{ page }}</a></li>
|
||||||
|
{% else %}
|
||||||
|
<li><a href="?page={{ page }}" title="第{{ page }}页">{{ page }}</a></li>
|
||||||
|
{% endifequal %}
|
||||||
|
{% endfor %}
|
||||||
|
{% if contacts.has_next %}
|
||||||
|
<li><a href="?page={{ contacts.next_page_number }}">»</a></li>
|
||||||
|
{% endif %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(document).ready(function(){
|
||||||
|
$(".iframe").colorbox({iframe:true, width:"70%", height:"70%"});
|
||||||
|
$('#editable').editableTableWidget();
|
||||||
|
});
|
||||||
|
|
||||||
|
function alter(form) {
|
||||||
|
selectData = GetTableDataBox();
|
||||||
|
if (selectData[1] != 0){
|
||||||
|
$.ajax({
|
||||||
|
type: "post",
|
||||||
|
url: "/jasset/host_edit/batch/",
|
||||||
|
data : {"editable":selectData[0],"len_table":selectData[1]},
|
||||||
|
success: function(data){
|
||||||
|
alert("修改成功");
|
||||||
|
window.open("/jasset/host_list/","_self");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function del(form) {
|
||||||
|
var checkboxes = document.getElementById(form);
|
||||||
|
var id_list = {};
|
||||||
|
var j = 0;
|
||||||
|
for (var i = 0; i < checkboxes.elements.length; i++) {
|
||||||
|
if (checkboxes.elements[i].type == "checkbox" && checkboxes.elements[i].checked == true && checkboxes.elements[i].value != "checkall") {
|
||||||
|
id_list[j] = checkboxes.elements[i].value;
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (confirm("确定删除")) {
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: "/jasset/host_del/",
|
||||||
|
data: {"id_list": id_list, "len_list": j},
|
||||||
|
success: function (data) {
|
||||||
|
window.open("/jasset/host_list/", "_self");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{% endblock %}
|
|
@ -22,6 +22,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th class="text-center"> ID </th>
|
<th class="text-center"> ID </th>
|
||||||
<th class="text-center"> 机房名 </th>
|
<th class="text-center"> 机房名 </th>
|
||||||
|
<th class="text-center"> 主机数量 </th>
|
||||||
<th class="text-center"> 备注 </th>
|
<th class="text-center"> 备注 </th>
|
||||||
<th class="text-center"> 操作 </th>
|
<th class="text-center"> 操作 </th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -31,10 +32,10 @@
|
||||||
<tr class="gradeX">
|
<tr class="gradeX">
|
||||||
<td class="text-center"> {{ post.id }} </td>
|
<td class="text-center"> {{ post.id }} </td>
|
||||||
<td class="text-center"> {{ post.name }} </td>
|
<td class="text-center"> {{ post.name }} </td>
|
||||||
|
<td class="text-center"> <a href="/jasset/idc_detail/{{ post.id }}">{{ post.asset_set.count }}</a> </td>
|
||||||
<td class="text-center"> {{ post.comment }} </td>
|
<td class="text-center"> {{ post.comment }} </td>
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
<a href="/jasset/{{ post.ip }}/" class="iframe btn btn-xs btn-primary">详情</a>
|
<a href="/jasset/idc_detail/{{ post.id }}" class="iframe btn btn-xs btn-primary">详情</a>
|
||||||
<a href="/jasset/host_edit/{{ post.ip }}" class="btn btn-xs btn-info">编辑</a>
|
|
||||||
<a href="/jasset/idc_del/{{ post.id }}" class="btn btn-xs btn-danger">删除</a>
|
<a href="/jasset/idc_del/{{ post.id }}" class="btn btn-xs btn-danger">删除</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -2,83 +2,115 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% include 'nav_cat_bar.html' %}
|
{% include 'nav_cat_bar.html' %}
|
||||||
<style>
|
<style>
|
||||||
|
.bootstrap-dialog-body {
|
||||||
|
background-color: rgba(0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
.bootstrap-dialog-message {
|
||||||
|
background-color: rgba(0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
.modal-content {
|
||||||
|
background-color: rgba(0, 0, 0, 0.6);
|
||||||
|
}
|
||||||
.modal-dialog {
|
.modal-dialog {
|
||||||
|
background-color: rgba(0, 0, 0, 0);
|
||||||
width: 800px;
|
width: 800px;
|
||||||
}
|
}
|
||||||
.modal-body {
|
.modal-body {
|
||||||
background-color: #000000;
|
background-color: rgba(0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
.modal-header {
|
||||||
|
background-color: #FFFFFF;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div class="wrapper wrapper-content animated fadeInRight">
|
<div class="wrapper wrapper-content animated fadeInRight">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<div class="panel-heading">
|
<div class="ibox float-e-margins">
|
||||||
<div class="panel-title m-b-md"><h4> 用户日志详细信息列表 </h4></div>
|
<div id="ibox-content" class="ibox-title">
|
||||||
<div class="panel-options">
|
<h5> 用户日志详细信息列表 </h5>
|
||||||
|
<div class="ibox-tools">
|
||||||
<ul class="nav nav-tabs">
|
<a class="collapse-link">
|
||||||
<li class="active"><a data-toggle="tab" href="#tab-1" class="text-center"><i class="fa fa-laptop"></i> 在线 </a></li>
|
<i class="fa fa-chevron-up"></i>
|
||||||
<li><a data-toggle="tab" href="#tab-2" class="text-center"><i class="fa fa-bar-chart-o"></i> 历史记录 </a></li>
|
</a>
|
||||||
</ul>
|
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
|
||||||
</div>
|
<i class="fa fa-wrench"></i>
|
||||||
</div>
|
</a>
|
||||||
<div class="panel-body">
|
<ul class="dropdown-menu dropdown-user">
|
||||||
<div class="tab-content">
|
<li><a href="#">未启用 1</a>
|
||||||
<div id="tab-1" class="ibox float-e-margins tab-pane active">
|
</li>
|
||||||
<div class="ibox-content">
|
<li><a href="#">未启用 2</a>
|
||||||
<table class="table table-striped table-bordered table-hover ">
|
</li>
|
||||||
<thead>
|
</ul>
|
||||||
<tr>
|
<a class="close-link">
|
||||||
<th class="text-center"> 用户名 </th>
|
<i class="fa fa-times"></i>
|
||||||
<th class="text-center"> 登录主机 </th>
|
</a>
|
||||||
<th class="text-center"> 实时监控 </th>
|
|
||||||
<th class="text-center"> 阻断 </th>
|
|
||||||
<th class="text-center"> 登录时间 </th>
|
|
||||||
<th class="text-center"> 结束时间 </th>
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for post in online %}
|
|
||||||
<tr class="gradeX">
|
|
||||||
<td class="text-center"> {{ post.user.name }} </td>
|
|
||||||
<td class="text-center"> {{ post.asset.ip }} </td>
|
|
||||||
<td class="text-center"><a class="monitor" filename="{{ post.log_path }}"> 监控 </a></td>
|
|
||||||
<td class="text-center"><a href="/jlog/log_kill/{{ post.pid }}"> 阻断 </a></td>
|
|
||||||
<td class="text-center"> {{ post.start_time|date:"Y-m-d H:i:s" }} </td>
|
|
||||||
<td class="text-center"> {{ post.end_time|date:"Y-m-d H:i:s" }} </td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div id="tab-2" class="ibox float-e-margins tab-pane">
|
</div>
|
||||||
<div class="ibox-content">
|
|
||||||
<table class="table table-striped table-bordered table-hover ">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th class="text-center"> 用户名 </th>
|
|
||||||
<th class="text-center"> 登录主机 </th>
|
|
||||||
<th class="text-center"> 命令统计 </th>
|
|
||||||
<th class="text-center"> 登录时间 </th>
|
|
||||||
<th class="text-center"> 结束时间 </th>
|
|
||||||
|
|
||||||
</tr>
|
<div class="ibox-content">
|
||||||
</thead>
|
<div class="panel blank-panel">
|
||||||
<tbody>
|
<div class="panel-options">
|
||||||
{% for post in offline %}
|
<ul class="nav nav-tabs">
|
||||||
<tr class="gradeX">
|
<li class="active"><a data-toggle="tab" href="#tab-1" class="text-center" onclick='log_fresh'><i class="fa fa-laptop"></i> 在线 </a></li>
|
||||||
<td class="text-center"> {{ post.user.name }} </td>
|
<li><a data-toggle="tab" href="#tab-2" class="text-center" onclick='log_fresh'><i class="fa fa-bar-chart-o"></i> 历史记录 </a></li>
|
||||||
<td class="text-center"> {{ post.asset.ip }} </td>
|
</ul>
|
||||||
<td class="text-center"> 命令统计 </td>
|
</div>
|
||||||
<td class="text-center"> {{ post.start_time|date:"Y-m-d H:i:s"}} </td>
|
<div class="panel-body">
|
||||||
<td class="text-center"> {{ post.end_time|date:"Y-m-d H:i:s" }} </td>
|
<div class="tab-content">
|
||||||
</tr>
|
<div id="tab-1" class="ibox float-e-margins tab-pane active">
|
||||||
{% endfor %}
|
<table class="table table-striped table-bordered table-hover ">
|
||||||
</tbody>
|
<thead>
|
||||||
</table>
|
<tr>
|
||||||
|
<th class="text-center"> 用户名 </th>
|
||||||
|
<th class="text-center"> 登录主机 </th>
|
||||||
|
<th class="text-center"> 实时监控 </th>
|
||||||
|
<th class="text-center"> 阻断 </th>
|
||||||
|
<th class="text-center"> 登录时间 </th>
|
||||||
|
<th class="text-center"> 结束时间 </th>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for post in online %}
|
||||||
|
<tr class="gradeX">
|
||||||
|
<td id="username" class="text-center"> {{ post.user.name }} </td>
|
||||||
|
<td id="ip" class="text-center"> {{ post.asset.ip }} </td>
|
||||||
|
<td class="text-center"><a class="monitor" filename="{{ post.log_path }}"> 监控 </a></td>
|
||||||
|
<td class="text-center"><input type="button" id="cut" class="btn btn-danger btn-xs" name="cut" value="阻断" onclick='cut("{{ post.pid }}")' /></td>
|
||||||
|
<td class="text-center"> {{ post.start_time|date:"Y-m-d H:i:s" }} </td>
|
||||||
|
<td class="text-center"> {{ post.end_time|date:"Y-m-d H:i:s" }} </td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div id="tab-2" class="ibox float-e-margins tab-pane">
|
||||||
|
<table class="table table-striped table-bordered table-hover ">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="text-center"> 用户名 </th>
|
||||||
|
<th class="text-center"> 登录主机 </th>
|
||||||
|
<th class="text-center"> 命令统计 </th>
|
||||||
|
<th class="text-center"> 登录时间 </th>
|
||||||
|
<th class="text-center"> 结束时间 </th>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for post in offline %}
|
||||||
|
<tr class="gradeX">
|
||||||
|
<td class="text-center"> {{ post.user.name }} </td>
|
||||||
|
<td class="text-center"> {{ post.asset.ip }} </td>
|
||||||
|
<td class="text-center"> 命令统计 </td>
|
||||||
|
<td class="text-center"> {{ post.start_time|date:"Y-m-d H:i:s"}} </td>
|
||||||
|
<td class="text-center"> {{ post.end_time|date:"Y-m-d H:i:s" }} </td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -103,6 +135,8 @@
|
||||||
var node = $(e.target);
|
var node = $(e.target);
|
||||||
message.id = genUid();
|
message.id = genUid();
|
||||||
message.filename = node.attr('filename');
|
message.filename = node.attr('filename');
|
||||||
|
var username = $('#username')[0].innerText;
|
||||||
|
var ip = $('#ip')[0].innerText;
|
||||||
BootstrapDialog.show({message:function(){
|
BootstrapDialog.show({message:function(){
|
||||||
var escapeString = function (html){
|
var escapeString = function (html){
|
||||||
var elem = document.createElement('div')
|
var elem = document.createElement('div')
|
||||||
|
@ -110,7 +144,7 @@
|
||||||
elem.appendChild(txt)
|
elem.appendChild(txt)
|
||||||
return elem.innerHTML;
|
return elem.innerHTML;
|
||||||
}
|
}
|
||||||
var tag = $('<div id="log" style="height: 500px;overflow: auto;"></div>');
|
var tag = $('<div id="log" style="height: 500px;overflow: auto;background-color: rgba(0, 0, 0, 0);"></div>');
|
||||||
//告诉服务器端有用户登录
|
//告诉服务器端有用户登录
|
||||||
socket.emit('login', {userid:message.id, filename:message.filename});
|
socket.emit('login', {userid:message.id, filename:message.filename});
|
||||||
socket.on('message',function(obj){
|
socket.on('message',function(obj){
|
||||||
|
@ -123,7 +157,7 @@
|
||||||
tag[0].style.color = "#00FF00";
|
tag[0].style.color = "#00FF00";
|
||||||
return tag[0];
|
return tag[0];
|
||||||
} ,
|
} ,
|
||||||
title:'Jumpserver实时监控:',
|
title:'Jumpserver实时监控 '+' 登录用户名: '+'<span class="text-info">'+username+'</span>'+' 登录主机: '+'<span class="text-info">'+ip,
|
||||||
onhide:function(){
|
onhide:function(){
|
||||||
socket.emit('disconnect');
|
socket.emit('disconnect');
|
||||||
}});
|
}});
|
||||||
|
@ -144,5 +178,25 @@
|
||||||
SOCKET_HOST: "{{ web_socket_host }}"
|
SOCKET_HOST: "{{ web_socket_host }}"
|
||||||
}
|
}
|
||||||
$(".monitor").webSocket()
|
$(".monitor").webSocket()
|
||||||
|
|
||||||
|
// function log_fresh(str){
|
||||||
|
// $.ajax({
|
||||||
|
// type: "GET",
|
||||||
|
// url: "/jlog/log_list/",
|
||||||
|
// data : $(".panel-body").serialize(),
|
||||||
|
// success: function(data){
|
||||||
|
// $("#tab-1").html(data);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
function cut(num){
|
||||||
|
var g_url = "/jlog/log_kill/"+num;
|
||||||
|
console.log(g_url);
|
||||||
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: g_url,
|
||||||
|
success: window.open("/jlog/","_self")
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -39,7 +39,7 @@
|
||||||
<li id="jlog">
|
<li id="jlog">
|
||||||
<a href="#"><i class="fa fa-files-o"></i> <span class="nav-label">日志审计</span><span class="fa arrow"></span></a>
|
<a href="#"><i class="fa fa-files-o"></i> <span class="nav-label">日志审计</span><span class="fa arrow"></span></a>
|
||||||
<ul class="nav nav-second-level">
|
<ul class="nav nav-second-level">
|
||||||
<li id="log_list"><a href="/jlog/log_list/">查看日志</a></li>
|
<li id="log_list"><a href="/jlog/">查看日志</a></li>
|
||||||
<li id="log_detail"><a href="/jlog/log_detail/">日志分析</a></li>
|
<li id="log_detail"><a href="/jlog/log_detail/">日志分析</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
Loading…
Reference in New Issue