From fd651117a14652969b8054ea3a7257b5f4d8ea2c Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Sun, 5 Dec 2010 10:08:43 +0000 Subject: [PATCH] Bugfixing git-svn-id: http://svn.brehm-online.com/svn/my-stuff/nagios/trunk@143 ec8d2aa5-1599-4edb-8739-2b3a1bc399aa --- bin/nagios/cfg/struct.py | 42 +++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/bin/nagios/cfg/struct.py b/bin/nagios/cfg/struct.py index a019bb1..4565ce2 100755 --- a/bin/nagios/cfg/struct.py +++ b/bin/nagios/cfg/struct.py @@ -25,7 +25,7 @@ class NagiosConfigStruct(object): return repr(dump) #------------------------------------------------------ - def __init__( self, logger = None, , ignore_empty_object_props = True ): + def __init__( self, logger = None, ignore_empty_object_props = True ): "Constructor." # Logging-Setup @@ -161,6 +161,7 @@ class NagiosConfigStruct(object): verifier = NagiosObjectVerifier( logger = self.logger ) res = None args = { 'file': file, 'row': rownum } + check_type = None # Generic properties for inheritance generic_property = { @@ -170,27 +171,31 @@ class NagiosConfigStruct(object): } if key in generic_property: - try: - res = verifier.verify_property( value, generic_property[key], args ) - return ( key, res ) - except NagiosVerifyError as e: - raise NagiosConfigStructError( "Property error for {0} definition: {1}".format( object_type, e ) ) - - checktype_tupel = self.get_key_checktype( key, object_type ) - if checktype_tupel is None: - raise NagiosConfigStructError( "Invalid key {0!r} for hosttype {1!r}.".format( key, object_type ) ) - - if checktype_tupel[1] is not None: - for argkey in checktype_tupel[1]: - argval = checktype_tupel[1][argkey] - args[argkey] = argval - - if args['deprecated']: + + check_type = generic_property[key] + + else: + + checktype_tupel = self.get_key_checktype( key, object_type ) + if checktype_tupel is None: + raise NagiosConfigStructError( "Invalid key {0!r} for hosttype {1!r}.".format( key, object_type ) ) + + check_type = checktype_tupel[0] + + if checktype_tupel[1] is not None: + for argkey in checktype_tupel[1]: + argval = checktype_tupel[1][argkey] + args[argkey] = argval + + if 'deprecated' in args and args['deprecated']: self.logger.warn( "Using of a deprecated {0} property {1!r} in {2!r}({3}).".format( object_type, key, file, rownum) ) + if value is None: + return ( key, None ) + try: - res = verifier.verify_property( value, checktype_tupel[0], args ) + res = verifier.verify_property( value, check_type, args ) except NagiosVerifyError as e: raise NagiosConfigStructError( "Property error for {0} definition: {1}".format( object_type, e ) ) @@ -397,6 +402,7 @@ Returns None if the key is invalid.""" }, 'hostextinfo': { 'host_name': ( 'string', None ), + 'hostgroup_name': ( 'array', { 'deprecated': True, } ), 'notes': ( 'string', None ), 'notes_url': ( 'string', None ), 'action_url': ( 'string', None ), -- 2.39.5