|
|
|
@ -211,20 +211,21 @@ def asset_edit(request):
|
|
|
|
|
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:
|
|
|
|
|
asset_test = get_object(Asset, hostname=hostname)
|
|
|
|
|
if asset_test and asset_id != unicode(asset_test.id):
|
|
|
|
|
error = u'该主机名 %s 已存在!' % hostname
|
|
|
|
|
raise ServerError(error)
|
|
|
|
|
emg = u'该主机名 %s 已存在!' % hostname
|
|
|
|
|
raise ServerError(emg)
|
|
|
|
|
except ServerError:
|
|
|
|
|
pass
|
|
|
|
|
else:
|
|
|
|
|
if af_post.is_valid():
|
|
|
|
|
print 'hehe', af_post
|
|
|
|
|
af_save = af_post.save(commit=False)
|
|
|
|
|
if use_default_auth:
|
|
|
|
|
af_save.username = ''
|
|
|
|
|
af_save.password = ''
|
|
|
|
|
af_save.port = ''
|
|
|
|
|
else:
|
|
|
|
|
if password_old != password:
|
|
|
|
|
password_encode = CRYPTOR.encrypt(password)
|
|
|
|
@ -237,9 +238,10 @@ def asset_edit(request):
|
|
|
|
|
info = asset_diff(af_post.__dict__.get('initial'), request.POST)
|
|
|
|
|
db_asset_alert(asset, username, info)
|
|
|
|
|
|
|
|
|
|
msg = u'主机 %s 修改成功' % ip
|
|
|
|
|
smg = u'主机 %s 修改成功' % ip
|
|
|
|
|
else:
|
|
|
|
|
emg = u'主机 %s 修改失败' % ip
|
|
|
|
|
return my_render('jasset/error.html', locals(), request)
|
|
|
|
|
return HttpResponseRedirect('/jasset/asset_detail/?id=%s' % asset_id)
|
|
|
|
|
|
|
|
|
|
return my_render('jasset/asset_edit.html', locals(), request)
|
|
|
|
@ -414,7 +416,7 @@ def asset_update(request):
|
|
|
|
|
if not asset:
|
|
|
|
|
return HttpResponseRedirect('/jasset/asset_detail/?id=%s' % asset_id)
|
|
|
|
|
else:
|
|
|
|
|
asset_ansible_update(asset_list, name)
|
|
|
|
|
asset_ansible_update([asset], name)
|
|
|
|
|
return HttpResponseRedirect('/jasset/asset_detail/?id=%s' % asset_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|