2 commits - func/commonconfig.py func/minion func/module_loader.py

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 func/commonconfig.py  |    4 +++-
 func/minion/server.py |   48 +++++++++++++++++++++++++++++++++++++++++-------
 func/module_loader.py |   13 ++++++++++++-
 3 files changed, 56 insertions(+), 9 deletions(-)

New commits:
commit f6ee3b76d4ff1dc96c49b245f8a3e32adb5e07b6
Author: Seth Vidal <skvidal@xxxxxxxxxxxxxxxxx>
Date:   Wed Feb 23 15:07:12 2011 -0500

    allow dumping a lot more info from the funcd - makes debugging simpler
    
    - add setup_server() function to server.py so we can setup w/o running the server
    - add a funcd --info option to dump out all the server info so we can know a lot more about
      the host we're trying to run funcd on.

diff --git a/func/minion/server.py b/func/minion/server.py
index e590e76..03201c6 100644
--- a/func/minion/server.py
+++ b/func/minion/server.py
@@ -205,7 +205,9 @@ class FuncApiMethod:
         return rc
 
 
-def serve():
+
+
+def setup_server():
 
     """
     Code for starting the XMLRPC service.
@@ -216,6 +218,11 @@ def serve():
     if listen_port == '':
         listen_port = 51234
     server = FuncSSLXMLRPCServer((listen_addr, listen_port), config.module_list)
+    return server
+    
+def serve():
+
+    server = setup_server()
     server.logRequests = 0 # don't print stuff to console
     server.serve_forever()
 
@@ -266,6 +273,7 @@ class FuncSSLXMLRPCServer(AuthedXMLRPCServer.AuthedSSLXMLRPCServer,
         self._our_ca = certs.retrieve_cert_from_file(self.ca)
         self.acls = acls_mod.Acls(config=self.config)
 
+
         AuthedXMLRPCServer.AuthedSSLXMLRPCServer.__init__(self, args,
                                                           self.key, self.cert,
                                                           self.ca)
@@ -367,6 +375,31 @@ def main(argv):
         print >> sys.stderr, file("/etc/func/version").read().strip()
         sys.exit(0)
 
+    if "--info" in sys.argv:
+        server = setup_server()
+        print 'config:'
+        for l in str(server.config).split('\n'):
+            print '\t' + l
+            
+        print 'server name: %s' % server.server_name
+        print 'server listen addr: %s:%s' % server.server_address
+        print 'key file:  %s' % server.key
+        cert = certs.retrieve_cert_from_file(server.cert)
+        print 'cert dn: %s' % cert.get_subject().CN
+        print 'certificate hash: %s' % cert.subject_name_hash()
+        print 'cert file: %s' % server.cert
+        print 'ca file: %s' % server.ca
+        print 'modules loaded:'
+        for mn in sorted(server.modules.keys()):
+            print '\t' + mn
+        print 'acls:'
+        for (host, methods) in server.acls.acls:
+            print '\t' + host + ' : ' + str(methods)
+        print 'facts:'
+        for (n, meth) in server.fact_methods.items():
+            print '\t' + n + ' : ' + meth()
+        sys.exit(0)
+        
     if "daemon" in sys.argv or "--daemon" in sys.argv:
         utils.daemonize("/var/run/funcd.pid")
     else:


commit a4b7ed48f9b4b00eb3ae548db93f42fe08d9669a
Author: Seth Vidal <skvidal@xxxxxxxxxxxxxxxxx>
Date:   Wed Feb 23 11:49:16 2011 -0500

    - allow modules to be controlled via config option so you can list only the ones you want
      takes shell globs. all included by default
    - comment about unused class
    
    add module_list option to funcd config

diff --git a/func/commonconfig.py b/func/commonconfig.py
index a4dc544..93dfdc4 100644
--- a/func/commonconfig.py
+++ b/func/commonconfig.py
@@ -14,7 +14,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 """
 
 
-from certmaster.config import BaseConfig, BoolOption, Option, IntOption, FloatOption
+from certmaster.config import BaseConfig, BoolOption, Option, IntOption, FloatOption, ListOption
 
 FUNCD_CONFIG_FILE="/etc/func/minion.conf"
 OVERLORD_CONFIG_FILE="/etc/func/overlord.conf"
@@ -34,6 +34,8 @@ class FuncdConfig(BaseConfig):
     cert_file = Option('')
     key_file = Option('')
     crl_location = Option('')
+    module_list = ListOption([])
+
 
 class OverlordConfig(BaseConfig):
     socket_timeout = FloatOption(0)
diff --git a/func/minion/server.py b/func/minion/server.py
index e79109f..e590e76 100644
--- a/func/minion/server.py
+++ b/func/minion/server.py
@@ -215,7 +215,7 @@ def serve():
     listen_port = config.listen_port
     if listen_port == '':
         listen_port = 51234
-    server =FuncSSLXMLRPCServer((listen_addr, listen_port))
+    server = FuncSSLXMLRPCServer((listen_addr, listen_port), config.module_list)
     server.logRequests = 0 # don't print stuff to console
     server.serve_forever()
 
@@ -224,7 +224,7 @@ def serve():
 class FuncXMLRPCServer(SimpleXMLRPCServer.SimpleXMLRPCServer, XmlRpcInterface):
 
     def __init__(self, args):
-
+        # DOES ANYTHING EVER USE THIS? SKV - 2011/02/23
         self.allow_reuse_address = True
 
         self.modules = module_loader.load_modules()
@@ -234,9 +234,9 @@ class FuncXMLRPCServer(SimpleXMLRPCServer.SimpleXMLRPCServer, XmlRpcInterface):
 from func.minion.facts.minion_query import *
 class FuncSSLXMLRPCServer(AuthedXMLRPCServer.AuthedSSLXMLRPCServer,
                           XmlRpcInterface):
-    def __init__(self, args):
+    def __init__(self, args, module_list=[]):
         self.allow_reuse_address = True
-        self.modules = module_loader.load_modules()
+        self.modules = module_loader.load_modules(module_list = module_list)
 
         #load facts methods
         self.fact_methods = load_fact_methods()
@@ -244,7 +244,7 @@ class FuncSSLXMLRPCServer(AuthedXMLRPCServer.AuthedSSLXMLRPCServer,
 
         XmlRpcInterface.__init__(self)
         hn = func_utils.get_hostname_by_route()
-
+        
         if self.config.key_file != '':
             self.key = self.config.key_file
         else:
@@ -355,7 +355,8 @@ def main(argv):
 
     sys.excepthook = excepthook
     if len(sys.argv) > 1 and sys.argv[1] == "--list-modules":
-        module_names = module_loader.load_modules().keys()
+        config = read_config("/etc/func/minion.conf", FuncdConfig)
+        module_names = module_loader.load_modules(module_list = config.module_list).keys()
         module_names.sort()
         print "loaded modules:"
         for foo in module_names:
diff --git a/func/module_loader.py b/func/module_loader.py
index fbc98e2..6861144 100644
--- a/func/module_loader.py
+++ b/func/module_loader.py
@@ -19,6 +19,8 @@ import sys
 import traceback
 import inspect
 from gettext import gettext
+import fnmatch
+
 _ = gettext
 
 
@@ -51,7 +53,8 @@ def load_methods(path, main_class, parent_class=None):
                 methods["%s.%s" % (x,method)]=getattr(modules[x], method)
     return methods
 
-def load_modules(path='func/minion/modules/', main_class=func_module.FuncModule, blacklist=None, parent_class=None):
+def load_modules(path='func/minion/modules/', main_class=func_module.FuncModule, 
+                 blacklist=None, parent_class=None, module_list=[]):
     log = logger.Logger().logger
     python_path = distutils.sysconfig.get_python_lib()
     module_file_path = "%s/%s" % (python_path, path)
@@ -84,6 +87,14 @@ def load_modules(path='func/minion/modules/', main_class=func_module.FuncModule,
 
         mod_imp_name = pathname.replace("/", ".")
 
+        if module_list: # only do this if we have a module list at all, otherwise everything comes in
+            matched = False
+            for match in module_list:
+                if fnmatch.fnmatch(mod_imp_name, match):
+                    matched = True
+            if not matched: # if we are not matched against anything in the module_list then skip it
+                continue
+                
         if mods.has_key(mod_imp_name):
             # If we've already imported mod_imp_name, don't import it again
             continue


_______________________________________________
Func-list mailing list
Func-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/func-list


[Index of Archives]     [Fedora Users]     [Linux Networking]     [Fedora Legacy List]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux