Changeset e76f38a


Ignore:
Timestamp:
May 11, 2010 12:50:59 PM (14 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
Children:
bf3e812
Parents:
7dbfaed
Message:

Local seer control option

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/emulab_access.py

    r7dbfaed re76f38a  
    8787        self.federation_software = config.get("access", "federation_software")
    8888        self.portal_software = config.get("access", "portal_software")
     89        self.local_seer_software = config.get("access", "local_seer_software")
     90        self.local_seer_image = config.get("access", "local_seer_image")
     91        self.local_seer_start = config.get("access", "local_seer_start")
    8992        self.ssh_privkey_file = config.get("access","ssh_privkey_file")
    9093        self.ssh_pubkey_file = config.get("access","ssh_pubkey_file")
     
    9699        self.federation_software = software_list(self.federation_software)
    97100        self.portal_software = software_list(self.portal_software)
     101        self.local_seer_software = software_list(self.local_seer_software)
    98102
    99103        self.access_type = self.access_type.lower()
     
    126130        # XXX: Configurable
    127131        self.exports = set(('SMB', 'seer', 'tmcd', 'userconfig',
    128             'project_export'))
     132            'project_export', 'local_seer_control'))
    129133        self.imports = set(('SMB', 'seer', 'userconfig'))
     134
     135        if not self.local_seer_image or not self.local_seer_software or \
     136                not self.local_seer_start:
     137            self.exports.discard('local_seer_control')
    130138
    131139        if auth: self.auth = auth
     
    160168            'ReleaseAccess': soap_handler("ReleaseAccess", self.ReleaseAccess),
    161169            'StartSegment': soap_handler("StartSegment", self.StartSegment),
    162             'TerminateSegment': soap_handler("TerminateSegment", self.TerminateSegment),
     170            'TerminateSegment': soap_handler("TerminateSegment",
     171                self.TerminateSegment),
    163172            }
    164173        self.xmlrpc_services =  {\
     
    182191                allocate_project_remote(config, auth)
    183192
     193
    184194        # If the project allocator exports services, put them in this object's
    185195        # maps so that classes that instantiate this can call the services.
    186196        self.soap_services.update(self.allocate_project.soap_services)
    187197        self.xmlrpc_services.update(self.allocate_project.xmlrpc_services)
     198
     199    @staticmethod
     200    def add_kit(e, kit):
     201        """
     202        Add a Software object created from the list of (install, location)
     203        tuples passed as kit  to the software attribute of an object e.  We
     204        do this enough to break out the code, but it's kind of a hack to
     205        avoid changing the old tuple rep.
     206        """
     207
     208        s = [ topdl.Software(install=i, location=l) for i, l in kit]
     209
     210        if isinstance(e.software, list): e.software.extend(s)
     211        else: e.software = s
    188212
    189213
     
    573597                }
    574598
     599    def export_local_seer(self, id, state, project, user):
     600        return {
     601                'id': id,
     602                'name': 'local_seer_control',
     603                'visibility': 'export',
     604                'server': 'http://control:16606',
     605                }
     606
    575607    def export_tmcd(self, id, state, project, user):
    576608        return {
     
    623655                        exp.append(self.export_userconfig(id, state,
    624656                            project, user))
     657                    elif sname == 'local_seer_control':
     658                        exp.append(self.export_local_seer(id, state, project,
     659                            user))
    625660        return (exp, state)
    626661
     
    10671102        seer_out = False
    10681103        client_out = False
     1104        mproj = None
     1105        mexp = None
     1106        control_gw = None
     1107        testbed = ""
     1108        # Create configuration files for the portals
    10691109        for e in [ e for e in topo.elements \
    10701110                if isinstance(e, topdl.Computer) and e.get_attribute('portal')]:
    10711111            myname = e.name[0]
    10721112            type = e.get_attribute('portal_type')
    1073             testbed = e.get_attribute('testbed')
    10741113
    10751114            info = conninfo_to_dict(myname, connInfo)
     
    10831122            ssh_port = info.get('ssh_port', 22)
    10841123
    1085             mexp = info.get('masterexperiment',"")
    1086             mproj, meid = mexp.split("/", 1)
    1087             mdomain = info.get('masterdomain',"")
    1088             muser = info.get('masteruser','root')
    1089             smbshare = info.get('smbshare', 'USERS')
     1124            # Collect this for the client.conf file
     1125            if 'masterexperiment' in info:
     1126                mproj, meid = info['masterexperiment'].split("/", 1)
     1127
     1128            if type in ('control', 'both'):
     1129                testbed = e.get_attribute('testbed')
     1130                control_gw = myname
    10901131
    10911132            active = info.get('active', 'False')
     
    11141155                raise service_error(service_error.internal,
    11151156                        "Can't write protal config %s: %s" % (cfn, e))
    1116            
    1117             if not client_out and type in ('control', 'both'):
    1118                 try:
    1119                     f = open("%s/client.conf" % tmpdir, "w")
    1120                     print >>f, "ControlGateway: %s.%s.%s%s" % \
    1121                         (myname.lower(), leid.lower(), lproj.lower(),
    1122                                 ldomain.lower())
    1123                     for s in services:
    1124                         if s.get('name',"") in self.imports and \
    1125                                 s.get('visibility','') == 'import':
    1126                             client_service_out[s['name']](f, s)
    1127                     # Seer uses this.
    1128                     print >>f, "ExperimentID: %s/%s" % (mproj, meid)
    1129                     # Better way...
    1130                     if testbed == master:
    1131                         print >>f, "SEERBase: True"
    1132                     f.close()
    1133                 except IOError, e:
    1134                     raise service_error(service_error.internal,
    1135                             "Cannot write client.conf: %s" %s)
    1136                 client_out = True
    1137 
     1157
     1158        # Done with portals, write the client config file.
     1159        try:
     1160            f = open("%s/client.conf" % tmpdir, "w")
     1161            if control_gw:
     1162                print >>f, "ControlGateway: %s.%s.%s%s" % \
     1163                    (myname.lower(), leid.lower(), lproj.lower(),
     1164                            ldomain.lower())
     1165            for s in services:
     1166                if s.get('name',"") in self.imports and \
     1167                        s.get('visibility','') == 'import':
     1168                    client_service_out[s['name']](f, s)
     1169            # Seer uses this.
     1170            if mproj and meid:
     1171                print >>f, "ExperimentID: %s/%s" % (mproj, meid)
     1172            # Better way...
     1173            if testbed == master:
     1174                print >>f, "SEERBase: True"
     1175            f.close()
     1176        except IOError, e:
     1177            raise service_error(service_error.internal,
     1178                    "Cannot write client.conf: %s" %s)
    11381179
    11391180    def generate_ns2(self, topo, expfn, softdir, master, connInfo):
     
    11841225                return e.name[0] not in self.nodes
    11851226
    1186         def add_kit(e, kit):
    1187             """
    1188             Add a Software object created from the list of (install, location)
    1189             tuples passed as kit  to the software attribute of an object e.  We
    1190             do this enough to break out the code, but it's kind of a hack to
    1191             avoid changing the old tuple rep.
    1192             """
    1193 
    1194             s = [ topdl.Software(install=i, location=l) for i, l in kit]
    1195 
    1196             if isinstance(e.software, list): e.software.extend(s)
    1197             else: e.software = s
    1198 
    11991227
    12001228        t = topo.clone()
     
    12431271                t.elements.remove(e)
    12441272            if isinstance(e, topdl.Computer):
    1245                 add_kit(e, self.federation_software)
     1273                self.add_kit(e, self.federation_software)
    12461274                if e.get_attribute('portal') and gate_cmd:
    12471275                    # Add local portal support software
    1248                     add_kit(e, self.portal_software)
     1276                    self.add_kit(e, self.portal_software)
    12491277                    # Portals never have a user-specified start command
    12501278                    e.set_attribute('startup', gate_cmd)
     
    14971525            # data.
    14981526            for s in services:
    1499                 if s.get("name", "") == 'userconfig' \
    1500                         and s.get('visibility',"") == 'import':
    1501 
     1527                s_name = s.get('name', '')
     1528                s_vis = s.get('visibility','')
     1529                if s_name  == 'userconfig' and s_vis == 'import':
    15021530                    # Collect ther server and certificate info.
    15031531                    u = s.get('server', None)
     
    15351563                                "No certificate for retreiving userconfig")
    15361564                    break
    1537 
    1538 
     1565                if s_name  == 'local_seer_control'  and s_vis == 'export':
     1566                    # Copy local seer control node software to the tempdir
     1567                    for l, f in self.local_seer_software:
     1568                        base = os.path.basename(f)
     1569                        copy_file(f, "%s/%s" % (softdir, base))
     1570
     1571                    # Add a control node to the local topology
     1572                    c_node = topdl.Computer(
     1573                            name='control',
     1574                            attribute=[
     1575                                { 'attribute': 'image',
     1576                                    'value': self.local_seer_image },
     1577                                { 'attribute': 'startup',
     1578                                    'value': self.local_seer_start },
     1579                                ]
     1580                            )
     1581                    self.add_kit(c_node, self.local_seer_software)
     1582                    topo.elements.append(c_node)
    15391583
    15401584            proj = None
Note: See TracChangeset for help on using the changeset viewer.