@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']
#------------------------------------------------------