Changeset 6548


Ignore:
Timestamp:
Jan 4, 2009, 10:56:22 AM (16 years ago)
Author:
roland
Message:

Fixed a bug regarding hostname check.
Added debug lines in genesis_to_exodus, when an error happens
during import. Added sqlite to easily make a list of point_to_point
connections for ethernet. Ethernet interface links will probably have to
be added manually later on because not all ethernet links have p_t_p
links, and it's probably to much work to check the subnets.

Location:
trunk/exodus
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/exodus/forms.py

    r6534 r6548  
    2020        name = self.cleaned_data.get('name')
    2121        re_name = re.compile('[0-9a-zA-Z-]+')
    22         if not re_name.match(name) or re_name.match(name) != name:
     22        if not re_name.match(name) or re_name.match(name).group() != name:
     23            print name
    2324            raise forms.ValidationError(
    24                     'Not a valid name. Use letters, digits and -.')
     25                    'Not a Node valid name. Use letters, digits and -.')
    2526        return name
    2627
  • trunk/exodus/scripts/genesis_to_exodus.py

    r6516 r6548  
    66from exodus.models import Node, Location, Interface, Antenna
    77import ConfigParser
     8import sqlite3
    89from sys import argv
    910
     
    2122            for i in loc.errors.keys():
    2223                print loc.errors[i][0]
     24                print loc
     25            import pdb; pdb.set_trace() ;
    2326            return None
    2427        locmodel = loc.save()
     
    4144            for i in form.errors.keys():
    4245                print form.errors[i][0]
     46            import pdb; pdb.set_trace() ;
    4347            return None
    4448    return nodemodel.id
     
    6165        for i in form.errors.keys():
    6266            print form.errors[i][0]
     67        import pdb; pdb.set_trace() ;
    6368        return None
    6469    return intfmodel.id
     
    8388    dataform ={'name' : 'Foo8', 'location' : '1', 'status' : 'up', 
    8489            'network' : '1', 'masterip' : '127.0.0.1' }
    85     networks = { }
     90    networks = {}
     91    ethernet = []
     92    conn = sqlite3.connect(':memory:')
     93    cursor = conn.cursor()
     94    cursor.execute('CREATE TABLE ifaceip (id INTEGER PRIMARY KEY, iface VARCHAR(20), ip VARCHAR(20))')
    8695    config = ConfigParser.SafeConfigParser(dataform)
    8796    # last cmdline argument is supposed to be the config file to use
     
    183192                                pass
    184193
     194                #ethernet stuff
     195                for intf in interfaces.split(','):
     196                    cfgsection = node['name']+'/'+intf
     197                    # build a list of all ethernet interfaces
     198                    if config.has_section(cfgsection) and \
     199                            config.get(cfgsection, 'type') == 'eth' and \
     200                            config.has_option(cfgsection, 'ip'):
     201                        ethernet.append(cfgsection)
     202                        cursor.execute('insert INTO ifaceip VALUES '
     203                                '(null, ?, ?)', ( cfgsection,
     204                                config.get(cfgsection, 'ip').rsplit('/')[0]))
     205                       
     206                    conn.commit()
     207
     208    import pdb; pdb.set_trace() ;
     209    non_alias = (i for i in ethernet if not ":" in i)
     210    for i in non_alias:
     211        for j in [ k for k in ethernet if k.startswith(i)]:
     212            if config.has_section(j) and \
     213                    config.has_option(j, 'point_to_point'):
     214                p2p = config.get(j, 'point_to_point')
     215                cursor.execute('SELECT iface FROM ifaceip where ip = ?', (p2p,))
     216                print cursor.fetchone()
     217               
     218             
    185219
    186220    # now we have already created all nodes and master interfaces...
Note: See TracChangeset for help on using the changeset viewer.