Rebased ref, commits from common ancestor:
commit e708908e48381cdd114c8d6cf26a295c7af2b481
Author: noik <noik00(a)gmail.com>
Date: Fri Dec 12 15:31:03 2008 +0100
Added hub-demo.py for testing hub functions(not complete)
changed base.py for starting the hubmode
Added some "to-be-implemented"-methods for further programming, and
visualizing the concept, and fixed the indentations.
diff --git a/hub-demo.py b/hub-demo.py
new file mode 100755
index 0000000..14208e7
--- /dev/null
+++ b/hub-demo.py
@@ -0,0 +1,23 @@
+#! /usr/bin/python
+
+#This is a demo of the server
+#to use it, run this in interactive mode (python -i)
+# and your environment will have a connection variable
+
+from revisor.client import *
+
+con = Connection("http://localhost:9321")
+
+#print dir(con)
+
+print con.con.system.listMethods()
+
+session = con.con.session_set_status(1, "POEP!!!!")
+
+#con.con.session_set_configuration(session)
+#con.con.session_set_model(session, "f9-i386")
+#con.con.session_set_kickstart(session, "/etc/revisor/conf.d/sample-ks.cfg")
+
+#con.con.session_start_compose(session)
+
+#con.con.session_delete_session(session)
diff --git a/revisor/base.py b/revisor/base.py
index 0348035..e797c9b 100644
--- a/revisor/base.py
+++ b/revisor/base.py
@@ -96,29 +96,40 @@ class RevisorBase:
self.cfg.setup_yum()
self.cfg.setup_ks()
-
- def run(self):
- """Split into either running CLI, Server or GUI"""
+
+ def run(self):
+ """Split into either running CLI, Server, Hub or GUI"""
if self.cfg.cli_mode:
- import revisor.cli
self.log.debug(_("Running Revisor in CLI mode..."), level=1)
+ import revisor.cli
self.cli = revisor.cli.RevisorCLI(self)
self.cli.run()
+ #not optimal yet
+ # TODO: remove redundant code
+ elif hasattr(self.cfg,"hub_mode"):
+ if self.cfg.hub_mode:
+ self.log.debug(_("Running Revisor in Hub mode..."), level=1)
+ self.server = self.plugins.modhub
+ self.server.run(base=self)
+ elif self.cfg.gui_mode:
+ self.log.debug(_("Running Revisor in GUI mode..."), level=1)
+ self.gui = self.plugins.modgui
+ self.gui.run(base=self)
elif hasattr(self.cfg,"server_mode"):
- # added hubmode
- if self.cfg.hub_mode:
- self.log.debug(_("Running Revisor in Hub mode..."), level=1)
- self.server = self.plugins.modhub
- self.cfg.gui_mode = False #hack!
- self.server.run(base=self)
- elif self.cfg.server_mode:
- self.log.debug(_("Running Revisor in RPC Server mode..."), level=1)
- self.server = self.plugins.modserver
- self.server.run(base=self)
- elif self.cfg.gui_mode:
- self.log.debug(_("Running Revisor in GUI mode..."), level=1)
- self.gui = self.plugins.modgui
- self.gui.run(base=self)
+ if self.cfg.server_mode:
+ self.log.debug(_("Running Revisor in RPC Server mode..."),
level=1)
+ self.server = self.plugins.modserver
+ self.server.run(base=self)
+ elif self.cfg.gui_mode:
+ self.log.debug(_("Running Revisor in GUI mode..."), level=1)
+ self.gui = self.plugins.modgui
+ self.gui.run(base=self)
+
+ elif self.cfg.gui_mode:
+ self.log.debug(_("Running Revisor in GUI mode..."), level=1)
+ self.gui = self.plugins.modgui
+ self.gui.run(base=self)
+
def create_logger(self):
"""Create a logger instance using
cli_options.debuglevel"""
diff --git a/revisor/modhub/__init__.py b/revisor/modhub/__init__.py
index 4af145c..7b20883 100644
--- a/revisor/modhub/__init__.py
+++ b/revisor/modhub/__init__.py
@@ -15,8 +15,7 @@ class RevisorHub():
""" Hub Mode """
def __init__(self):
- # blaat
- print "HELLO HUB!!!!!!!"
+ pass
def do_xmlrpc(self, cfg):
""" Get our xmlrpc hub running. """
@@ -90,22 +89,35 @@ class RevisorHub():
class RevisorXMLRPCInterface(object):
""" Functionality to expose to the XML-RPC interface.
"""
- def __init__(self, cfg=None):
- #if cfg == None:
- # FIXME: Initialize ConfigStore or return Error
- #pass
- #else:
- #self.cfg = cfg
-
- #self.sessions = dict()
+ def __init__(self, cfg):
+ try:
+ if cfg:
+ self.cfg = cfg
+ else:
+ # FIXME: Initialize ConfigStore or return Error
+ pass
+ except NameError:
+ pass
+
+ self.sessions = dict()
#self.next_session = 0
pass
+
+ def session_set_status(self, id, status):
+ self.sessions[sid].set_status(id, status)
+ return 1
class Session(object):
def __init__(self, id):
self.id = id
- print "Session initted & ended"
+ print "Hub session initted"
+ self.revisor = HubMode()
+
+ def set_status(self, id, status):
+ if id == self.id:
+ self.revisor.set_status(id, status)
+ pass
class RevisorXMLRPCServer(SimpleXMLRPCServer.SimpleXMLRPCServer):
@@ -113,3 +125,25 @@ class RevisorXMLRPCServer(SimpleXMLRPCServer.SimpleXMLRPCServer):
def __init__(self, args):
self.allow_reuse_address = True
SimpleXMLRPCServer.SimpleXMLRPCServer.__init__(self, args)
+
+
+class HubMode():
+ def __init__(self):
+ pass
+
+ def set_status(self, id, status):
+ print id
+ print status
+ pass
+
+ def db_get_ks():
+ pass
+
+ def check_jobs():
+ #check jobs in DB
+ #get KS from DB if any found
+ pass
+
+ def add_composer():
+ #function to add composer for distribution idea
+ pass