[Pkg-nagios-changes] [SCM] UNNAMED PROJECT branch, debian/master, updated. 810edbdd3feedbfe37f4a65bee50b57b2f60fa2a

Naparuba naparuba at gmail.com
Tue Feb 28 22:15:53 UTC 2012


The following commit has been merged in the debian/master branch:
commit 728099ab59c0a278ed3ac107c0f6d9c7f150a38b
Author: Naparuba <naparuba at gmail.com>
Date:   Mon Jan 23 15:46:20 2012 +0100

    Enh : change mongodb server properties into an uri one like the livestatus modules.

diff --git a/etc/shinken-specific.cfg b/etc/shinken-specific.cfg
index 734412c..246091d 100755
--- a/etc/shinken-specific.cfg
+++ b/etc/shinken-specific.cfg
@@ -446,7 +446,7 @@ define module{
 define module{
        module_name      MongodbRetention
        module_type      mongodb_retention
-       server           localhost
+       uri		mongodb://localhost
        database		shinken
 }
 
@@ -497,7 +497,7 @@ define module{
 define module{
        module_name      Mongodb
        module_type      mongodb
-       server		localhost
+       uri              mongodb://localhost
        database		shinken
 }
 
diff --git a/shinken/modules/mongodb_arbiter.py b/shinken/modules/mongodb_arbiter.py
index 34b3ba5..7c315cc 100644
--- a/shinken/modules/mongodb_arbiter.py
+++ b/shinken/modules/mongodb_arbiter.py
@@ -40,17 +40,17 @@ properties = {
 # called by the plugin manager to get a module instance
 def get_instance(plugin):
     print "[MongoDB Importer Module] : Get Mongodb importer instance for plugin %s" % plugin.get_name()
-    server   = plugin.server
+    uri   = plugin.uri
     database = plugin.database
 
-    instance = Mongodb_arbiter(plugin, server, database)
+    instance = Mongodb_arbiter(plugin, uri, database)
     return instance
 
 # Retrieve hosts from a Mongodb
 class Mongodb_arbiter(BaseModule):
-    def __init__(self, mod_conf, server, database):
+    def __init__(self, mod_conf, uri, database):
         BaseModule.__init__(self, mod_conf)
-        self.server     = server
+        self.uri        = uri
         self.database   = database
         # Some used varaible init
         self.con = None
@@ -59,9 +59,9 @@ class Mongodb_arbiter(BaseModule):
 
     # Called by Arbiter to say 'let's prepare yourself guy'
     def init(self):
-        print "[Mongodb Importer Module] : Try to open a Mongodb connection to %s:%s" % (self.server, self.database)
+        print "[Mongodb Importer Module] : Try to open a Mongodb connection to %s:%s" % (self.uri, self.database)
         try:
-            self.con = Connection(self.server)
+            self.con = Connection(self.uri)
             self.db = getattr(self.con, self.database)
         except Exception, e:
             print "Mongodb Module : Error %s:" % e
@@ -84,7 +84,7 @@ class Mongodb_arbiter(BaseModule):
             del h['_id']
             # And we add an imported_from property to say it came from
             # mongodb
-            h['imported_from'] = 'mongodb:%s:%s' % (self.server, self.database)
+            h['imported_from'] = 'mongodb:%s:%s' % (self.uri, self.database)
             r['hosts'].append(h)
 
         return r
diff --git a/shinken/modules/mongodb_retention.py b/shinken/modules/mongodb_retention.py
index 4134b81..564a96b 100644
--- a/shinken/modules/mongodb_retention.py
+++ b/shinken/modules/mongodb_retention.py
@@ -39,25 +39,25 @@ properties = {
 # Called by the plugin manager to get a broker
 def get_instance(plugin):
     print "Get a Mongodb retention scheduler module for plugin %s" % plugin.get_name()
-    server = plugin.server
+    uri = plugin.uri
     database = plugin.database
-    instance = Mongodb_retention_scheduler(plugin, server, database)
+    instance = Mongodb_retention_scheduler(plugin, uri, database)
     return instance
 
 
 
 # Just print some stuff
 class Mongodb_retention_scheduler(BaseModule):
-    def __init__(self, modconf, server, database):
+    def __init__(self, modconf, uri, database):
         BaseModule.__init__(self, modconf)
-        self.server = server
+        self.uri = uri
         self.database = database
 
 
     # Called by Scheduler to say 'let's prepare yourself guy'
     def init(self):
         print "Initilisation of the mongodb module"
-        self.con = Connection(self.server)
+        self.con = Connection(self.uri)
         # Open a gridfs connection
         self.db = getattr(self.con, self.database)
         self.hosts_fs = GridFS(self.db, collection='retention_hosts')
@@ -110,7 +110,7 @@ class Mongodb_retention_scheduler(BaseModule):
         # Now the new redis way :)
         log_mgr.log("MongodbRetention] asking me to load the retention objects")
 
-        #We got list of loaded data from retention server
+        #We got list of loaded data from retention uri
         ret_hosts = {}
         ret_services = {}
 
diff --git a/test/test_module_mongodb_retention.py b/test/test_module_mongodb_retention.py
index 02775b4..1502608 100755
--- a/test/test_module_mongodb_retention.py
+++ b/test/test_module_mongodb_retention.py
@@ -35,7 +35,7 @@ from shinken.modules.mongodb_retention import get_instance
 
 modconf = Module()
 modconf.module_name = "MongodbRetention"
-modconf.server = 'localhost'
+modconf.uri = 'mongodb://127.0.0.1:27017'
 modconf.database = 'test'
 modconf.module_type = mongodb_retention.properties['type']
 modconf.properties = mongodb_retention.properties.copy()

-- 
UNNAMED PROJECT



More information about the Pkg-nagios-changes mailing list