Changeset 10887 in genesis for tools/gformat.py


Ignore:
Timestamp:
May 16, 2012, 9:32:05 PM (13 years ago)
Author:
rick
Message:

Weg met die vervelende dhcpclient flag, merge in de dhcp vlag.

Fixes beheer:ticket:220

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/gformat.py

    r10885 r10887  
    9797datadump_cache = {}
    9898
     99NO_DHCP = 0
     100DHCP_CLIENT = 10
     101DHCP_SERVER = 20
     102def dhcp_type(item):
     103  if not item.has_key('dhcp'):
     104    return NO_DHCP
     105  elif not item['dhcp']:
     106    return NO_DHCP
     107  elif item['dhcp'].lower() == 'client':
     108    return DHCP_CLIENT
     109  else:
     110    return DHCP_SERVER
     111
    99112def get_yaml(item):
    100113  try:
     
    139152      raise
    140153
    141     dhcp_interfaces = [datadump[key]['autogen_ifname'] for key in datadump['autogen_iface_keys'] if (datadump[key].has_key('dhcp') and datadump[key]['dhcp'])]
     154    dhcp_interfaces = [datadump[key]['autogen_ifname'] for key in datadump['autogen_iface_keys'] \
     155      if dhcp_type(datadump[key]) == DHCP_SERVER]
     156
    142157    datadump['autogen_dhcp_interfaces'] = dhcp_interfaces
    143158    datadump['autogen_item'] = item
     
    433448    datadump[iface_key]['autogen_subnet'] = get_network(addr, mask)
    434449    try:
     450      if dhcp_type(datadump[iface_key]) != DHCP_SERVER:
     451        raise ValueError
    435452      (dhcp_start, dhcp_stop) = datadump[iface_key]['dhcp'].split('-')
    436453    except (AttributeError, ValueError, KeyError):
     
    678695
    679696    # Flag dhclient is possible
    680     dhclient_if[ifname] = ifacedump.has_key('dhcpclient') and ifacedump['dhcpclient']
     697    dhclient_if[ifname] = dhcp_type(ifacedump) == DHCP_CLIENT
    681698
    682699    # Add interface IP to list
     
    948965    ('ssid', False),
    949966    ('dhcp', True),
    950     ('dhcpclient', False),
    951967    ('compass', False),
    952968    ('distance', False),
Note: See TracChangeset for help on using the changeset viewer.