From 0bb458f830dc49294e6c4562a9397bf44d9daa5d Mon Sep 17 00:00:00 2001 From: Michal Kostenec <kostenec@cesnet.cz> Date: Tue, 12 May 2015 15:04:37 +0200 Subject: [PATCH] Test for correct options for anonymisation Minor updates --- warden3/contrib/connectors/hp-kippo/README | 2 +- .../contrib/connectors/hp-kippo/warden3-kippo-sender.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/warden3/contrib/connectors/hp-kippo/README b/warden3/contrib/connectors/hp-kippo/README index 8096b5a..57ed860 100644 --- a/warden3/contrib/connectors/hp-kippo/README +++ b/warden3/contrib/connectors/hp-kippo/README @@ -56,7 +56,7 @@ D. Configuration cron SCRIPT_PATH=/opt/warden_client/ - */5 * * * * root cd $SCRIPT_PATH; warden3-kippo-sender.py > /dev/null 2>&1 + */5 * * * * root cd $SCRIPT_PATH; python warden3-kippo-sender.py > /dev/null 2>&1 Note: Repeat interval must be the same as value of 'awin'. diff --git a/warden3/contrib/connectors/hp-kippo/warden3-kippo-sender.py b/warden3/contrib/connectors/hp-kippo/warden3-kippo-sender.py index 014d256..69eb7f4 100644 --- a/warden3/contrib/connectors/hp-kippo/warden3-kippo-sender.py +++ b/warden3/contrib/connectors/hp-kippo/warden3-kippo-sender.py @@ -11,6 +11,7 @@ from time import time, gmtime, strftime from math import trunc from uuid import uuid4 from os import path +import sys import MySQLdb as my import MySQLdb.cursors as mycursors @@ -71,14 +72,16 @@ def main(): awin = aconfig.get('awin', DEFAULT_AWIN) * 60 wconfig['name'] = aname + wclient = Client(**wconfig) aanonymised = aconfig.get('anonymised', DEFAULT_ANONYMISED) - atargetnet = aconfig.get('target_net', DEFAULT_TARGET_NET) + if aanonymised not in ['no', 'yes', 'omit']: + wclient.logger.error("Configuration error: anonymised: '%s' - possible typo? use 'no', 'yes' or 'omit'" % aanonymised) + sys.exit(2) + atargetnet = aconfig.get('target_net', DEFAULT_TARGET_NET) aanonymised = aanonymised if (atargetnet != DEFAULT_TARGET_NET) or (aanonymised == 'omit') else DEFAULT_ANONYMISED - wclient = Client(**wconfig) - con = my.connect( host=aconfig['dbhost'], user=aconfig['dbuser'], passwd=aconfig['dbpass'], db=aconfig['dbname'], port=aconfig['dbport'], cursorclass=mycursors.DictCursor) -- GitLab