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 several backends: a builtin core written from
scratch using the various server tools in the Python standard library;
a variant on the builtin core that uses Python 2.6’s
multiprocessing library to process requests in parallel; 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.Core._run() to handle server
startup.
- Override Bcfg2.Server.Core.Core._block() to run the
blocking server loop.
- Call Bcfg2.Server.Core.Core.shutdown() on orderly
shutdown.
A core that wants to use the network (i.e., a core that isn’t used
entirely for introspection, as in bcfg2-info, or other local tasks) should inherit from
Bcfg2.Server.Core.NetworkCore, and must also override
Bcfg2.Server.Core.NetworkCore._daemonize() to handle daemonization,
writing the PID file, and dropping privileges.
Nearly all XML-RPC handling is delegated entirely to the core
implementation. It needs to:
- Call Bcfg2.Server.Core.NetworkCore.authenticate() to
authenticate clients.
- Handle xmlrpclib.Fault exceptions 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.Server.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.Server.SSLServer.SSLServer(listen_all, server_address, RequestHandlerClass, keyfile=None, certfile=None, reqCert=False, ca=None, timeout=None, protocol='xmlrpc/tlsv1')[source]
Bases: SocketServer.TCPServer, object
TCP 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/ssl and xmlrpc/tlsv1.
|
-
exception Bcfg2.Server.SSLServer.XMLRPCACLCheckException[source]
Bases: exceptions.Exception
Raised when ACL checks fail on an RPC request
-
class Bcfg2.Server.SSLServer.XMLRPCDispatcher(allow_none, encoding)[source]
Bases: SimpleXMLRPCServer.SimpleXMLRPCDispatcher
An XML-RPC dispatcher.
-
class Bcfg2.Server.SSLServer.XMLRPCRequestHandler(*args, **kwargs)[source]
Bases: SimpleXMLRPCServer.SimpleXMLRPCRequestHandler
XML-RPC request handler.
Adds support for HTTP authentication.
-
parse_request()[source]
Extends parse_request.
Optionally check HTTP authentication when parsing.
-
class Bcfg2.Server.SSLServer.XMLRPCServer(listen_all, server_address, RequestHandlerClass=None, keyfile=None, certfile=None, ca=None, protocol='xmlrpc/tlsv1', timeout=10, logRequests=False, register=True, allow_none=True, encoding=None)[source]
Bases: SocketServer.ThreadingMixIn, Bcfg2.Server.SSLServer.SSLServer, Bcfg2.Server.SSLServer.XMLRPCDispatcher, object
Component 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
|
-
ping(*args)[source]
Echo response.
-
serve_forever()[source]
Serve single requests until (self.serve == False).
-
shutdown()[source]
Signal that automatic service should stop.
Multiprocessing Core
CherryPy Core