From: Frank Brehm Date: Wed, 15 Dec 2010 22:50:48 +0000 (+0000) Subject: Bugfixing X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=7315764684c55630f070d615b9d7eb49240725a2;p=my-stuff%2Fnagios.git Bugfixing git-svn-id: http://svn.brehm-online.com/svn/my-stuff/nagios/trunk@159 ec8d2aa5-1599-4edb-8739-2b3a1bc399aa --- diff --git a/bin/nagios/config.py b/bin/nagios/config.py index 0084620..805b601 100644 --- a/bin/nagios/config.py +++ b/bin/nagios/config.py @@ -349,37 +349,65 @@ class NagiosConfig(LoggingObject): @rtype: list ''' + pp = pprint.PrettyPrinter( indent = 4, depth = 6, width = 120 ) + + if self.verbose >= 5: + self.logger.debug( "Analyze object:\n\t{0}".format( pp.pformat( object ) ) ) + + object_file = object['__object_definition__'][0] + object_rownum = object['__object_definition__'][1] + + if object_type == 'contact' and self.verbose >= 4: + name = 'anonymous' + if 'contact_name' in object: + name = "'contact_name': " + object['contact_name'][0] + elif 'name' in object: + name = "'name': " + object['name'][0] + self.logger.debug( "Analyze Contact {0!r} from {1!r}({2}) ...".format( name, object_file, object_rownum ) ) + if not 'use' in object: + if self.verbose >= 4: + self.logger.debug( "No 'use' in object." ) return [] file = object['use'][1] row_num = object['use'][2] - pp = pprint.PrettyPrinter( indent = 4, depth = 6, width = 120 ) if 'templates' in object: - self.logger.debug( "Templates allready found, returning:\n\t{0}".format( pp.pformat( object['templates'] ) ) ) + if self.verbose >= 4: + self.logger.debug( "Templates allready found, returning:\n\t{0}".format( pp.pformat( object['templates'] ) ) ) return object['templates'] + if self.verbose >= 4: + self.logger.debug( "No templates found, go on ..." ) + object['templates'] = [] object['templates_applied'] = set([]) for template_name in object['use'][0]: + if self.verbose >= 4: + self.logger.debug( "Looking for template {0!r} ...".format( template_name ) ) if not template_name in self.templates[object_type]: raise NagiosConfigError( "Template {0!r} for {1!r} in {2!r}({3}) not found.".format( template_name, object_type, file, row_num ) ) template_id = self.templates[object_type][template_name] + if self.verbose >= 4: + self.logger.debug( "Found ID {0} for template {1!r}.".format( template_id, template_name ) ) template_object = self.objects_read[object_type][template_id] names = [ template_name ] - for name in self._retrieve_templates( object_type, template_name ): + for name in self._retrieve_templates( object_type, template_object ): names.append( name ) for name in names: - self.logger.debug( "Assigning template {0!r}.".format( name ) ) + if self.verbose >= 4: + self.logger.debug( "Assigning template {0!r}.".format( name ) ) if name in object['templates_applied']: - self.logger.debug( "Template {0!r} for {1!r} allready applied.".format( name, object_type ) ) + if self.verbose >= 3: + self.logger.debug( "Template {0!r} for {1!r} allready applied.".format( name, object_type ) ) else: object['templates'].append( name ) object['templates_applied'].add( name ) - self.logger.debug( "Templates returning:\n\t{0}".format( pp.pformat( object['templates'] ) ) ) + if self.verbose >= 4: + self.logger.debug( "Templates returning:\n\t{0}".format( pp.pformat( object['templates'] ) ) ) return object['templates'] #------------------------------------------------------