pvl/hosts/host.py
changeset 733 45bedeba92e5
parent 696 55796948021e
child 734 5770ed34c1f0
--- a/pvl/hosts/host.py	Sat Mar 07 16:31:11 2015 +0200
+++ b/pvl/hosts/host.py	Mon Mar 09 18:00:18 2015 +0200
@@ -176,10 +176,16 @@
             This handles all string parsing to our data types.
         """
 
+        ip4 = parse_dict(ip, ipaddr.IPv4Address)
+        ip6 = parse_dict(ip6, ipaddr.IPv6Address)
+
+        ip = {label: (ip4.get(label), ip6.get(label)) for label in set(ip4) | set(ip6)}
+
         return cls(name,
                 domain      = domain,
-                ip          = parse_ip(ip, ipaddr.IPv4Address),
-                ip6         = parse_ip(ip6, ipaddr.IPv6Address),
+                ip4         = ip4.get(None),
+                ip6         = ip6.get(None),
+                ip          = ip,
                 ethernet    = parse_dict(ethernet,  parse_ethernet),
                 owner       = owner,
                 location    = parse_location(location, domain),
@@ -194,7 +200,8 @@
         )
 
     def __init__ (self, name, domain,
-            ip=None, ip6=None,
+            ip4=None, ip6=None,
+            ip={},
             ethernet={ },
             owner=None,
             location=None,
@@ -207,8 +214,9 @@
         """
             name        - str
             domain      - str
-            ip          - ipaddr.IPv4Address
-            ip6         - ipaddr.IPv6Address
+            ip4         - primary ipaddr.IPv4Address
+            ip6         - primary ipaddr.IPv6Address
+            ip          - secondary { index: (ip4, ip6) } interface addresses
             ethernet    - { index: ethernet }
             alias       - [ str ]: generate CNAMEs for given relative names
             owner       - str: LDAP uid
@@ -226,8 +234,9 @@
 
         self.name = name
         self.domain = domain
+        self.ip4 = ip4
+        self.ip6 = ip6
         self.ip = ip
-        self.ip6 = ip6
         self.ethernet = ethernet
         self.alias = alias
         self.alias4 = alias4