Changeset 6485


Ignore:
Timestamp:
Dec 27, 2008, 10:49:10 PM (16 years ago)
Author:
roland
Message:

Added a readme script and removed linewraps in genesis_to_exodus.
Plus added some comments.

Location:
trunk/exodus/scripts
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/exodus/scripts/genesis_to_exodus.py

    r6473 r6485  
    3939
    4040def import_interface(interface):
    41     isearch = Interface.objects.filter(node__exact=interface['node'], iface__exact=interface['iface'])
     41    isearch = Interface.objects.filter(node__exact=interface['node'], \
     42            iface__exact=interface['iface'])
    4243    if len(isearch):
    4344        # XXX - should we update existing interfaces ??
     
    5051    else:
    5152        print 'Can\'t import interface '+interface['iface']
    52         print form._errors # XXX - outputs html but this is supposed to be a console script
     53        # XXX - outputs html but this is supposed to be a console script
     54        print form._errors
    5355        return None
    5456    return intfmodel.id
    5557
    5658def import_antenna(antenna):
    57     antsearch = Antenna.objects.filter(type__exact=antenna['type'], gain__exact=antenna['gain'])
     59    antsearch = Antenna.objects.filter(type__exact=antenna['type'],
     60            gain__exact=antenna['gain'])
    5861    if len(antsearch):
    5962        return antsearch[0].id
     
    6770    print """Import script for genesis."""
    6871
    69     # Please do mind to keep all the entries valid, altough some get values get updated
    70     dataform ={'name' : 'Foo8', 'location' : '1', 'status' : 'up',  'network' : '1', 'masterip' : '127.0.0.1' }
    71 
     72    # Please do mind to keep all the entries valid, altough some get
     73    # values get updated (i.e. mastip, ip, ssid, netmask, mode, channel,
     74    # shortdesc, desc
     75    dataform ={'name' : 'Foo8', 'location' : '1', 'status' : 'up', 
     76            'network' : '1', 'masterip' : '127.0.0.1' }
     77    import pdb; pdb.set_trace() ;
    7278    networks = { }
    7379    config = ConfigParser.SafeConfigParser(dataform)
    74     config.read(argv[len(argv)-1]) # last cmdline argument is supposed to be the config file to use
     80    # last cmdline argument is supposed to be the config file to use
     81    config.read(argv[len(argv)-1])
    7582    sections = config.sections()
    7683    sections.sort()
    7784    for s in sections:
    78         if s.find('/') == -1: # get only main node blocks (interface-specific blocks will be accessed later)
     85        # get only main node blocks (interface-specific blocks
     86        #will be accessed later)
     87        if s.find('/') == -1:
    7988            node = { }
    8089            for key in dataform:
     
    8897                    node['location'] = import_location(location)
    8998                else:
    90                     node['location'] = 1 # unknown/unconfigured location has id 1
     99                    #XXX: Don't do this, an error should be raised.
     100                    # unknown/unconfigured location has id 1
     101                    node['location'] = 1
    91102
    92103            nodeid = import_node(node)
     
    96107                    if intf.find(':') == -1: # alias interface
    97108                        cfgsection = node['name']+'/'+intf
    98                         if config.has_section(cfgsection): # check for an interface-specific block
     109                        # check for an interface-specific block
     110                        if config.has_section(cfgsection):
    99111                            # interface defaults
    100                             interface = { 'iface': intf, 'netmask': 24, 'ip': '127.0.0.1', 'mode': 'ms', 'polar': '', 'type': 'eth', 'accesspoint': False }
     112                            interface = { 'iface': intf, 'netmask': 24,
     113                                    'ip': '127.0.0.1', 'mode': 'ms',
     114                                    'polar': '', 'type': 'eth',
     115                                    'accesspoint': False }
    101116
    102117                            if config.has_option(cfgsection, 'ip'):
     
    107122                                else:
    108123                                    interface['ip'] = ip
    109                             for key in [ 'type', 'desc', 'ssid', 'channel', 'mode', 'polar' ]:
     124                            for key in [ 'type', 'desc', 'ssid', 'channel',
     125                                    'mode', 'polar' ]:
    110126                                if (config.has_option(cfgsection, key)):
    111                                     interface[key] = config.get(cfgsection, key)
     127                                    interface[key] = config.get(cfgsection,
     128                                            key)
    112129                            interface['node'] = nodeid
    113130
     
    130147                                else:
    131148                                    networks[ssid]['links'].append(interface);
    132                             else: # XXX - should we handle links on not-wifi interfaces?
     149                            else:
     150                                # XXX - should we handle links on not-wifi
     151                                # interfaces?
     152                                # ROLAND: yes we should
    133153                                import_interface(interface)
    134154
Note: See TracChangeset for help on using the changeset viewer.