summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2006-11-23 14:18:31 +0000
committerNarayan Desai <desai@mcs.anl.gov>2006-11-23 14:18:31 +0000
commit820b2a677475e26aa29a23cd9c4eadcaf4ec4730 (patch)
treed4967f03a48386d5700329f6eb1fa0e37b7a6d43 /src
parentc44c69fc0d288c4674ddef02d25b10ecb461385b (diff)
downloadbcfg2-820b2a677475e26aa29a23cd9c4eadcaf4ec4730.tar.gz
bcfg2-820b2a677475e26aa29a23cd9c4eadcaf4ec4730.tar.bz2
bcfg2-820b2a677475e26aa29a23cd9c4eadcaf4ec4730.zip
Fixup server error handling
* Remove ssl key print * Handle bind failure case cleanly git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2533 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rw-r--r--src/lib/Server/Component.py4
-rwxr-xr-xsrc/sbin/bcfg2-server11
2 files changed, 10 insertions, 5 deletions
diff --git a/src/lib/Server/Component.py b/src/lib/Server/Component.py
index f3bd47d34..ecb476780 100644
--- a/src/lib/Server/Component.py
+++ b/src/lib/Server/Component.py
@@ -53,7 +53,6 @@ class SSLServer(BaseHTTPServer.HTTPServer):
def __init__(self, address, keyfile, handler):
SocketServer.BaseServer.__init__(self, address, handler)
ctxt = OpenSSL.SSL.Context(OpenSSL.SSL.SSLv23_METHOD)
- print keyfile
ctxt.use_privatekey_file (keyfile)
ctxt.use_certificate_file(keyfile)
#ctxt.load_verify_locations('/tmp/keys/CA.cert')
@@ -134,6 +133,9 @@ class Component(SSLServer,
try:
SSLServer.__init__(self, location, keyfile, CobaltXMLRPCRequestHandler)
+ except socket.error:
+ self.logger.error("Failed to bind to socket")
+ raise ComponentInitError
except:
self.logger.error("Failed to load ssl key %s" % (keyfile), exc_info=1)
raise ComponentInitError
diff --git a/src/sbin/bcfg2-server b/src/sbin/bcfg2-server
index c6d3d9ab7..4204b49ba 100755
--- a/src/sbin/bcfg2-server
+++ b/src/sbin/bcfg2-server
@@ -59,6 +59,10 @@ def critical_error(operation):
logger.error(operation, exc_info=1)
raise Fault, (7, "Critical unexpected failure: %s" % (operation))
+class SetupError(Exception):
+ '''Used when the server cant be setup'''
+ pass
+
class Bcfg2Serv(Bcfg2.Server.Component.Component):
"""The Bcfg2 Server component providing XML-RPC access to Bcfg methods"""
__name__ = 'bcfg2'
@@ -71,8 +75,7 @@ class Bcfg2Serv(Bcfg2.Server.Component.Component):
Bcfg2.Server.Component.Component.__init__(self, setup)
self.shut = False
except Bcfg2.Server.Component.ComponentInitError:
- logger.critical("Failed to setup server")
- raise SystemExit, 1
+ raise SetupError
# set shutdown handlers for sigint and sigterm
signal.signal(signal.SIGINT, self.start_shutdown)
@@ -216,8 +219,8 @@ if __name__ == '__main__':
daemonize(SSETUP['daemon'])
try:
BSERV = Bcfg2Serv(SSETUP)
- except:
- critical_error("Failed to setup server; probably a key problem")
+ except SetupError:
+ raise SystemExit, 1
while not BSERV.shut:
try:
BSERV.serve_forever()