Ignore:
Timestamp:
Mar 9, 2010 1:08:05 AM (14 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
Children:
4e9719b
Parents:
c2c153b
Message:

SEER support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/emulab_access.py

    rc2c153b r9b3627e  
    5656        Initializer.  Pulls parameters out of the ConfigParser's access section.
    5757        """
     58
     59        def software_list(v):
     60            l = [ ]
     61            if v:
     62                ps = v.split(" ")
     63                while len(ps):
     64                    loc, file = ps[0:2]
     65                    del ps[0:2]
     66                    l.append((loc, file))
     67            return l
     68
    5869
    5970        # Make sure that the configuration is in place
     
    7384        self.userconfcmd = config.get("access","userconfcmd")
    7485        self.userconfurl = config.get("access","userconfurl")
     86        self.federation_software = config.get("access", "federation_software")
     87        self.portal_software = config.get("access", "portal_software")
    7588        self.ssh_privkey_file = config.get("access","ssh_privkey_file")
    7689        self.ssh_pubkey_file = config.get("access","ssh_pubkey_file")
     
    7992        self.cleanup = not config.getboolean("access", "leave_tmpfiles")
    8093        self.access_type = config.get("access", "type")
     94   
     95        self.federation_software = software_list(self.federation_software)
     96        self.portal_software = software_list(self.portal_software)
    8197
    8298        self.access_type = self.access_type.lower()
     
    968984                'userconfig': client_null,
    969985            }
     986
     987        def server_port(f, s):
     988            p = urlparse(s.get('server', 'http://localhost'))
     989            print >>f, 'port: remote:%s:%s:%s' % (p.port, p.hostname, p.port)
     990
     991        def server_null(f,s): pass
     992
     993        def server_seer(f, s):
     994            print >>f, 'seer: true'
     995
     996        server_service_out = {
     997                'SMB': server_port,
     998                'tmcd': server_port,
     999                'userconfig': server_null,
     1000                'seer': server_seer,
     1001            }
    9701002        # XXX: end un hardcode this
    9711003
     
    10061038                        for s in [s for s in services \
    10071039                                if s.get('name', "") in self.imports]:
    1008                             p = urlparse(s.get('server', 'http://localhost'))
    1009                             print >>f, 'port: remote:%s:%s:%s' % \
    1010                                     (p.port, p.hostname, p.port)
     1040                            server_service_out[s['name']](f, s)
    10111041
    10121042                if tunnelconfig:
     
    10261056           
    10271057            # XXX: This little seer config file needs to go away.
    1028             if not seer_out:
    1029                 try:
    1030                     seerfn = "%s/seer.conf" % tmpdir
    1031                     f = open(seerfn, "w")
    1032                     if not master:
    1033                         print >>f, "ControlNode: control.%s.%s%s" % \
    1034                             (meid.lower(), mproj.lower(), mdomain)
    1035                     print >>f, "ExperimentID: %s" % mexp
    1036                     f.close()
    1037                 except IOError, e:
    1038                     raise service_error(service_error.internal,
    1039                             "Can't write seer.conf: %s" %e)
    1040                 seer_out = True
     1058            #if not seer_out:
     1059                #try:
     1060                    #seerfn = "%s/seer.conf" % tmpdir
     1061                    #f = open(seerfn, "w")
     1062                    #if not master:
     1063                        #print >>f, "ControlNode: control.%s.%s%s" % \
     1064                            #(meid.lower(), mproj.lower(), mdomain)
     1065                    #print >>f, "ExperimentID: %s" % mexp
     1066                    #f.close()
     1067                #except IOError, e:
     1068                    #raise service_error(service_error.internal,
     1069                            #"Can't write seer.conf: %s" %e)
     1070                #seer_out = True
    10411071
    10421072            if not client_out and type in ('control', 'both'):
     
    10501080                                s.get('visibility','') == 'import':
    10511081                            client_service_out[s['name']](f, s)
    1052                     # Does seer need this? (evidently so)
     1082                    # Seer uses this?
    10531083                    print >>f, "ExperimentID: %s/%s" % (mproj, meid)
    10541084                    f.close()
     
    11051135                return e.name[0] not in self.nodes
    11061136
     1137        def add_kit(e, kit):
     1138            """
     1139            Add a Software object created from the list of (install, location)
     1140            tuples passed as kit  to the software attribute of an object e.  We
     1141            do this enough to break out the code, but it's kind of a hack to
     1142            avoid changing the old tuple rep.
     1143            """
     1144
     1145            s = [ topdl.Software(install=i, location=l) for i, l in kit]
     1146
     1147            if isinstance(e.software, list): e.software.extend(s)
     1148            else: e.software = s
     1149
     1150
    11071151        t = topo.clone()
    11081152
     
    11491193            if isinstance(e, topdl.Segment):
    11501194                t.elements.remove(e)
    1151             # Fix software paths
    1152             for s in getattr(e, 'software', []):
    1153                 s.location = re.sub("^.*/", softdir, s.location)
    11541195            if isinstance(e, topdl.Computer):
     1196                add_kit(e, self.federation_software)
    11551197                if e.get_attribute('portal') and gate_cmd:
     1198                    # Add local portal support software
     1199                    add_kit(e, self.portal_software)
    11561200                    # Portals never have a user-specified start command
    11571201                    e.set_attribute('startup', gate_cmd)
     
    11671211                e.interface = [i for i in e.interface \
    11681212                        if not i.get_attribute('portal') or i.name in dinf ]
     1213            # Fix software paths
     1214            for s in getattr(e, 'software', []):
     1215                s.location = re.sub("^.*/", softdir, s.location)
    11691216
    11701217        t.substrates = [ s.clone() for s in t.substrates ]
     
    13681415                get_url(s, certfile, softdir)
    13691416
     1417            # Copy local portal node software to the tempdir
     1418            for l, f in self.portal_software:
     1419                base = os.path.basename(f)
     1420                copy_file(f, "%s/%s" % (softdir, base))
     1421
    13701422            for a in attrs:
    13711423                if a['attribute'] in configs:
Note: See TracChangeset for help on using the changeset viewer.