Changeset 13598 in genesis


Ignore:
Timestamp:
Aug 9, 2016, 11:49:24 AM (8 years ago)
Author:
rick
Message:

Workaround for USB NIC w/o MAC address.

Some USB dongles do not have an MAC address, defaulting to 00:00:00:00:00:00.
This will cause issues on systems with multiple off them. Workaround is to use
an 'local' MAC adress. To ensure uniqueness use the IP of the the interface as
reference for creating the mac address.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • nodes/GHR/wleiden.yaml

    r13597 r13598  
    3838iface_ue0:
    3939  comment    : "Link naar Kaag2"
     40  ether      : "02:00:ac:10:07:44"
    4041  ip         : "172.16.7.68/29"
    4142  sdesc      : "2kaag2"
  • tools/gformat.py

    r13568 r13598  
    615615
    616616
     617class AutoVivification(dict):
     618    """Implementation of perl's autovivification feature."""
     619    def __getitem__(self, item):
     620        try:
     621            return dict.__getitem__(self, item)
     622        except KeyError:
     623            value = self[item] = type(self)()
     624            return value
     625
    617626def make_interface_list(datadump):
    618627  if interface_list_cache.has_key(datadump['autogen_item']):
     
    624633  addrs_list = { 'lo0' : [("127.0.0.1/8", "LocalHost"), ("172.31.255.1/32","Proxy IP")] }
    625634  vlan_list = defaultdict(list)
     635  flags_if = AutoVivification()
    626636  dhclient_if = {'lo0' : False}
    627637
     
    648658    if not dhclient_if.has_key(ifname) or dhclient_if[ifname] == False:
    649659      dhclient_if[ifname] = dhcp_type(ifacedump) == DHCP_CLIENT
     660
     661    # Ethernet address
     662    if ifacedump.has_key('ether'):
     663        flags_if[ifname]['ether'] = ifacedump['ether']
    650664
    651665    # DHCP interfaces are to be added to bridge0
     
    705719      assert False, "Unknown type " + ifacedump['type']
    706720
    707   store = (addrs_list, vlan_list, dhclient_if, output)
     721  store = (addrs_list, vlan_list, dhclient_if, flags_if, output)
    708722  interface_list_cache[datadump['autogen_item']] = store
    709723  return(store)
     
    887901""")
    888902
    889   (addrs_list, vlan_list, dhclient_if, extra_ouput) = make_interface_list(datadump)
     903  (addrs_list, vlan_list, dhclient_if, flags_if, extra_ouput) = make_interface_list(datadump)
    890904  for iface, vlans in vlan_list.items():
    891905    output += 'vlans_%s="%s"\n' % (iface, ' '.join(vlans))
     
    927941      output += "ifconfig_bridge0='%s up'\n" % addrs[0][0]
    928942    else:
    929       output += "ifconfig_%s='inet %s'\n" % (iface, addrs[0][0])
     943      if flags_if[iface].has_key('ether'):
     944        output += "ifconfig_%s='ether %s inet %s'\n" % (iface, flags_if[iface]['ether'], addrs[0][0])
     945      else:
     946        output += "ifconfig_%s='inet %s'\n" % (iface, addrs[0][0])
    930947    for idx, addr in enumerate(addrs[1:]):
    931948      output += "ifconfig_%s_alias%s='inet %s'\n" % (iface, idx, addr[0])
     
    9881005
    9891006def get_neighbours(datadump):
    990   (addrs_list, _, dhclient_if, extra_ouput) = make_interface_list(datadump)
     1007  (addrs_list, _, dhclient_if, _, extra_ouput) = make_interface_list(datadump)
    9911008
    9921009  (poel, errors) = make_relations()
     
    11531170        return lines
    11541171
    1155   (addrs_list, vlan_list, dhclient_if, extra_ouput) = make_interface_list(datadump)
     1172  (addrs_list, vlan_list, dhclient_if, flags_if, extra_ouput) = make_interface_list(datadump)
    11561173  table = []
    11571174  for iface,addrs in sorted(addrs_list.iteritems()):
Note: See TracChangeset for help on using the changeset viewer.