pvl.hosts-dns/graph: support a separate location = name@domain format, with an optional separate Host.location_domain
--- 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