pvl.hosts-dns/graph: support a separate location = name@domain format, with an optional separate Host.location_domain
authorTero Marttila <terom@paivola.fi>
Sat, 26 Jul 2014 13:42:37 +0300
changeset 421 585eadaed270
parent 420 ee31a0b573f2
child 422 56ba4bef5016
pvl.hosts-dns/graph: support a separate location = name@domain format, with an optional separate Host.location_domain
bin/pvl.hosts-dns
bin/pvl.hosts-graph
pvl/hosts.py
--- a/bin/pvl.hosts-dns	Sun Apr 27 01:44:30 2014 +0300
+++ b/bin/pvl.hosts-dns	Sat Jul 26 13:42:37 2014 +0300
@@ -73,7 +73,9 @@
         if host.alias6 :
             yield pvl.dns.zone.ZoneRecord.AAAA(label.ALIAS6_FMT.format(host=host), host.ip6)
 
-        if host.location :
+        if host.location and host.location_domain:
+            yield process_hosts_alias(options, origin, host.location_domain, host.location, label)
+        elif host.location:
             yield process_hosts_alias(options, origin, host.domain, host.location, label)
 
         for alias in host.alias :
--- a/bin/pvl.hosts-graph	Sun Apr 27 01:44:30 2014 +0300
+++ b/bin/pvl.hosts-graph	Sat Jul 26 13:42:37 2014 +0300
@@ -187,7 +187,9 @@
         for ethernet in host.ethernet.itervalues() :
             hosts_by_ethernet[ethernet] = host
 
-        if host.location :
+        if host.location and host.location_domain:
+            hosts_by_location[(host.location_domain, host.location)] = host
+        elif host.location:
             hosts_by_location[(host.domain, host.location)] = host
 
     # first graph: lldp remotes
--- a/pvl/hosts.py	Sun Apr 27 01:44:30 2014 +0300
+++ b/pvl/hosts.py	Sat Jul 26 13:42:37 2014 +0300
@@ -184,7 +184,11 @@
             down = None
         
         if not location :
-            location = None
+            location = location_domain = None
+        elif '@' in location:
+            location, location_domain = location.split('@', 1)
+        else:
+            location_domain = None
 
         return cls(host,
                 domain      = domain,
@@ -196,6 +200,7 @@
                 alias6      = alias6,
                 owner       = owner,
                 location    = location,
+                location_domain = location_domain,
                 boot        = boot,
                 forward     = forward,
                 reverse     = reverse,
@@ -211,6 +216,7 @@
             alias=(),
             owner=None,
             location=None,
+            location_domain=None,
             boot=None,
             alias4=None, alias6=None,
             forward=None, reverse=None,
@@ -225,7 +231,8 @@
             ethernet    - { index: ethernet }
             alias       - list
             owner       - str: LDAP uid
-            location    - name
+            location    - location name@ part
+            location_domain - location @domain part
             alias4      - list (CNAME -> A)
             alias6      - list (CNAME -> AAAA)
             forward     - generate forward records, or CNAME into given zone
@@ -243,6 +250,7 @@
         self.alias6 = alias6
         self.owner = owner
         self.location = location
+        self.location_domain = location_domain
         self.boot = boot
         self.forward = forward
         self.reverse = reverse