From 0d14546f801c28d7be93fd818db718e98357f0d8 Mon Sep 17 00:00:00 2001 From: Jorrit Schaap <schaap@astron.nl> Date: Fri, 18 Mar 2016 12:42:41 +0000 Subject: [PATCH] Task #8887: use proper default notification busname, prefix, subject --- .../ResourceAssignmentDatabase/config.py | 5 +++-- .../ResourceAssignmentDatabase/radbbuslistener.py | 4 ++-- .../ResourceAssignmentDatabase/radbpglistener.py | 10 +++++----- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/SAS/ResourceAssignment/ResourceAssignmentDatabase/config.py b/SAS/ResourceAssignment/ResourceAssignmentDatabase/config.py index d8a6964dc60..dabf0b2a375 100644 --- a/SAS/ResourceAssignment/ResourceAssignmentDatabase/config.py +++ b/SAS/ResourceAssignment/ResourceAssignmentDatabase/config.py @@ -1,5 +1,6 @@ #!/usr/bin/python # $Id$ -DEFAULT_BUSNAME = 'lofar.ra.notification' -DEFAULT_NOTIFICATION_SUBJECT_PREFIX = 'RADB.' +DEFAULT_NOTIFICATION_BUSNAME = 'lofar.ra.notification' +DEFAULT_NOTIFICATION_PREFIX = 'RADB.' +DEFAULT_NOTIFICATION_SUBJECTS=DEFAULT_NOTIFICATION_PREFIX+'*' diff --git a/SAS/ResourceAssignment/ResourceAssignmentDatabase/radbbuslistener.py b/SAS/ResourceAssignment/ResourceAssignmentDatabase/radbbuslistener.py index 627e05ab311..0939c4e98c0 100644 --- a/SAS/ResourceAssignment/ResourceAssignmentDatabase/radbbuslistener.py +++ b/SAS/ResourceAssignment/ResourceAssignmentDatabase/radbbuslistener.py @@ -28,7 +28,7 @@ Typical usage is to derive your own subclass from RADBBusListener and implement """ from lofar.messaging.messagebus import AbstractBusListener -from lofar.sas.resourceassignment.database.config import DEFAULT_BUSNAME +from lofar.sas.resourceassignment.database.config import DEFAULT_NOTIFICATION_BUSNAME, DEFAULT_NOTIFICATION_SUBJECTS from lofar.common.util import waitForInterrupt import qpid.messaging @@ -39,7 +39,7 @@ logger = logging.getLogger(__name__) class RADBBusListener(AbstractBusListener): - def __init__(self, busname=DEFAULT_BUSNAME, subject='RADB.*', broker=None, **kwargs): + def __init__(self, busname=DEFAULT_NOTIFICATION_BUSNAME, subject=DEFAULT_NOTIFICATION_SUBJECTS, broker=None, **kwargs): """ RADBBusListener listens on the lofar notification message bus and calls (empty) on<SomeMessage> methods when such a message is received. Typical usage is to derive your own subclass from RADBBusListener and implement the specific on<SomeMessage> methods that you are interested in. diff --git a/SAS/ResourceAssignment/ResourceAssignmentDatabase/radbpglistener.py b/SAS/ResourceAssignment/ResourceAssignmentDatabase/radbpglistener.py index b94781cb09f..884344c7e7e 100644 --- a/SAS/ResourceAssignment/ResourceAssignmentDatabase/radbpglistener.py +++ b/SAS/ResourceAssignment/ResourceAssignmentDatabase/radbpglistener.py @@ -32,15 +32,15 @@ from optparse import OptionParser from lofar.common.postgres import PostgresListener, makePostgresNotificationQueries from lofar.messaging import EventMessage, ToBus -from lofar.sas.resourceassignment.database.config import DEFAULT_BUSNAME, DEFAULT_NOTIFICATION_SUBJECT_PREFIX +from lofar.sas.resourceassignment.database.config import DEFAULT_NOTIFICATION_BUSNAME, DEFAULT_NOTIFICATION_PREFIX from lofar.common import dbcredentials logger = logging.getLogger(__name__) class RADBPGListener(PostgresListener): def __init__(self, - busname=DEFAULT_BUSNAME, - notification_prefix=DEFAULT_NOTIFICATION_SUBJECT_PREFIX, + busname=DEFAULT_NOTIFICATION_BUSNAME, + notification_prefix=DEFAULT_NOTIFICATION_PREFIX, dbcreds=None, broker=None): super(RADBPGListener, self).__init__(dbcreds.host, dbcreds.database, dbcreds.user, dbcreds.password) @@ -140,8 +140,8 @@ def main(): parser = OptionParser("%prog [options]", description='runs the radb postgres listener which listens to changes on some tables in the radb and publishes the changes as notifications on the bus.') parser.add_option('-q', '--broker', dest='broker', type='string', default=None, help='Address of the qpid broker, default: localhost') - parser.add_option("-b", "--busname", dest="busname", type="string", default=DEFAULT_BUSNAME, help="Name of the publication bus on the qpid broker, [default: %default]") - parser.add_option("-n", "--notification_prefix", dest="notification_prefix", type="string", default=DEFAULT_NOTIFICATION_SUBJECT_PREFIX, help="The prefix for all notifications of this publisher, [default: %default]") + parser.add_option("-b", "--busname", dest="busname", type="string", default=DEFAULT_NOTIFICATION_BUSNAME, help="Name of the publication bus on the qpid broker, [default: %default]") + parser.add_option("-n", "--notification_prefix", dest="notification_prefix", type="string", default=DEFAULT_NOTIFICATION_PREFIX, help="The prefix for all notifications of this publisher, [default: %default]") parser.add_option_group(dbcredentials.options_group(parser)) parser.set_defaults(dbcredentials="RADB") (options, args) = parser.parse_args() -- GitLab