bin/pvl.hosts-import
changeset 281 b236f689ba22
parent 280 8118854bfa6f
child 285 e18aaec99e54
equal deleted inserted replaced
280:8118854bfa6f 281:b236f689ba22
   103             continue
   103             continue
   104 
   104 
   105         elif rr.type in ('A', 'AAAA') :
   105         elif rr.type in ('A', 'AAAA') :
   106             ip, = rr.data
   106             ip, = rr.data
   107 
   107 
   108             yield rr.name, 'ip', ipaddr.IPAddress(ip)
   108             type = { 'A': 'ip', 'AAAA': 'ip6' }[rr.type]
       
   109 
       
   110             yield rr.name, type, ipaddr.IPAddress(ip)
   109 
   111 
   110             if rr.comment :
   112             if rr.comment :
   111                 yield rr.name, 'comment', rr.comment
   113                 yield rr.name, 'comment', rr.comment
   112 
   114 
   113             if rr.origin :
   115             if rr.origin :
   457 
   459 
   458         print >>file, u"[{host}]".format(host=host)
   460         print >>file, u"[{host}]".format(host=host)
   459         
   461         
   460         for field, fmt in (
   462         for field, fmt in (
   461                 ('ip',              None),
   463                 ('ip',              None),
       
   464                 ('ip6',             None),
   462                 ('ethernet',        None),
   465                 ('ethernet',        None),
   463                 ('owner',           u"\t{field:15} = {value} # {fields[comment-owner][0]}"),
   466                 ('owner',           u"\t{field:15} = {value} # {fields[comment-owner][0]}"),
   464                 ('alias',           None),
   467                 ('alias',           None),
   465                 ('boot',            None),
   468                 ('boot',            None),
   466         ) :
   469         ) :