X-Git-Url: https://git.llucax.com/software/pymin.git/blobdiff_plain/3dc285a9ac21a377d5a81d6681e97becc0c2f286..05968c86ff71ae5031fd5940cf4807a4b8e71e24:/services/dhcp/host.py diff --git a/services/dhcp/host.py b/services/dhcp/host.py index c9f200f..59a7b1a 100644 --- a/services/dhcp/host.py +++ b/services/dhcp/host.py @@ -3,35 +3,24 @@ from os import path import logging ; log = logging.getLogger('pymin.services.dhcp') -from pymin.seqtools import Sequence +from pymin.validation import Item, Field, Any, IPAddress, MACAddress, \ + HostName, FullyQualifiedHostName from pymin.service.util import DictSubHandler __all__ = ('HostHandler',) -class Host(Sequence): +class Host(Item): 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 + name = Field(Any(HostName(not_empty=True), + FullyQualifiedHostName(not_empty=True))) + ip = Field(IPAddress(not_empty=True)) + mac = Field(MACAddress(add_colons=True, not_empty=True)) class HostHandler(DictSubHandler): r"""HostHandler(parent) -> HostHandler instance :: Handle a list of hosts.