@csrf_exempt
def addChangeDbInstanceInfo(request):
    '\n            新增数据库实例\n            修改数据库实例\n    '
    v_instanceId = request.POST.get('instance_id')
    v_groupId = request.POST.get('group_id')
    v_host_id = request.POST.get('host_id')
    v_instanceName = request.POST.get('instance_env')
    v_instanceType = request.POST.get('instance_type')
    v_portNum = request.POST.get('port_num')
    v_instanceRole = request.POST.get('instance_role')
    v_instanceStatus = request.POST.get('instance_status')
    v_instanceDesc = request.POST.get('instance_desc')
    print(v_instanceId, v_groupId, v_host_id, v_instanceName, v_instanceType, v_portNum, v_instanceRole, v_instanceStatus, v_instanceDesc)
    logger.info('保存或修改数据库实例信息，接收前端参数：', v_instanceId, v_groupId, v_host_id, v_instanceName, v_instanceType, v_portNum, v_instanceRole, v_instanceStatus, v_instanceDesc)
    if ((v_instanceId == '') or (v_instanceId is None)):
        try:
            dbGroupObj = dbGroup.objects.get(id=v_groupId)
            hostObj = host.objects.get(id=v_host_id)
            print(hostObj)
            dbInstanceObj = dbInstance(groupName=dbGroupObj, host=hostObj, instanceName=v_instanceName, instanceType=v_instanceType, portNum=v_portNum, instanceRole=v_instanceRole, instanceStatus=v_instanceStatus, instanceDesc=v_instanceDesc)
            dbInstanceObj.save()
            result = {'status': 1, 'msg': '保存成功!', 'data': ''}
            return HttpResponse(json.dumps(result), content_type='application/json')
        except Exception as e:
            print(e)
            logger.error(str(e))
            result = {'status': 2, 'msg': '保存失败!', 'data': ''}
            return HttpResponse(json.dumps(result), content_type='application/json')
    else:
        try:
            dbGroupObj = dbGroup.objects.get(id=v_groupId)
            hostObj = host.objects.get(id=v_host_id)
            dbInstanceObj = dbInstance.objects.filter(id=v_instanceId)
            dbInstanceObj.update(groupName=dbGroupObj, host=hostObj, instanceName=v_instanceName, instanceType=v_instanceType, portNum=v_portNum, instanceRole=v_instanceRole, instanceStatus=v_instanceStatus, instanceDesc=v_instanceDesc)
            result = {'status': 1, 'msg': '修改成功!', 'data': ''}
            return HttpResponse(json.dumps(result), content_type='application/json')
        except Exception as e:
            logger.error(str(e))
            result = {'status': 2, 'msg': '修改失败!', 'data': ''}
            return HttpResponse(json.dumps(result), content_type='application/json')
新增数据库实例
修改数据库实例
@csrf_exempt
def addChangeDbInstanceInfo(request):
    '\n            新增数据库实例\n            修改数据库实例\n    '
    v_instanceId = request.POST.get('instance_id')
    v_groupId = request.POST.get('group_id')
    v_host_id = request.POST.get('host_id')
    v_instanceName = request.POST.get('instance_env')
    v_instanceType = request.POST.get('instance_type')
    v_portNum = request.POST.get('port_num')
    v_instanceRole = request.POST.get('instance_role')
    v_instanceStatus = request.POST.get('instance_status')
    v_instanceDesc = request.POST.get('instance_desc')
    print(v_instanceId, v_groupId, v_host_id, v_instanceName, v_instanceType, v_portNum, v_instanceRole, v_instanceStatus, v_instanceDesc)
    logger.info('保存或修改数据库实例信息，接收前端参数：', v_instanceId, v_groupId, v_host_id, v_instanceName, v_instanceType, v_portNum, v_instanceRole, v_instanceStatus, v_instanceDesc)
    if ((v_instanceId == ) or (v_instanceId is None)):
        try:
            dbGroupObj = dbGroup.objects.get(id=v_groupId)
            hostObj = host.objects.get(id=v_host_id)
            print(hostObj)
            dbInstanceObj = dbInstance(groupName=dbGroupObj, host=hostObj, instanceName=v_instanceName, instanceType=v_instanceType, portNum=v_portNum, instanceRole=v_instanceRole, instanceStatus=v_instanceStatus, instanceDesc=v_instanceDesc)
            dbInstanceObj.save()
            result = {'status': 1, 'msg': '保存成功!', 'data': }
            return HttpResponse(json.dumps(result), content_type='application/json')
        except Exception as e:
            print(e)
            logger.error(str(e))
            result = {'status': 2, 'msg': '保存失败!', 'data': }
            return HttpResponse(json.dumps(result), content_type='application/json')
    else:
        try:
            dbGroupObj = dbGroup.objects.get(id=v_groupId)
            hostObj = host.objects.get(id=v_host_id)
            dbInstanceObj = dbInstance.objects.filter(id=v_instanceId)
            dbInstanceObj.update(groupName=dbGroupObj, host=hostObj, instanceName=v_instanceName, instanceType=v_instanceType, portNum=v_portNum, instanceRole=v_instanceRole, instanceStatus=v_instanceStatus, instanceDesc=v_instanceDesc)
            result = {'status': 1, 'msg': '修改成功!', 'data': }
            return HttpResponse(json.dumps(result), content_type='application/json')
        except Exception as e:
            logger.error(str(e))
            result = {'status': 2, 'msg': '修改失败!', 'data': }
            return HttpResponse(json.dumps(result), content_type='application/json')