Пример #1
0
                                                       port=incept.db_backup_port, tableName=tableName,
                                                       sequence=str(ds.sequence).replace('\'',''),
                                                       ) 
                    if rbkSql.get('status') == 'success': 
                        for sql in rbkSql.get('data'):
                            rollBackSql.append(sql[0])                         
            if rollBackSql:
                rbkSql = Inception(
                                   host=order.sql_audit_order.order_db.db_host,
                                   name=order.sql_audit_order.order_db.db_name,
                                   user=order.sql_audit_order.order_db.db_user,
                                   passwd=order.sql_audit_order.order_db.db_passwd,
                                   port=order.sql_audit_order.order_db.db_port                                   
                                   )
                for sql in rollBackSql:
                    result = rbkSql.rollback(sql)
                    if result.get('status') == 'error':#回滚时如果其中一条出现错误就停止回滚 
                        return JsonResponse({'msg':"SQL回滚失败:" + result.get('errinfo'),"code":500,'data':[]})
                #回滚语句如果全部执行成功则修改状态
                order.order_status = 6
                order.save()         
                sendOrderNotice.delay(order.id,mask='【已回滚】')                     
                return JsonResponse({'msg':"SQL回滚成功","code":200,'data':[]})           
            else:    
                return JsonResponse({'msg':"没有需要执行的回滚SQL语句","code":500,'data':[]})    
        else:
            return JsonResponse({'msg':"SQL已经被执行","code":500,'data':[]})    
        
        
@login_required()
@permission_required('OpsManage.change_sql_audit_control',login_url='/noperm/')
Пример #2
0
                 user=incept.db_backup_user,
                 passwd=incept.db_backup_passwd,
                 dbName=ds.backup_db,
                 port=incept.db_backup_port,
                 tableName=tableName,
                 sequence=str(ds.sequence).replace('\'', ''),
             )
         if rbkSql.get('status') == 'success':
             rollBackSql.append(rbkSql.get('data')[0])
 if rollBackSql:
     rbkSql = Inception(host=order.order_db.db_host,
                        name=order.order_db.db_name,
                        user=order.order_db.db_user,
                        passwd=order.order_db.db_passwd,
                        port=order.order_db.db_port)
     result = rbkSql.rollback(','.join(rollBackSql))
     if result.get('status') == 'success':
         order.order_status = 3
         order.save()
         sendSqlEmail.delay(order.id, mask='【已回滚】')
         return JsonResponse({
             'msg': "SQL回滚成功",
             "code": 200,
             'data': []
         })
     else:
         return JsonResponse({
             'msg':
             "SQL回滚失败:" + result.get('errinfo'),
             "code":
             500,
Пример #3
0
                        tableName = result.get('data')[0]
                        rbkSql = Inception.getRollBackSQL(
                                                       host=incept.db_backup_host, user=incept.db_backup_user, 
                                                       passwd=incept.db_backup_passwd, dbName=ds.backup_db, 
                                                       port=incept.db_backup_port, tableName=tableName,
                                                       sequence=str(ds.sequence).replace('\'',''),
                                                       ) 
                    if rbkSql.get('status') == 'success': 
                        rollBackSql.append(rbkSql.get('data')[0])
            if rollBackSql:
                rbkSql = Inception(
                                   host=order.order_db.db_host,name=order.order_db.db_name,
                                   user=order.order_db.db_user,passwd=order.order_db.db_passwd,
                                   port=order.order_db.db_port                                   
                                   )
                result = rbkSql.rollback(','.join(rollBackSql))
                if result.get('status') == 'success': 
                    order.order_status = 3
                    order.save()         
                    sendSqlNotice.delay(order.id,mask='【已回滚】')           
                    return JsonResponse({'msg':"SQL回滚成功","code":200,'data':[]})  
                else:
                    return JsonResponse({'msg':"SQL回滚失败:" + result.get('errinfo'),"code":500,'data':[]})   
            else:    
                return JsonResponse({'msg':"没有需要执行的回滚SQL语句","code":500,'data':[]})    
        else:
            return JsonResponse({'msg':"SQL已经被执行","code":500,'data':[]})    
        
        
@login_required()
@permission_required('OpsManage.change_sql_audit_control',login_url='/noperm/')
Пример #4
0
                 port=incept.db_backup_port,
                 tableName=tableName,
                 sequence=str(ds.sequence).replace('\'', ''),
             )
         if rbkSql.get('status') == 'success':
             for sql in rbkSql.get('data'):
                 rollBackSql.append(sql[0])
 if rollBackSql:
     rbkSql = Inception(
         host=order.sql_audit_order.order_db.db_host,
         name=order.sql_audit_order.order_db.db_name,
         user=order.sql_audit_order.order_db.db_user,
         passwd=order.sql_audit_order.order_db.db_passwd,
         port=order.sql_audit_order.order_db.db_port)
     for sql in rollBackSql:
         result = rbkSql.rollback(sql)
         if result.get('status') == 'error':  #回滚时如果其中一条出现错误就停止回滚
             return JsonResponse({
                 'msg':
                 "SQL回滚失败:" + result.get('errinfo'),
                 "code":
                 500,
                 'data': []
             })
     #回滚语句如果全部执行成功则修改状态
     order.order_status = 6
     order.save()
     sendOrderNotice.delay(order.id, mask='【已回滚】')
     return JsonResponse({
         'msg': "SQL回滚成功",
         "code": 200,