Changeset 14230 in genesis for tools/gformat.py


Ignore:
Timestamp:
Nov 21, 2018, 9:11:45 AM (6 years ago)
Author:
rick
Message:

Add gformat feature to disable broken interfaces

Both Meelfabriek2 and PanTerra1 have flapping interfaces

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/gformat.py

    r14206 r14230  
    716716    if ifacedump.has_key('ether'):
    717717        flags_if[ifname]['ether'] = ifacedump['ether']
     718
     719    # Handle special interface states
     720    flags_if[ifname]['status'] = ifacedump['status']
    718721
    719722    # Add interface IP to list
     
    9981001      output += "# %s || %s || %s\n" % (iface, addr, comment)
    9991002
     1003    prefix = ''
     1004    if flags_if[iface]['status'] == 'broken':
     1005        output += "# Interface %s disabled since status=broken\n" % iface
     1006        prefix = '#'
     1007
    10001008    # Write DHCLIENT entry
    10011009    if iface in dhclient_if and dhclient_if[iface]:
    1002       output += "ifconfig_%s='SYNCDHCP'\n\n" % (iface)
     1010      output += prefix + "ifconfig_%s='SYNCDHCP'\n\n" % (iface)
    10031011      continue
    10041012   
     
    10111019      )
    10121020
     1021
    10131022    idx_offset = 0
    10141023    # Set MAC is required
    10151024    if flags_if[iface].has_key('ether'):
    1016       output += "ifconfig_%s='link %s'\n" % (iface, flags_if[iface]['ether'])
    1017       output += "ifconfig_%s_alias0='inet %s'\n" % (iface, addrs[0][0])
     1025      output += prefix + "ifconfig_%s='link %s'\n" % (iface, flags_if[iface]['ether'])
     1026      output += prefix + "ifconfig_%s_alias0='inet %s'\n" % (iface, addrs[0][0])
    10181027      idx_offset += 1
    10191028    elif iface in bridge_list: 
    1020       output += "ifconfig_%s_alias0='inet %s'\n" % (iface, addrs[0][0])
     1029      output += prefix + "ifconfig_%s_alias0='inet %s'\n" % (iface, addrs[0][0])
    10211030      idx_offset += 1
    10221031    else:   
    1023       output += "ifconfig_%s='inet %s'\n" % (iface, addrs[0][0])
     1032      output += prefix + "ifconfig_%s='inet %s'\n" % (iface, addrs[0][0])
    10241033       
    10251034    for idx, addr in enumerate(addrs[1:]):
    1026       output += "ifconfig_%s_alias%s='inet %s'\n" % (iface, idx + idx_offset, addr[0])
     1035      output += prefix + "ifconfig_%s_alias%s='inet %s'\n" % (iface, idx + idx_offset, addr[0])
    10271036
    10281037    output += "\n"
Note: See TracChangeset for help on using the changeset viewer.