pvl.hosts.dhcp: fix mixed ethernet instance/None naming to be per-dhcp-host
authorTero Marttila <terom@paivola.fi>
Sat, 07 Mar 2015 13:44:59 +0200
changeset 731 5e2c1b78047d
parent 730 2073e2e20895
child 732 ddb77f32b35a
pvl.hosts.dhcp: fix mixed ethernet instance/None naming to be per-dhcp-host
pvl/hosts/dhcp.py
--- a/pvl/hosts/dhcp.py	Sat Mar 07 13:41:18 2015 +0200
+++ b/pvl/hosts/dhcp.py	Sat Mar 07 13:44:59 2015 +0200
@@ -42,11 +42,7 @@
             subclass: name      - generate a subclass name $ethernet for this host
     """
 
-    if set(host.ethernet) == set([None]) :
-        host_fmt = "{host.name}"
-    elif host.ethernet :
-        host_fmt = "{host.name}-{index}"
-    else :
+    if not host.ethernet:
         # nothing to be seen here
         return
  
@@ -56,7 +52,11 @@
         comment = None
 
     for index, ethernet in host.ethernet.iteritems() :
-        name = host_fmt.format(host=host, index=index)
+        if index:
+            name = '{host.name}-{index}'.format(host=host, index=index)
+        else:
+            name = '{host.name}'.format(host=host)
+
         items = list(dhcp_host_options(host, ethernet))
 
         yield pvl.dhcp.config.Block(('host', name), items, comment=comment)