Changeset 6486


Ignore:
Timestamp:
Dec 28, 2008, 12:34:42 AM (16 years ago)
Author:
roland
Message:

Updated genesis_to_exodus.py with some stuff.
Fixed a bug, and rewrote code, added comments.

Location:
trunk/exodus/scripts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/exodus/scripts/README

    r6485 r6486  
    33$ svn co http://svn.wirelessleiden.nl/svn/node-config/genesis $SVNROOT
    44$ cd $SVNROOT/nodes
     5# make sure that unused nodes aren't in the py.conf file
    56$ for file in */wleiden.conf; do ./genesis-to-py.pl $file; done > py.conf
    67$ cd 
  • trunk/exodus/scripts/genesis_to_exodus.py

    r6485 r6486  
    1414        # XXX - should we update an existing location with new lat/lon data ?
    1515    else:
    16         location = LocationForm({ 'description': location['descr'],
     16        # XXX: you were overwriting location, which meant that the dict
     17        #      location was overwritten.
     18        loc = LocationForm({ 'description': location['descr'],
    1719            'latitude': location['lat'], 'longitude': location['lon'] })
    18         locmodel = location.save()
    19         print 'Location ' + location['descr'] + 'created'
    20         if not location.is_valid():
     20        if not loc.is_valid():
    2121            print location._errors
    2222            return None
     23        locmodel = loc.save()
     24        print 'Location ' + location['descr'] + 'created'
    2325    return locmodel.id
    2426
     
    2628    nodesearch = Node.objects.filter(name__exact=node['name'])
    2729    if len(nodesearch):
     30        # XXX: Add check that len == 1, else multiple nodes with the same
     31        # name could exist and the wrong one might be returned
    2832        print 'Node '+node['name']+' already exists'
    2933        nodemodel = nodesearch[0]
     
    7579    dataform ={'name' : 'Foo8', 'location' : '1', 'status' : 'up', 
    7680            'network' : '1', 'masterip' : '127.0.0.1' }
    77     import pdb; pdb.set_trace() ;
    7881    networks = { }
    7982    config = ConfigParser.SafeConfigParser(dataform)
     
    8487    for s in sections:
    8588        # get only main node blocks (interface-specific blocks
    86         #will be accessed later)
    87         if s.find('/') == -1:
     89        # will be accessed later)
     90        if not '/' in s :
    8891            node = { }
    8992            for key in dataform:
     
    9295                location = { }
    9396                location['descr'] = config.get(s, 'location')
    94                 if location['descr']:
     97                if location.has_key('descr'):
    9598                    location['lat'] = config.get(s, 'latitude')
    9699                    location['lon'] = config.get(s, 'longitude')
     
    105108                interfaces = config.get(s, 'interfaces')
    106109                for intf in interfaces.split(','):
    107                     if intf.find(':') == -1: # alias interface
     110                    if not ':' in intf: # discard alias interface
    108111                        cfgsection = node['name']+'/'+intf
    109112                        # check for an interface-specific block
    110113                        if config.has_section(cfgsection):
    111114                            # interface defaults
    112                             interface = { 'iface': intf, 'netmask': 24,
    113                                     'ip': '127.0.0.1', 'mode': 'ms', 
    114                                     'polar': '', 'type': 'eth', 
     115                            interface = { 'iface': intf, 'netmask': 32,
     116                                    'ip': '127.0.0.1', 'mode': 'ms',
     117                                    'polar': '', 'type': 'eth',
    115118                                    'accesspoint': False }
    116119
     120                            #XXX: this section can be discarded because
     121                            #     there is no need to import ips.
    117122                            if config.has_option(cfgsection, 'ip'):
    118123                                ip = config.get(cfgsection, 'ip')
     
    122127                                else:
    123128                                    interface['ip'] = ip
     129                           
    124130                            for key in [ 'type', 'desc', 'ssid', 'channel',
    125131                                    'mode', 'polar' ]:
     
    128134                                            key)
    129135                            interface['node'] = nodeid
     136
     137                            # XXX: The genesis data is complete, the type of
     138                            #      antenna needs to be passed on.
     139                            #      it's probably better
    130140
    131141                            # handle Antenna
     
    143153                                    networks[ssid] = { 'links': [] }
    144154                                if interface['mode'] == 'ms':
     155                                    #XXX: if dhcp != 'no' accesspoint = 1
    145156                                    interface['accesspoint'] = 1
    146157                                    networks[ssid]['master'] = import_interface(interface)
     
    150161                                # XXX - should we handle links on not-wifi
    151162                                # interfaces?
    152                                 # ROLAND: yes we should
     163                                # XXX: yes we should
    153164                                import_interface(interface)
    154165
     
    161172    #       links later (once we have already configured all master interfaces) instead of
    162173    #       trying to update interfaces progressively
     174
     175    # XXX:this needn't be done, because exodus defines the ssid.
    163176    for ssid in networks:
    164177        for interface in networks[ssid]['links']:
Note: See TracChangeset for help on using the changeset viewer.