Minimum 5% guaranteed allocation to prevent authors of resource brokers from shooting...
[nodemanager.git] / nm.py
diff --git a/nm.py b/nm.py
index 14a13c5..23a0d34 100644 (file)
--- a/nm.py
+++ b/nm.py
@@ -2,43 +2,45 @@
 
 import optparse
 import time
+import xmlrpclib
 
-from config import *
-import accounts
-import api
-import database
-import delegate
+import conf_files
 import logger
-import plc
-import sliver
+import sm
 import tools
 
 
 parser = optparse.OptionParser()
-parser.add_option('-d', '--daemon',
-                  action='store_true', dest='daemon', default=False,
-                  help='run daemonized')
-parser.add_option('-s', '--startup',
-                  action='store_true', dest='startup', default=False,
-                  help='run all sliver startup scripts')
+parser.add_option('-d', '--daemon', action='store_true', dest='daemon', default=False, help='run daemonized')
+parser.add_option('-s', '--startup', action='store_true', dest='startup', default=False, help='run all sliver startup scripts')
 (options, args) = parser.parse_args()
 
+# XXX - awaiting a real implementation
+data = []
+modules = []
+
+def GetSlivers():
+    for mod in modules: mod.GetSlivers_callback(data)
+
+def start_and_register_callback(mod):
+    mod.start(options)
+    modules.append(mod)
+
+
 def run():
     try:
         if options.daemon: tools.daemon()
 
-        accounts.register_class(sliver.Sliver)
-        accounts.register_class(delegate.Delegate)
 
         other_pid = tools.pid_file()
         if other_pid != None:
-            print """There might be another instance of the node manager running as pid %d.  If this is not the case, please remove the pid file %s""" % (other_pid, PID_FILE)
+            print """There might be another instance of the node manager running as pid %d.  If this is not the case, please remove the pid file %s""" % (other_pid, tools.PID_FILE)
             return
 
-        database.start()
-        api.start()
+        start_and_register_callback(sm)
+        start_and_register_callback(conf_files)
         while True:
-            try: plc.fetch_and_update()
+            try: GetSlivers()
             except: logger.log_exc()
             time.sleep(10)
     except: logger.log_exc()