Exemplo n.º 1
0
def collector_make_rules(request, product_id):
    tracker_manger = CTrackerManagerService(product_id)
    new_rules = tracker_manger.make_rule()
    tracker_manger.stop_tracker()
    tracker_manger.clear_buffer()
    params = {'created_rules': [],
              'product_id': product_id}
    if new_rules.get('status'):
        params['created_rules'] = new_rules.get('created_rules')
    else:
        params['error'] = new_rules.get('message')

    return render_to_response('admin/create_new_rules.html', params,
                                  RequestContext(request))
Exemplo n.º 2
0
        confirm_rules = self._find_need_rules(method, url, body, product)
        if confirm_rules:
            rule = self._get_rule_with_biggest_weight(confirm_rules)
            CKibanaLog({'module': 'RULE_IS',
                        'rule': str(rule)})
            try:
                response = self._make_response_content(rule)
            except Exception, e:
                CKibanaLog({'exception': str(e),
                            'module': 'ERROR_MAKE_RESPONSE'})
        else:
            CKibanaLog({'module': 'WITHOUT_RULE',
                        'message': 'rule is None'})

        try:
            tracker_manager = CTrackerManagerService(product)
            tracker_manager.write(method, url, body, rule)
        except:
            pass
        return response

    def _product_conformity(self, raw_headers):
        uniq_header = raw_headers.get('cproxy-ProductId', None)
        if not uniq_header:
            return None
        self._uniq_header = uniq_header[0]
        product = Product.objects.filter(unique_header=uniq_header[0])
        if len(product) == 0:
            return None
        return product[0]
Exemplo n.º 3
0
def return_from_collect(request, product_id):
    tracker_manger = CTrackerManagerService(product_id)
    tracker_manger.stop_tracker()
    tracker_manger.clear_buffer()
    return redirect('admin:core_product_change', product_id)
Exemplo n.º 4
0
def collector_clear(request, product_id):
    tracker_manger = CTrackerManagerService(product_id)
    tracker_manger.clear_buffer()
    return HttpResponse(json.dumps(tracker_manger.get_message()),
                        content_type="application/json")
Exemplo n.º 5
0
def collector_collect(request, product_id):
    tracker_manger = CTrackerManagerService(product_id)
    return HttpResponse(json.dumps(tracker_manger.get_collect()),
                        content_type="application/json")