X-Git-Url: https://git.llucax.com/software/pymin.git/blobdiff_plain/3a113e91bcbc8e34d9ef66915ccec80e6187332b..73cc0c58e7d9cd821216be6ea47159dece5398d3:/services/dhcp/handler.py diff --git a/services/dhcp/handler.py b/services/dhcp/handler.py index c33a555..6cb21a9 100644 --- a/services/dhcp/handler.py +++ b/services/dhcp/handler.py @@ -3,54 +3,13 @@ from os import path import logging ; log = logging.getLogger('pymin.services.dhcp') -from pymin.seqtools import Sequence -from pymin.dispatcher import Handler, handler, HandlerError -from pymin.service.util import Restorable, ConfigWriter, InitdHandler, \ +from pymin.service.util import Restorable, ConfigWriter, ReloadHandler, \ TransactionalHandler, ParametersHandler, \ - DictSubHandler, ReloadHandler + InitdHandler -__all__ = ('DhcpHandler', 'get_service') +from host import HostHandler - -def get_service(config): - return DhcpHandler(config.dhcp.pickle_dir, config.dhcp.config_dir) - - -class Host(Sequence): - r"""Host(name, ip, mac) -> Host instance :: Class representing a host. - - name - Host name, should be a fully qualified name, but no checks are done. - ip - IP assigned to the hostname. - mac - MAC address to associate to the hostname. - """ - - def __init__(self, name, ip, mac): - r"Initialize Host object, see class documentation for details." - self.name = name - self.ip = ip - self.mac = mac - - def as_tuple(self): - r"Return a tuple representing the host." - return (self.name, self.ip, self.mac) - - def update(self, ip=None, mac=None): - if ip is not None: - self.ip = ip - if mac is not None: - self.mac = mac - -class HostHandler(DictSubHandler): - r"""HostHandler(parent) -> HostHandler instance :: Handle a list of hosts. - - This class is a helper for DhcpHandler to do all the work related to hosts - administration. - """ - - handler_help = u"Manage DHCP hosts" - - _cont_subhandler_attr = 'hosts' - _cont_subhandler_class = Host +__all__ = ('DhcpHandler',) class DhcpHandler(Restorable, ConfigWriter, ReloadHandler, TransactionalHandler, ParametersHandler, InitdHandler):