From 5530d7cc27a0a9552cd027600afc8e0ccb1a4827 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 21 Dec 2018 17:48:20 +0100 Subject: [PATCH] ctrl2cgi: explicitly ignore unrelated TRAPs Previously we've tried to determine the type of TRAP and handle as many as possible via generic method dispatcher similar to parent class. Let's make code simpler by explicitly ignoring all but 'location-state' TRAPs. This should also reduce debug log output because we'll only log the TRAP variable for ignored messages instead of entire content. Change-Id: I42b715cb82eb309950ff387649726504b6c7cf61 Related: SYS#4399 --- scripts/ctrl2cgi.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/scripts/ctrl2cgi.py b/scripts/ctrl2cgi.py index 2cf386c..bb5c93e 100755 --- a/scripts/ctrl2cgi.py +++ b/scripts/ctrl2cgi.py @@ -22,7 +22,7 @@ */ """ -__version__ = "0.0.9" # bump this on every non-trivial change +__version__ = "0.1.0" # bump this on every non-trivial change import argparse, os, logging, logging.handlers, datetime import hashlib @@ -89,11 +89,11 @@ class Trap(CTRL): """ Parse CTRL TRAP and dispatch to appropriate handler after normalization """ - self.factory.log.debug('TRAP %s' % v) - t_type = get_type(v) - p = p_h(v) - method = getattr(self, 'handle_' + t_type.replace('-', ''), lambda *_: "Unhandled %s trap" % t_type) - method(p(1), p(3), p(5), p(7), get_r(v)) + if get_type(v) == 'location-state': + p = p_h(v) + self.handle_locationstate(p(1), p(3), p(5), p(7), get_r(v)) + else: + self.factory.log.debug('Ignoring TRAP %s' % (v.split()[0])) def ctrl_SET_REPLY(self, data, _, v): """ @@ -126,12 +126,6 @@ class Trap(CTRL): # Ensure that we run only limited number of requests in parallel: self.factory.semaphore.run(make_async_req, t, self.factory.location, params, self.transport.write, self.factory.log, self.factory.timeout) - def handle_notificationrejectionv1(self, net, bsc, bts, trx, data): - """ - Handle notification-rejection-v1 TRAP: just an example to show how more message types can be handled - """ - self.factory.log.debug('notification-rejection-v1@bsc-id %s => %s' % (bsc, data)) - class TrapFactory(IPAFactory): """