pvl.hosts: add support for explicit location = ... field
authorTero Marttila <terom@paivola.fi>
Mon, 17 Mar 2014 17:36:59 +0200
changeset 385 01d31fda75ab
parent 384 caa3dbbdbe83
child 386 9e1abcf47d27
pvl.hosts: add support for explicit location = ... field
bin/pvl.hosts-dns
pvl/hosts.py
--- a/bin/pvl.hosts-dns	Mon Mar 17 17:31:45 2014 +0200
+++ b/bin/pvl.hosts-dns	Mon Mar 17 17:36:59 2014 +0200
@@ -73,6 +73,9 @@
         if host.alias6 :
             yield pvl.dns.zone.ZoneRecord.AAAA(label.ALIAS6_FMT.format(host=host), host.ip6)
 
+        if host.location :
+            yield process_hosts_alias(options, origin, host.domain, host.location, label)
+
         for alias in host.alias :
             yield process_hosts_alias(options, origin, host.domain, alias, label)
 
@@ -80,7 +83,7 @@
             yield process_hosts_alias(options, origin, host.domain, alias4, host.ALIAS4_FMT.format(host=label))
 
         for alias6 in host.alias6 :
-            yield process_hosts_alias(options, origin, host.domain,  alias6, host.ALIAS6_FMT.format(host=label))
+            yield process_hosts_alias(options, origin, host.domain, alias6, host.ALIAS6_FMT.format(host=label))
 
 def process_hosts_forward (options, hosts, origin) :
     """
--- a/pvl/hosts.py	Mon Mar 17 17:31:45 2014 +0200
+++ b/pvl/hosts.py	Mon Mar 17 17:36:59 2014 +0200
@@ -99,8 +99,11 @@
     
     @classmethod
     def build (cls, options, host, domain,
-            ip=None, ip6=None, owner=None, boot=None, alias=None, alias4=None, alias6=None, forward=None, reverse=None,
+            ip=None, ip6=None, owner=None, location=None,
+            alias=None, alias4=None, alias6=None,
+            forward=None, reverse=None,
             down=None,
+            boot=None,
             **extra) :
         """
             Return a Host from a config section's scalars.
@@ -173,6 +176,9 @@
         else :
             down = None
         
+        if not location :
+            location = None
+
         return cls(host,
                 domain      = domain,
                 ip          = ipaddr.IPv4Address(ip) if ip else None,
@@ -182,6 +188,7 @@
                 alias4      = alias4,
                 alias6      = alias6,
                 owner       = owner,
+                location    = location,
                 boot        = boot,
                 forward     = forward,
                 reverse     = reverse,
@@ -196,6 +203,7 @@
             ethernet={ },
             alias=(),
             owner=None,
+            location=None,
             boot=None,
             alias4=None, alias6=None,
             forward=None, reverse=None,
@@ -210,6 +218,7 @@
             ethernet    - { index: ethernet }
             alias       - list
             owner       - str: LDAP uid
+            location    - name
             alias4      - list (CNAME -> A)
             alias6      - list (CNAME -> AAAA)
             forward     - generate forward records, or CNAME into given zone
@@ -226,6 +235,7 @@
         self.alias4 = alias4
         self.alias6 = alias6
         self.owner = owner
+        self.location = location
         self.boot = boot
         self.forward = forward
         self.reverse = reverse