Server Core Development¶
New in version 1.3.0.
Bcfg2 1.3 added a pluggable server core system so that the server core itself can be easily swapped out to use different technologies. It currently ships with two backends: a builtin core written from scratch using the various server tools in the Python standard library; and an experimental CherryPy based core. This page documents the server core interface so that other cores can be written to take advantage of other technologies, e.g., Tornado or Twisted.
A core implementation needs to:
- Override
Bcfg2.Server.Core.BaseCore._daemonize()to handle daemonization, writing the PID file, and dropping privileges. - Override
Bcfg2.Server.Core.BaseCore._run()to handle server startup. - Override
Bcfg2.Server.Core.BaseCore._block()to run the blocking server loop. - Call
Bcfg2.Server.Core.BaseCore.shutdown()on orderly shutdown.
Nearly all XML-RPC handling is delegated entirely to the core implementation. It needs to:
- Call
Bcfg2.Server.Core.BaseCore.authenticate()to authenticate clients. - Handle
xmlrpclib.Faultexceptions raised by the exposed XML-RPC methods as appropriate. - Dispatch XML-RPC method invocations to the appropriate method, including Plugin RMI. The client address pair (a tuple of remote IP address and remote hostname) must be prepended to the argument list passed to built-in methods (i.e., not to plugin RMI).
Additionally, running and configuring the server is delegated to the core. It needs to honor the configuration options that influence how and where the server runs, including the server location (host and port), listening interfaces, and SSL certificate and key.
Base Core¶
Core Implementations¶
Builtin Core¶
The builtin server core consists of the core implementation
(Bcfg2.Server.BuiltinCore.Core) and the XML-RPC server
implementation (Bcfg2.SSLServer).
Core¶
XML-RPC Server¶
Bcfg2 SSL server used by the builtin server core
(Bcfg2.Server.BuiltinCore). This needs to be documented
better.
-
class
Bcfg2.SSLServer.SSLServer(listen_all, server_address, RequestHandlerClass, keyfile=None, certfile=None, reqCert=False, ca=None, timeout=None, protocol='xmlrpc/ssl')[source]¶ Bases:
SocketServer.TCPServer,objectTCP server supporting SSL encryption.
Parameters: - listen_all (bool) – Listen on all interfaces
- server_address – Address to bind to the server
- RequestHandlerClass – Request handler used by TCP server
- keyfile (string) – Full path to SSL encryption key file
- certfile (string) – Full path to SSL certificate file
- reqCert (bool) – Require client to present certificate
- ca (string) – Full path to SSL CA that signed the key and cert
- timeout – Timeout for non-blocking request handling
- protocol (string) – The protocol to serve. Supported values are
xmlrpc/sslandxmlrpc/tlsv1.
-
class
Bcfg2.SSLServer.XMLRPCDispatcher(allow_none, encoding)[source]¶ Bases:
SimpleXMLRPCServer.SimpleXMLRPCDispatcherAn XML-RPC dispatcher.
-
class
Bcfg2.SSLServer.XMLRPCRequestHandler(request, client_address, server)[source]¶ Bases:
SimpleXMLRPCServer.SimpleXMLRPCRequestHandlerXML-RPC request handler.
Adds support for HTTP authentication.
-
class
Bcfg2.SSLServer.XMLRPCServer(listen_all, server_address, RequestHandlerClass=None, keyfile=None, certfile=None, ca=None, protocol='xmlrpc/ssl', timeout=10, logRequests=False, register=True, allow_none=True, encoding=None)[source]¶ Bases:
SocketServer.ThreadingMixIn,Bcfg2.SSLServer.SSLServer,Bcfg2.SSLServer.XMLRPCDispatcher,objectComponent XMLRPCServer.
Parameters: - listen_all (bool) – Listen on all interfaces
- server_address – Address to bind to the server
- RequestHandlerClass – request handler used by TCP server
- keyfile (string) – Full path to SSL encryption key file
- certfile (string) – Full path to SSL certificate file
- ca (string) – Full path to SSL CA that signed the key and cert
- logRequests (bool) – Log all requests
- register (bool) – Presence should be reported to service-location
- allow_none (bool) – Allow None values in XML-RPC
- encoding – Encoding to use for XML-RPC
