--- a/pvl/hosts.py Tue Dec 17 17:44:47 2013 +0200
+++ b/pvl/hosts.py Wed Dec 18 22:35:48 2013 +0200
@@ -21,6 +21,10 @@
return hosts
class Host (object) :
+ # the label used for alias4/6 hosts
+ ALIAS4_FMT = '{host}-ipv4'
+ ALIAS6_FMT = '{host}-ipv6'
+
@classmethod
def expand (cls, options, host, range, ip, **opts) :
host = pvl.dns.zone.parse_generate_field(host)
@@ -51,7 +55,7 @@
yield cls.build(options, host, ip=ip, **extra)
@classmethod
- def build (cls, options, host, domain=None, ip=None, ip6=None, owner=None, boot=None, alias=None, **extra) :
+ def build (cls, options, host, domain=None, ip=None, ip6=None, owner=None, boot=None, alias=None, alias4=None, alias6=None, **extra) :
"""
Return a Host from a config section's scalars.
"""
@@ -60,6 +64,16 @@
alias = alias.split()
else :
alias = ()
+
+ if alias4 :
+ alias4 = alias4.split()
+ else :
+ alias4 = ()
+
+ if alias6 :
+ alias6 = alias6.split()
+ else :
+ alias6 = ()
ethernet = { }
@@ -87,11 +101,13 @@
ip6 = ipaddr.IPv6Address(ip6) if ip6 else None,
ethernet = ethernet,
alias = alias,
+ alias4 = alias4,
+ alias6 = alias6,
owner = owner,
boot = boot,
)
- def __init__ (self, host, domain=None, ip=None, ip6=None, ethernet={ }, alias=(), owner=None, boot=None) :
+ def __init__ (self, host, domain=None, ip=None, ip6=None, ethernet={ }, alias=(), owner=None, boot=None, alias4=None, alias6=None) :
"""
host - str
domain - str
@@ -100,6 +116,8 @@
ethernet - { index: ethernet }
alias - list
owner - str: LDAP uid
+ alias4 - list (CNAME -> A)
+ alias6 - list (CNAME -> AAAA)
"""
self.host = host
self.domain = domain
@@ -107,6 +125,8 @@
self.ip6 = ip6
self.ethernet = ethernet
self.alias = alias
+ self.alias4 = alias4
+ self.alias6 = alias6
self.owner = owner
self.boot = boot