summaryrefslogtreecommitdiffstats
path: root/src/sbin
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-07-19 17:18:57 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-07-19 17:19:17 -0400
commit7c31e9544d325bfc869cba1d15cbc57f1d6a9aff (patch)
tree1952f9e4860738cda67e9c3cf2dd94d0ecde91a8 /src/sbin
parent73aad860ba02d31a0196bb9b5e36c95d475f59d4 (diff)
downloadbcfg2-7c31e9544d325bfc869cba1d15cbc57f1d6a9aff.tar.gz
bcfg2-7c31e9544d325bfc869cba1d15cbc57f1d6a9aff.tar.bz2
bcfg2-7c31e9544d325bfc869cba1d15cbc57f1d6a9aff.zip
added CherryPy-based server core
Diffstat (limited to 'src/sbin')
-rwxr-xr-xsrc/sbin/bcfg2-info8
-rwxr-xr-xsrc/sbin/bcfg2-lint5
-rwxr-xr-xsrc/sbin/bcfg2-server52
-rwxr-xr-xsrc/sbin/bcfg2-test9
4 files changed, 27 insertions, 47 deletions
diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info
index 297b2227d..55650f18b 100755
--- a/src/sbin/bcfg2-info
+++ b/src/sbin/bcfg2-info
@@ -169,20 +169,18 @@ def load_interpreters():
return interpreters
-class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core):
+class infoCore(cmd.Cmd, Bcfg2.Server.Core.BaseCore):
"""Main class for bcfg2-info."""
def __init__(self, repo, plgs, passwd, encoding, event_debug,
filemonitor='default', setup=None):
cmd.Cmd.__init__(self)
try:
- Bcfg2.Server.Core.Core.__init__(self, repo, plgs, passwd,
- encoding, filemonitor=filemonitor,
- setup=setup)
+ Bcfg2.Server.Core.BaseCore.__init__(self, setup=setup)
if event_debug:
self.fam.debug = True
except Bcfg2.Server.Core.CoreInitError:
msg = sys.exc_info()[1]
- print("Core load failed because %s" % msg)
+ print("Core load failed: %s" % msg)
raise SystemExit(1)
self.prompt = '> '
self.cont = True
diff --git a/src/sbin/bcfg2-lint b/src/sbin/bcfg2-lint
index c664a67f2..09b2f715d 100755
--- a/src/sbin/bcfg2-lint
+++ b/src/sbin/bcfg2-lint
@@ -61,10 +61,7 @@ def get_errorhandler(config):
def load_server(setup):
""" load server """
- core = Bcfg2.Server.Core.Core(setup['repo'], setup['plugins'],
- setup['password'], setup['encoding'],
- filemonitor=setup['filemonitor'],
- setup=setup)
+ core = Bcfg2.Server.Core.Core(setup)
core.fam.handle_events_in_interval(4)
return core
diff --git a/src/sbin/bcfg2-server b/src/sbin/bcfg2-server
index d03edc93e..2727dfe3a 100755
--- a/src/sbin/bcfg2-server
+++ b/src/sbin/bcfg2-server
@@ -2,13 +2,11 @@
"""The XML-RPC Bcfg2 server."""
-import logging
-import os.path
+import os
import sys
-
+import logging
import Bcfg2.Logger
import Bcfg2.Options
-import Bcfg2.Component
import Bcfg2.Server.Plugins.Metadata
from Bcfg2.Server.Core import CoreInitError
@@ -21,36 +19,30 @@ if __name__ == '__main__':
optinfo.update(Bcfg2.Options.DAEMON_COMMON_OPTIONS)
setup = Bcfg2.Options.OptionParser(optinfo)
setup.parse(sys.argv[1:])
+ # check whether the specified bcfg2.conf exists
+ if not os.path.exists(setup['configfile']):
+ print("Could not read %s" % setup['configfile'])
+ sys.exit(1)
+
+ if setup['backend'] not in ['best', 'cherrypy', 'builtin']:
+ print("Unknown server backend %s, using 'best'" % setup['backend'])
+ setup['backend'] = 'best'
+ if setup['backend'] == 'cherrypy':
+ try:
+ from Bcfg2.Server.CherryPyCore import Core
+ except ImportError:
+ err = sys.exc_info()[1]
+ print("Unable to import CherryPy server core: %s" % err)
+ raise
+ elif setup['backend'] == 'builtin' or setup['backend'] == 'best':
+ from Bcfg2.Server.BuiltinCore import Core
+
try:
- # check whether the specified bcfg2.conf exists
- if not os.path.exists(setup['configfile']):
- print("Could not read %s" % setup['configfile'])
- sys.exit(1)
- Bcfg2.Component.run_component(Bcfg2.Server.Core.Core,
- listen_all=setup['listen_all'],
- location=setup['location'],
- daemon=setup['daemon'],
- pidfile_name=setup['daemon'],
- protocol=setup['protocol'],
- to_file=setup['logging'],
- cfile=setup['configfile'],
- register=False,
- cls_kwargs={'repo':setup['repo'],
- 'plugins':setup['plugins'],
- 'password':setup['password'],
- 'encoding':setup['encoding'],
- 'ca':setup['ca'],
- 'filemonitor':setup['filemonitor'],
- 'start_fam_thread':True,
- 'setup':setup},
- keyfile=setup['key'],
- certfile=setup['cert'],
- ca=setup['ca']
- )
+ core = Core(setup, start_fam_thread=True)
+ core.run()
except CoreInitError:
msg = sys.exc_info()[1]
logger.error(msg)
- logger.error("exiting")
sys.exit(1)
except KeyboardInterrupt:
sys.exit(1)
diff --git a/src/sbin/bcfg2-test b/src/sbin/bcfg2-test
index 653c24124..73800b5e3 100755
--- a/src/sbin/bcfg2-test
+++ b/src/sbin/bcfg2-test
@@ -75,14 +75,7 @@ def main():
if setup['verbose']:
Bcfg2.Logger.setup_logging("bcfg2-test", to_syslog=False)
- core = Bcfg2.Server.Core.Core(
- setup['repo'],
- setup['plugins'],
- setup['password'],
- setup['encoding'],
- filemonitor=setup['filemonitor'],
- setup=setup
- )
+ core = Bcfg2.Server.Core.Core(setup)
ignore = dict()
for entry in setup['test_ignore']: