Changeset 5e1fb7b


Ignore:
Timestamp:
May 27, 2010 7:40:12 AM (14 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
Children:
a65a65a
Parents:
1962a5b
Message:

Get all those attributes out of the access DB. Bad design.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/emulab_access.py

    r1962a5b r5e1fb7b  
    9797        self.cleanup = not config.getboolean("access", "leave_tmpfiles")
    9898        self.access_type = config.get("access", "type")
    99    
     99
     100        self.dragon_endpoint = config.get("access", "dragon")
     101        self.dragon_vlans = config.get("access", "dragon_vlans")
     102        self.deter_internal = config.get("access", "deter_internal")
     103
     104        self.tunnel_config = config.getboolean("access", "tunnel_config")
     105        self.portal_command = config.get("access", "portal_command")
     106        self.portal_image = config.get("access", "portal_image")
     107        self.portal_type = config.get("access", "portal_type") or "pc"
     108        self.portal_startcommand = config.get("access", "portal_startcommand")
     109        self.node_startcommand = config.get("access", "node_startcommand")
     110
    100111        self.federation_software = software_list(self.federation_software)
    101112        self.portal_software = software_list(self.portal_software)
     
    113124            self.stop_segment = None
    114125
    115         self.attrs = { }
    116126        self.access = { }
    117127        self.restricted = [ ]
     
    258268
    259269        restricted_re = re.compile("restricted:\s*(.*)", re.IGNORECASE)
    260         attr_re = re.compile('attribute:\s*([\._\-a-z0-9]+)\s+value:\s*(.*)',
    261                 re.IGNORECASE)
    262270        access_re = re.compile('\('+key_name+'\s*,\s*'+key_name+'\s*,\s*'+
    263271                key_name+'\s*\)\s*->\s*\('+access_proj + '\s*,\s*' +
     
    280288            line = line.strip();
    281289            if len(line) == 0 or line.startswith('#'):
    282                 continue
    283 
    284             # Extended (attribute: x value: y) attribute line
    285             m = attr_re.match(line)
    286             if m != None:
    287                 attr, val = m.group(1,2)
    288                 self.attrs[attr] = val
    289290                continue
    290291
     
    717718                ]
    718719            }
    719         if len(self.attrs) > 0:
    720             msg['fedAttr'].extend(
    721                 [ { 'attribute': x, 'value' : y } \
    722                         for x,y in self.attrs.iteritems()])
     720
     721        if self.dragon_endpoint:
     722            msg['fedAttr'].append({'attribute': 'dragon',
     723                'value': self.dragon_endpoint})
     724        if self.deter_internal:
     725            print 'adding internal'
     726            msg['fedAttr'].append({'attribute': 'deter_internal',
     727                'value': self.deter_internal})
     728        else: print "internal: %s" % self.deter_internal
     729        #XXX: ??
     730        if self.dragon_vlans:
     731            msg['fedAttr'].append({'attribute': 'vlans',
     732                'value': self.dragon_vlans})
    723733
    724734        if services:
     
    735745
    736746        def gateway_hardware(h):
    737             if h == 'GWTYPE': return self.attrs.get('connectorType', 'GWTYPE')
     747            if h == 'GWTYPE': return self.portal_type or 'GWTYPE'
    738748            else: return h
    739749
     
    11941204
    11951205            cfn = "%s/%s.gw.conf" % (tmpdir, myname.lower())
    1196             tunnelconfig = self.attrs.has_key('TunnelCfg')
     1206            tunnelconfig = self.tunnel_config
    11971207            try:
    11981208                f = open(cfn, "w")
     
    13181328                        "Missing connectivity info")
    13191329
    1320         # The startcmds for master and slave testbeds
    1321         if master:
    1322             gate_cmd = self.attrs.get('MasterConnectorStartCmd', '/bin/true')
    1323             node_cmd = self.attrs.get('MasterNodeStartCmd', 'bin/true')
    1324         else:
    1325             gate_cmd = self.attrs.get('SlaveConnectorStartCmd', '/bin/true')
    1326             node_cmd = self.attrs.get('SlaveNodeStartCmd', 'bin/true')
    1327 
    13281330        # Weed out the things we aren't going to instantiate: Segments, portal
    13291331        # substrates, and portal interfaces.  (The copy in the for loop allows
     
    13371339            if isinstance(e, topdl.Computer):
    13381340                self.add_kit(e, self.federation_software)
    1339                 if e.get_attribute('portal') and gate_cmd:
     1341                if e.get_attribute('portal') and self.portal_startcommand:
    13401342                    # Add local portal support software
    13411343                    self.add_kit(e, self.portal_software)
    13421344                    # Portals never have a user-specified start command
    1343                     e.set_attribute('startup', gate_cmd)
    1344                 elif node_cmd:
     1345                    e.set_attribute('startup', self.portal_startcommand)
     1346                elif self.node_startcommand:
    13451347                    if e.get_attribute('startup'):
    13461348                        e.set_attribute('startup', "%s \\$USER '%s'" % \
    1347                                 (node_cmd, e.get_attribute('startup')))
     1349                                (self.node_startcommand,
     1350                                    e.get_attribute('startup')))
    13481351                    else:
    1349                         e.set_attribute('startup', node_cmd)
     1352                        e.set_attribute('startup', self.node_startcommand)
    13501353
    13511354                dinf = [i[0] for i in dragon_map.get(e.name, []) ]
     
    13631366        filters = []
    13641367
    1365         # NB: these are extra commands issued for the node, not the startcmds
    1366         if master: cmd = self.attrs.get('MasterConnectorCmd', '')
    1367         else: cmd = self.attrs.get('SlaveConnectorCmd', '')
    1368 
    1369         if self.attrs.has_key('dragon'):
     1368        if self.dragon_endpoint:
    13701369            add_filter = not_dragon(dragon_map)
    13711370            filters.append(dragon_commands(dragon_map))
     
    13731372            add_filter = None
    13741373
    1375         if cmd:
    1376             filters.append(topdl.generate_portal_command_filter(cmd,
    1377                 add_filter=add_filter))
    1378 
    1379         if self.attrs.has_key('connectorImage'):
     1374        if self.portal_command:
     1375            filters.append(topdl.generate_portal_command_filter(
     1376                self.portal_command, add_filter=add_filter))
     1377
     1378        if self.portal_image:
    13801379            filters.append(topdl.generate_portal_image_filter(
    1381                 self.attrs.get('connectorImage')))
    1382 
    1383         if self.attrs.has_key('connectorType'):
     1380                self.portal_image))
     1381
     1382        if self.portal_type:
    13841383            filters.append(topdl.generate_portal_hardware_filter(
    1385                 self.attrs.get('connectorType')))
     1384                self.portal_type))
    13861385
    13871386        # Convert to ns and write it out
Note: See TracChangeset for help on using the changeset viewer.