Hi,

I wanted to write a module which provides host and contact definitions
to the arbiter.
That worked out pretty good for the host definitions - so far so good.
But the host definitions are the only configuration values that can be
added by modules - because it's hard coded in the arbiter.

I don't know if that is inteded for security reasons or just becaus of a
quick implementation.
If you are interested, I have attached a patch which uses the
types_creations of the configuration for dynamical detection of
configuration "sections" and allows modules to add properties to the
configuration, such as contacts, hostgroups, etc. pp.

Sorry, if the code does not meet your formatting patterns - I was just
glad to get it working for now. ;-)
If you decide to use the code, please double check it, as I am not too
firm to python programming yet. Especially the existance checks may not
be the optimal choice.. but they (seem to) work.

Kris

diff --git a/bin/shinken-arbiter b/bin/shinken-arbiter
index 7cdee90..e899568 100755
--- a/bin/shinken-arbiter
+++ b/bin/shinken-arbiter
@@ -323,7 +323,7 @@ class Arbiter(Daemon):
         #so we can ask them some objects too
         self.conf.create_objects_for_type(raw_objects, 'arbiter')
         self.conf.create_objects_for_type(raw_objects, 'module')
-
+ 
 
         self.conf.early_arbiter_linking()
 
@@ -367,13 +367,26 @@ class Arbiter(Daemon):
                 if 'configuration' in inst.properties['phases']:
                     try :
                         r = inst.get_objects()
-                        for h in r['hosts']:
-                            raw_objects['host'].append(h)
+			types_creations = self.conf.types_creations
+			for k in types_creations:
+				(cls, clss, prop) = types_creations[k]
+				try:
+	                        	for x in r[prop]:
+						# test if raw_objects[k] is already set - if not, add empty array
+						try:
+							_test = raw_objects[k]
+						except Exception, exExistanceTest2:
+							raw_objects[k] = []
+						# now append the object
+		                    		raw_objects[k].append(x)
+					print "Added %i objects to %s from module %s" % (len(r[prop]), k, inst.get_name())
+				except Exception, exExistanceTest1:
+					# just ignore it - the property is not used by module
+					_test = None # at least do something
                     except Exception, exp:
                         print "The instance %s raise an exception %s. I remove it" % (inst.get_name(), str(exp))
 
-
-        ### Resume standard operations ###
+       ### Resume standard operations ###
         self.conf.create_objects(raw_objects)
 
 	#Maybe conf is already invalid
@@ -435,9 +448,6 @@ class Arbiter(Daemon):
         # Look for business rules, and create teh dep trees
         self.conf.create_business_rules()
 
-        # And link them
-        self.conf.create_business_rules_dependencies()
-
         #************* Print warning about useless parameters in Shinken **************"
         self.conf.notice_about_useless_parameters()
 
------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Shinken-devel mailing list
Shinken-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/shinken-devel

Reply via email to