pvl.hosts.Host.fqnd(): assume any host with a . is a fqdn
authorTero Marttila <terom@paivola.fi>
Tue, 17 Dec 2013 01:15:37 +0200
changeset 299 df653511caf9
parent 298 fa1ab8cda47e
child 300 a720bcf96007
pvl.hosts.Host.fqnd(): assume any host with a . is a fqdn
bin/pvl.hosts-dns
pvl/hosts.py
--- a/bin/pvl.hosts-dns	Tue Dec 17 01:04:06 2013 +0200
+++ b/bin/pvl.hosts-dns	Tue Dec 17 01:15:37 2013 +0200
@@ -70,7 +70,7 @@
             log.debug("%s: %s out of prefix: %s", host, ip, prefix)
             continue
         
-        fqdn = pvl.dns.zone.fqdn(host, host.domain)
+        fqdn = host.fqdn()
 
         log.debug("%s: ip=%s domain=%s: %s", host, ip, host.domain, fqdn)
 
--- a/pvl/hosts.py	Tue Dec 17 01:04:06 2013 +0200
+++ b/pvl/hosts.py	Tue Dec 17 01:15:37 2013 +0200
@@ -99,6 +99,14 @@
         self.owner = owner
         self.boot = boot
 
+    def fqdn (self) :
+        if '.' in self.host :
+            return self.host + '.'
+        elif self.domain :
+            return pvl.dns.zone.fqdn(self.host, self.domain)
+        else :
+            raise ValueError("%s: have no fqdn/domain" % (self, ))
+
     def __str__ (self) :
         return str(self.host)