Changeset 6485
- Timestamp:
- Dec 27, 2008, 10:49:10 PM (16 years ago)
- Location:
- trunk/exodus/scripts
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/exodus/scripts/genesis_to_exodus.py
r6473 r6485 39 39 40 40 def 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']) 42 43 if len(isearch): 43 44 # XXX - should we update existing interfaces ?? … … 50 51 else: 51 52 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 53 55 return None 54 56 return intfmodel.id 55 57 56 58 def 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']) 58 61 if len(antsearch): 59 62 return antsearch[0].id … … 67 70 print """Import script for genesis.""" 68 71 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() ; 72 78 networks = { } 73 79 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]) 75 82 sections = config.sections() 76 83 sections.sort() 77 84 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: 79 88 node = { } 80 89 for key in dataform: … … 88 97 node['location'] = import_location(location) 89 98 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 91 102 92 103 nodeid = import_node(node) … … 96 107 if intf.find(':') == -1: # alias interface 97 108 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): 99 111 # 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 } 101 116 102 117 if config.has_option(cfgsection, 'ip'): … … 107 122 else: 108 123 interface['ip'] = ip 109 for key in [ 'type', 'desc', 'ssid', 'channel', 'mode', 'polar' ]: 124 for key in [ 'type', 'desc', 'ssid', 'channel', 125 'mode', 'polar' ]: 110 126 if (config.has_option(cfgsection, key)): 111 interface[key] = config.get(cfgsection, key) 127 interface[key] = config.get(cfgsection, 128 key) 112 129 interface['node'] = nodeid 113 130 … … 130 147 else: 131 148 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 133 153 import_interface(interface) 134 154
Note:
See TracChangeset
for help on using the changeset viewer.