]> git.llucax.com Git - software/pymin.git/blobdiff - services/dns/host.py
Add validation to vpn service (refs #20)
[software/pymin.git] / services / dns / host.py
index 20ce0d5a5444161e9d0184e9f832556d629263bb..fecd7c60a0f7c4f00b60d485eb45cada678e0650 100644 (file)
@@ -1,20 +1,16 @@
 # vim: set encoding=utf-8 et sw=4 sts=4 :
 
 # vim: set encoding=utf-8 et sw=4 sts=4 :
 
-# TODO documentation, validation
+# TODO documentation
 
 
-from pymin.seqtools import Sequence
+from pymin.validation import Item, Field, HostName, IPAddress
 from pymin.service.util import DictComposedSubHandler
 
 __all__ = ('HostHandler',)
 
 from pymin.service.util import DictComposedSubHandler
 
 __all__ = ('HostHandler',)
 
-class Host(Sequence):
-    def __init__(self, name, ip):
-        self.name = name
-        self.ip = ip
-    def update(self, ip=None):
-        if ip is not None: self.ip = ip
-    def as_tuple(self):
-        return (self.name, self.ip)
+
+class Host(Item):
+    name = Field(HostName(not_empty=True))
+    ip = Field(IPAddress(not_empty=True))
 
 class HostHandler(DictComposedSubHandler):
     handler_help = u"Manage DNS hosts"
 
 class HostHandler(DictComposedSubHandler):
     handler_help = u"Manage DNS hosts"