pvl.hosts-dhcp: quote
authorTero Marttila <terom@paivola.fi>
Thu, 19 Dec 2013 03:06:51 +0200
changeset 317 2859d3dedcfe
parent 316 41bd6688b142
child 318 304f56896942
pvl.hosts-dhcp: quote
bin/pvl.hosts-dhcp
--- a/bin/pvl.hosts-dhcp	Thu Dec 19 02:50:59 2013 +0200
+++ b/bin/pvl.hosts-dhcp	Thu Dec 19 03:06:51 2013 +0200
@@ -18,6 +18,9 @@
             raise ValueError("Unknown item: %r", item)
     yield "}"
 
+def dhcp_quote (value) :
+    return '"{value}"'.format(value=value)
+
 def process_host (options, host) :
         if host.owner :
             yield u"# {host.owner}".format(host=host)
@@ -43,11 +46,11 @@
 
         for index, ethernet in host.ethernet.iteritems() :
             for line in build_host(host_fmt.format(host=host, index=index),
-                    { 'option host-name':   str(host) },
+                    { 'option host-name':   dhcp_quote(host) },
                     { 'hardware ethernet':  ethernet },
                     { 'fixed-address':      host.ip },
                     { 'next-server':        next_server },
-                    { 'filename':           filename },
+                    { 'filename':           dhcp_quote(filename) },
             ) :
                 yield line