From 3dc285a9ac21a377d5a81d6681e97becc0c2f286 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Fri, 20 Jun 2008 01:02:15 -0300 Subject: [PATCH] Split dhcp handler in submodules (refs #2). --- services/dhcp/handler.py | 45 ++++---------------------------------- services/dhcp/host.py | 47 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 41 deletions(-) create mode 100644 services/dhcp/host.py diff --git a/services/dhcp/handler.py b/services/dhcp/handler.py index f27f984..6cb21a9 100644 --- a/services/dhcp/handler.py +++ b/services/dhcp/handler.py @@ -3,50 +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') +from host import HostHandler - -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): diff --git a/services/dhcp/host.py b/services/dhcp/host.py new file mode 100644 index 0000000..c9f200f --- /dev/null +++ b/services/dhcp/host.py @@ -0,0 +1,47 @@ +# vim: set encoding=utf-8 et sw=4 sts=4 : + +from os import path +import logging ; log = logging.getLogger('pymin.services.dhcp') + +from pymin.seqtools import Sequence +from pymin.service.util import DictSubHandler + +__all__ = ('HostHandler',) + + +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 + -- 2.43.0