Changeset 13169 in genesis for tools/gformat.py


Ignore:
Timestamp:
Feb 17, 2015, 8:47:27 PM (10 years ago)
Author:
rick
Message:

Quick to define bridge interfaces, example:

iface_bridge0:

comment : "Link naar RickRing"
ip : "172.16.6.114/28"
sdesc : "2ring"
type : "eth"
dhcp : False
status : "up"
members : "vr1 vr2"

iface_bridge0_alias0:

comment : "Link naar Ed"
ip : "172.17.2.250/29"
sdesc : "2ed"
type : "eth"
dhcp : False
status : "up"

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/gformat.py

    r13079 r13169  
    217217        else:
    218218          datadump[key]['autogen_ifname'] = datadump[key]['autogen_ifbase']
     219        datadump[key]['autogen_bridge'] = datadump[key]['autogen_ifbase'].startswith('bridge')
     220        if datadump[key]['autogen_bridge'] and not 'alias' in key:
     221          datadump[key]['autogen_bridge_interfaces'] = datadump[key]['members'].split()
    219222    except Exception as e:
    220223      print "# Error while processing interface %s" % key
     
    653656      output += ("create_args_%(autogen_ifname)s='wlanmode %(autogen_wlanmode)s mode " +\
    654657        "%(type)s ssid %(ssid)s %(autogen_extra)s channel %(channel)s'\n") % ifacedump
     658      output += "\n"
    655659
    656660    elif ifacedump['type'] in ['ethernet', 'eth']:
    657661      # No special config needed besides IP
    658       pass
     662      if ifacedump['autogen_bridge']:
     663        output += "cloned_interfaces='%(autogen_ifname)s'\n" % ifacedump
     664        output += "ifconfig_%s='addm %s up'\n" % (ifacedump['autogen_ifname'], ' addm '.join(ifacedump['autogen_bridge_interfaces']))
     665        for member in ifacedump['autogen_bridge_interfaces']:
     666          output += "ifconfig_%s='up'\n" % member
     667        output += "\n"
    659668    else:
    660669      assert False, "Unknown type " + ifacedump['type']
     
    839848
    840849  (addrs_list, dhclient_if, extra_ouput) = make_interface_list(datadump)
    841   output += extra_ouput
     850  output += extra_ouput.strip() + "\n"
    842851
    843852  # Print IP address which needs to be assigned over here
     
    11011110    ('ns_type', False),
    11021111    ('bridge_type', False),
     1112    ('members', True),
    11031113    ('status', True),
    11041114  )
Note: See TracChangeset for help on using the changeset viewer.