- Timestamp:
- Dec 16, 2015, 8:54:23 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/gformat.py
r13516 r13524 509 509 # Interface definitions 510 510 # 511 \n""").render(datadump) 511 \n\n""").render(datadump) 512 513 514 # TODO: Use textwrap.fill instead 515 def indent(text, count): 516 return '\n'.join(map(lambda x: ' ' * count + x, text.split('\n'))) 512 517 513 518 dhcp_out = defaultdict(list) … … 518 523 519 524 if dhcp_type(datadump[iface_key]) != DHCP_SERVER: 520 dhcp_out[iface_key].append(" 525 dhcp_out[iface_key].append("## %(autogen_ifname)s - %(comment)s\n" % datadump[iface_key]) 521 526 else: 522 dhcp_out[ ifname].append("## %(autogen_ifname)s - %(comment)s\n" % datadump[iface_key])527 dhcp_out['bridge0'].append(" ## %(autogen_ifname)s - %(comment)s\n" % datadump[iface_key]) 523 528 524 529 (addr, mask) = datadump[iface_key]['ip'].split('/') … … 526 531 datadump[iface_key]['autogen_netmask'] = cidr2netmask(mask) 527 532 datadump[iface_key]['autogen_subnet'] = get_network(addr, mask) 533 528 534 if dhcp_type(datadump[iface_key]) != DHCP_SERVER: 529 dhcp_out[iface_key].append(" subnet %(autogen_subnet)s netmask %(autogen_netmask)s {\n ### not autoritive\n }\n" % \ 530 datadump[iface_key]) 535 dhcp_out[iface_key].append(textwrap.dedent("""\ 536 subnet %(autogen_subnet)s netmask %(autogen_netmask)s { 537 ### not autoritive 538 } 539 """ % datadump[iface_key])) 531 540 continue 532 541 … … 540 549 fixed = 5 541 550 for mac in datadump['no_portal']: 542 dhcp_out[ ifname].append("""\551 dhcp_out['bridge0'].append("""\ 543 552 host fixed-%(ifname)s-%(fixed)s { 544 553 hardware ethernet %(mac)s; … … 548 557 fixed += 1 549 558 550 dhcp_out[ ifname].append("""\559 dhcp_out['bridge0'].append("""\ 551 560 subnet %(autogen_subnet)s netmask %(autogen_netmask)s { 552 561 range %(autogen_dhcp_start)s %(autogen_dhcp_stop)s; … … 554 563 option domain-name-servers %(autogen_addr)s; 555 564 } 565 556 566 """ % datadump[iface_key]) 557 567 558 568 for ifname,value in dhcp_out.iteritems(): 559 output += ("shared-network %s {\n" % ifname) + ''.join(value) + '}\n\n' 569 if ifname == 'bridge0': 570 output += ("shared-network %s {\n" % ifname) + ''.join(value) + '}\n\n' 571 else: 572 output += ''.join(value) + "\n\n" 560 573 return output 561 574
Note:
See TracChangeset
for help on using the changeset viewer.