Exemple #1
0
def order_detail(request, id,format=None):
    """
    Retrieve, update or delete a server assets instance.
    """
    try:
        snippet = Order_System.objects.get(id=id)
    except Order_System.DoesNotExist:
        return Response(status=status.HTTP_404_NOT_FOUND)
    if request.method == 'PUT':
        if int(request.data.get('order_status')) == 7:
            sendOrderNotice.delay(id,mask='【已取消】')  
        elif int(request.data.get('order_status')) == 8:
            sendOrderNotice.delay(id,mask='【已授权】')  
        elif int(request.data.get('order_status')) == 3:
            sendOrderNotice.delay(id,mask='【已部署】')         
        serializer = serializers.OrderSerializer(snippet, data=request.data)
        if serializer.is_valid():
            serializer.save()
            return Response(serializer.data)
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
     
    elif request.method == 'DELETE':
        if not request.user.has_perm('OpsManage.can_delete_order_system'):
            return Response(status=status.HTTP_403_FORBIDDEN)
        snippet.delete()
        return Response(status=status.HTTP_204_NO_CONTENT) 
Exemple #2
0
                order_project=project,
                order_content=request.POST.get('order_content'),
                order_branch=request.POST.get('order_branch', None),
                order_comid=request.POST.get('order_comid', None),
                order_tag=request.POST.get('order_tag', None))
        except Exception, ex:
            logger.error(msg="项目部署申请失败: {ex}".format(ex=str(ex)))
            return render(
                request,
                'orders/deploy_apply.html',
                {
                    "user": request.user,
                    "errorInfo": "项目部署申请失败:%s" % str(ex)
                },
            )
        sendOrderNotice.delay(order_id=order.id, mask='【申请中】')
        return HttpResponseRedirect('/order/deploy/apply/{id}/'.format(id=pid))


@login_required()
@permission_required('orders.can_read_sql_audit_order', login_url='/noperm/')
def db_sqlorder_audit(request):
    try:
        config = SQL_Audit_Control.objects.get(id=1)
    except:
        return render(request, 'orders/db_sqlorder_audit.html', {
            "user": request.user,
            "errinfo": "请先在数据管理-基础配置-SQL工单审核配置,做好相关配置。"
        })
    if request.method == "GET":
        try:
Exemple #3
0
                                                             errormessage = ds.get('errmsg'),
                                                             sqltext =  ds.get('sql'),
                                                             affectrow = ds.get('affected_rows'),
                                                             sequence = ds.get('sequence'),
                                                             backup_db = ds.get('backup_dbname'),
                                                             execute_time = ds.get('execute_time'),
                                                             sqlsha = ds.get('sqlsha1'),
                                                             )
                 except Exception, ex:
                     logger.error(msg="记录SQL错误: {ex}".format(ex=str(ex)))
                 if ds.get('errlevel') > 0 and ds.get('errmsg'):count = count + 1
                 sList.append({'sql':ds.get('sql'),'row':ds.get('affected_rows'),'errmsg':ds.get('errmsg')})
             if count > 0:
                 order.order_status = 9
                 order.save()      
                 sendOrderNotice.delay(order.id,mask='【执行失败】')                   
                 return JsonResponse({'msg':"执行失败,请检查SQL语句","code":500,'data':sList})
             else:
                 order.order_status = 5
                 order.save()
                 sendOrderNotice.delay(order.id,mask='【已执行】') 
                 return JsonResponse({'msg':"SQL执行成功","code":200,'data':sList})
         else:
             return JsonResponse({'msg':result.get('errinfo'),"code":500,'data':[]}) 
     except Exception, ex:
         logger.error(msg="执行SQL[{id}]错误: {ex}".format(id=id,ex=str(ex)))
         return JsonResponse({'msg':str(ex),"code":200,'data':[]})  
 elif order.sql_audit_order.order_type == 'file':
     filePath = os.getcwd() + '/upload/' + str(order.sql_audit_order.order_file)
     rc,rs = mysql.loads(    
                         host=order.sql_audit_order.order_db.db_host,
Exemple #4
0
                 sqlsha=ds.get('sqlsha1'),
             )
         except Exception, ex:
             logger.error(msg="记录SQL错误: {ex}".format(
                 ex=str(ex)))
         if ds.get('errlevel') > 0 and ds.get('errmsg'):
             count = count + 1
         sList.append({
             'sql': ds.get('sql'),
             'row': ds.get('affected_rows'),
             'errmsg': ds.get('errmsg')
         })
     if count > 0:
         order.order_status = 9
         order.save()
         sendOrderNotice.delay(order.id, mask='【执行失败】')
         return JsonResponse({
             'msg': "执行失败,请检查SQL语句",
             "code": 500,
             'data': sList
         })
     else:
         order.order_status = 5
         order.save()
         sendOrderNotice.delay(order.id, mask='【已执行】')
         return JsonResponse({
             'msg': "SQL执行成功",
             "code": 200,
             'data': sList
         })
 else:
Exemple #5
0
        except Exception,ex:
            logger.error(msg="项目部署申请失败: {ex}".format(ex=str(ex)))
            return render(request,'orders/deploy_apply.html',{"user":request.user,"errorInfo":"项目部署申请失败:%s" % str(ex)},)    
        try:
            Project_Order.objects.create(
                                         order = order,
                                         order_project = project,
                                         order_content = request.POST.get('order_content'),
                                         order_branch = request.POST.get('order_branch',None),
                                         order_comid = request.POST.get('order_comid',None),
                                         order_tag  = request.POST.get('order_tag',None)                                         
                                         )
        except Exception,ex:      
            logger.error(msg="项目部署申请失败: {ex}".format(ex=str(ex)))
            return render(request,'orders/deploy_apply.html',{"user":request.user,"errorInfo":"项目部署申请失败:%s" % str(ex)},)                 
        sendOrderNotice.delay(order_id=order.id,mask='【申请中】')
        return HttpResponseRedirect('/order/deploy/apply/{id}/'.format(id=pid))  


@login_required()
@permission_required('orders.can_read_sql_audit_order',login_url='/noperm/')
def db_sqlorder_audit(request):
    try:
        config = SQL_Audit_Control.objects.get(id=1)  
    except:
        return render(request,'orders/db_sqlorder_audit.html',{"user":request.user,"errinfo":"请先在数据管理-基础配置-SQL工单审核配置,做好相关配置。"})
    if request.method == "GET":
        try:
            try:
                audit_group = []
                for g in json.loads(config.audit_group):