parameters: (self, request)
return_statement: return HttpResponse(json.dumps({'data': 'no data'}))
docstring: 用设置salt 报警和，不在salt里面的服务器 下线操作
docstring_summary: 用设置salt 报警和，不在salt里面的服务器 下线操作
docstring_tokens: 用设置salt 报警和，不在salt里面的服务器 下线操作
function: def delete(self, request):
          '''用设置salt 报警和，不在salt里面的服务器 下线操作'''
          print("----------------delete", request.GET)
          data = request.GET.get('data')
          err = request.GET.get('err')
          # 设置下线
          if data:
              salt_id = json.loads(data)
              models.Host.objects.filter(salt_id=salt_id).update(status="2")
              host_id = models.Host.objects.filter(salt_id=salt_id).values("id")[0]['id']
              models.Log.objects.create(host_ip_id=host_id, level="warning", message=u"设置为下线状态")
              return HttpResponse(json.dumps({'data': 'ok delete'}))
          # salt链接失败
          if err:
              err_ip = json.loads(err)
              host_id = models.Host.objects.filter(salt_id=err_ip).values("id")
              if host_id:
                  models.Log.objects.create(host_ip_id=host_id[0]['id'], level="error", message=u"salt 连接失败,导致更新失败.")
              return HttpResponse(json.dumps({'data': 'ok err'}))
          return HttpResponse(json.dumps({'data': 'no data'}))
function_tokens: def delete ( self , request ) : print ( "----------------delete" , request . GET ) data = request . GET . get ( 'data' ) err = request . GET . get ( 'err' ) # 设置下线 if data : salt_id = json . loads ( data ) models . Host . objects . filter ( salt_id = salt_id ) . update ( status = "2" ) host_id = models . Host . objects . filter ( salt_id = salt_id ) . values ( "id" ) [ 0 ] [ 'id' ] models . Log . objects . create ( host_ip_id = host_id , level = "warning" , message = u"设置为下线状态") return HttpResponse ( json . dumps ( { 'data' : 'ok delete' } ) ) # salt链接失败 if err : err_ip = json . loads ( err ) host_id = models . Host . objects . filter ( salt_id = err_ip ) . values ( "id" ) if host_id : models . Log . objects . create ( host_ip_id = host_id [ 0 ] [ 'id' ] , level = "error" , message = u"salt 连接失败,导致更新失败.") return HttpResponse ( json . dumps ( { 'data' : 'ok err' } ) ) return HttpResponse ( json . dumps ( { 'data' : 'no data' } ) )