예제 #1
0
def advertizeWork(client_name,req_name,glidein_name,min_glideins,glidein_params={}):
    # get a 9 digit number that will stay 9 digit for the next 25 years
    short_time = time.time()-1.05e9
    tmpnam="/tmp/aw_%li_%li"%(short_time,os.getpid())
    fd=file(tmpnam,"w")
    try:
        try:
            fd.write('MyType = "%s"\n'%client_id)
            fd.write('GlideMyType = "%s"\n'%client_id)
            fd.write('Name = "%s@%s"\n'%(req_name,client_name))
            fd.write('ClientName = "%s"\n'%client_name)
            fd.write('ReqName = "%s"\n'%req_name)
            fd.write('ReqGlidein = "%s"\n'%glidein_name)
            fd.write('ReqIdleGlideins=%i\n'%min_glideins)

            # write out both the attributes, prefixes and counts
            prefix="GlideinParam"
            data=glidein_params
            for attr in data.keys():
                    el=data[attr]
                    if type(el)==type(1):
                        # don't quote ints
                        fd.write('%s%s = %s\n'%(prefix,attr,el))
                    else:
                        fd.write('%s%s = "%s"\n'%(prefix,attr,el))
        finally:
            fd.close()

        condorExe.exe_cmd("../sbin/condor_advertise","UPDATE_MASTER_AD %s"%tmpnam)
    finally:
        os.remove(tmpnam)
예제 #2
0
 def test_exe_cmd(self):
     """
     exe_cmd is a wrapper for iexe_cmd.  See test_iexe_cmd docstring for
     full details.
     """
     # Execution should proceed normally and exit with no exceptions.
     try:
         for script in self.normal_exit_scripts:
             output = exe_cmd(script, self.dummy_args)
     except Exception, e:
         self.fail("Exception Occurred: %s" % str(e))
예제 #3
0
    def test_exe_cmd(self):
        """
        exe_cmd is a wrapper for iexe_cmd.  See test_iexe_cmd docstring for
        full details.
        """
        # Execution should proceed normally and exit with no exceptions.
        try:
            for script in self.normal_exit_scripts:
                output = exe_cmd(script, self.dummy_args)
        except Exception as e:
            self.fail("Exception Occurred: %s" % str(e))

        # Execution should exit with an exception.  If no exception, then fail
        for script in self.abnormal_exit_scripts:
            self.failUnlessRaises(ExeError, exe_cmd, script, self.dummy_args)
예제 #4
0
    def test_exe_cmd(self):
        """
        exe_cmd is a wrapper for iexe_cmd.  See test_iexe_cmd docstring for
        full details.
        """
        # Execution should proceed normally and exit with no exceptions.
        try:
            for script in self.normal_exit_scripts:
                output = exe_cmd(script, self.dummy_args)
        except Exception as e:
            self.fail("Exception Occurred: %s" % str(e))

        # Execution should exit with an exception.  If no exception, then fail
        for script in self.abnormal_exit_scripts:
            self.failUnlessRaises(ExeError, exe_cmd, script, self.dummy_args)
예제 #5
0
def create_client_condor_config(config_fname, mapfile_fname, collector_nodes, classad_proxy):
    attrs = condorExe.exe_cmd('condor_config_val','-dump')
    def_attrs = filter_unwanted_config_attrs(attrs)

    fd=open(config_fname,"w")
    try:
        fd.write("############################################\n")
        fd.write("#\n")
        fd.write("# Condor config file used by the VO Frontend\n")
        fd.write("#\n")
        fd.write("# This file is generated at each reconfig\n")
        fd.write("# Do not change by hand!\n")
        fd.write("#\n")
        fd.write("############################################\n\n")

        fd.write("###########################\n")
        fd.write("# Base config values\n")
        fd.write("# obtained from\n")
        fd.write("#  condor_config_val -dump\n")
        fd.write("# at config time.\n")
        fd.write("###########################\n\n")

        for attr in def_attrs:
            fd.writelines("%s\n" % attr)

        fd.write("\n##################################\n")
        fd.write("# Add Frontend specific attributes\n")
        fd.write("##################################\n")

        fd.write("\n###########################\n")
        fd.write("# Pool collector(s)\n")
        fd.write("###########################\n")
        fd.write("COLLECTOR_HOST = %s\n"%string.join(collector_nodes,","))

        fd.write("\n###########################\n")
        fd.write("# Authentication settings\n")
        fd.write("############################\n")

        fd.write("\n# Force GSI authentication\n")
        fd.write("SEC_DEFAULT_AUTHENTICATION_METHODS = GSI\n")
        fd.write("SEC_DEFAULT_AUTHENTICATION = REQUIRED\n")

        fd.write("\n#################################\n")
        fd.write("# Where to find ID->uid mappings\n")
        fd.write("# (also disable any GRIDMAP)\n")
        fd.write("#################################\n")
        fd.write("# This is a fake file, redefine at runtime\n")
        fd.write("CERTIFICATE_MAPFILE=%s\n"%mapfile_fname)

        fd.write("\n# Specify that we trust anyone but not anonymous\n")
        fd.write("# I.e. we only talk to servers that have \n")
        fd.write("#  a DN mapped in our mapfile\n")
        for context in condorSecurity.CONDOR_CONTEXT_LIST:
            fd.write("DENY_%s = anonymous@*\n"%context)
        fd.write("\n")
        for context in condorSecurity.CONDOR_CONTEXT_LIST:
            fd.write("ALLOW_%s = *@*\n"%context)
        fd.write("\n")
        fd.write("\n# Unset all the tool specifics\n")

        fd.write("\n# Force integrity\n")
        fd.write("SEC_DEFAULT_INTEGRITY = REQUIRED\n")

        fd.write("\n######################################################\n")
        fd.write("## If someone tried to use this config to start a master\n")
        fd.write("## make sure it is not used to run any daemons\n")
        fd.write("######################################################\n")
        fd.write("DAEMON_LIST=MASTER\n")
        fd.write("DAEMON_SHUTDOWN=True\n")


        fd.write("\n######################################################\n")
        fd.write("## If condor is allowed to use VOMS attributes, it will\n")
        fd.write("## map COLLECTOR DN to anonymous. Just disable it.\n")
        fd.write("######################################################\n")
        fd.write("USE_VOMS_ATTRIBUTES = False\n")
        
        fd.write("\n######################################################\n")
        fd.write("## Add GSI DAEMON PROXY based on the frontend config and \n")
        fd.write("## not what is in the condor configs from install \n")
        fd.write("########################################################\n")
        fd.write("GSI_DAEMON_PROXY = %s\n" % classad_proxy)

    finally:
        fd.close()
        
    return
예제 #6
0
def create_client_condor_config(config_fname, mapfile_fname, collector_nodes, classad_proxy):
    attrs = condorExe.exe_cmd('condor_config_val', '-dump')
    def_attrs = filter_unwanted_config_attrs(attrs)

    fd=open(config_fname, "w")
    try:
        fd.write("############################################\n")
        fd.write("#\n")
        fd.write("# Condor config file used by the VO Frontend\n")
        fd.write("#\n")
        fd.write("# This file is generated at each reconfig\n")
        fd.write("# Do not change by hand!\n")
        fd.write("#\n")
        fd.write("############################################\n\n")

        fd.write("###########################\n")
        fd.write("# Base config values\n")
        fd.write("# obtained from\n")
        fd.write("#  condor_config_val -dump\n")
        fd.write("# at config time.\n")
        fd.write("###########################\n\n")

        for attr in def_attrs:
            fd.writelines("%s\n" % attr)

        fd.write("\n##################################\n")
        fd.write("# Add Frontend specific attributes\n")
        fd.write("##################################\n")

        fd.write("\n###########################\n")
        fd.write("# Pool collector(s)\n")
        fd.write("###########################\n")
        fd.write("COLLECTOR_HOST = %s\n"%string.join(collector_nodes, ","))

        fd.write("\n###########################\n")
        fd.write("# Authentication settings\n")
        fd.write("############################\n")

        fd.write("\n# Force GSI authentication\n")
        fd.write("SEC_DEFAULT_AUTHENTICATION_METHODS = GSI\n")
        fd.write("SEC_DEFAULT_AUTHENTICATION = REQUIRED\n")

        fd.write("\n#################################\n")
        fd.write("# Where to find ID->uid mappings\n")
        fd.write("# (also disable any GRIDMAP)\n")
        fd.write("#################################\n")
        fd.write("# This is a fake file, redefine at runtime\n")
        fd.write("CERTIFICATE_MAPFILE=%s\n"%mapfile_fname)

        fd.write("\n# Specify that we trust anyone but not anonymous\n")
        fd.write("# I.e. we only talk to servers that have \n")
        fd.write("#  a DN mapped in our mapfile\n")
        for context in condorSecurity.CONDOR_CONTEXT_LIST:
            fd.write("DENY_%s = anonymous@*\n"%context)
        fd.write("\n")
        for context in condorSecurity.CONDOR_CONTEXT_LIST:
            fd.write("ALLOW_%s = *@*\n"%context)
        fd.write("\n")
        fd.write("\n# Unset all the tool specifics\n")

        fd.write("\n# Force integrity\n")
        fd.write("SEC_DEFAULT_INTEGRITY = REQUIRED\n")

        fd.write("\n######################################################\n")
        fd.write("## If someone tried to use this config to start a master\n")
        fd.write("## make sure it is not used to run any daemons\n")
        fd.write("######################################################\n")
        fd.write("DAEMON_LIST=MASTER\n")
        fd.write("DAEMON_SHUTDOWN=True\n")


        fd.write("\n######################################################\n")
        fd.write("## If condor is allowed to use VOMS attributes, it will\n")
        fd.write("## map COLLECTOR DN to anonymous. Just disable it.\n")
        fd.write("######################################################\n")
        fd.write("USE_VOMS_ATTRIBUTES = False\n")
        
        fd.write("\n######################################################\n")
        fd.write("## Newer versions of Condor will try to enforce hostname\n")
        fd.write("## mapping in the server DN. This does not work for\n")
        fd.write("## pilot DNs. We can safely disable this check since\n")
        fd.write("## we explicitly whitelist all DNs.\n")
        fd.write("######################################################\n")
        fd.write("GSI_SKIP_HOST_CHECK = True\n")
        
        fd.write("\n######################################################\n")
        fd.write("## Add GSI DAEMON PROXY based on the frontend config and \n")
        fd.write("## not what is in the condor configs from install \n")
        fd.write("########################################################\n")
        fd.write("GSI_DAEMON_PROXY = %s\n" % classad_proxy)

    finally:
        fd.close()
        
    return
예제 #7
0
            pool_status.load(self.glidekeeper_constraint,
                             [('GLIDEIN_COLLECTOR_NAME', 's'),
                              ('GLIDEIN_MASTER_NAME', 's'),
                              ('MyAddress', 's')])
            pool_data = pool_status.fetchStored()
        except:
            self.errors.append((time.time(), "condor_status failed"))

        for k in pool_data.keys():
            el = pool_data[k]
            ilog('Now killing pool with data: (%s -> %s)' %
                 (dbgp(k), dbgp(el)))
            try:

                condorExe.exe_cmd("../sbin/condor_off",
                                  "-addr %s" % (el['MyAddress']),
                                  env={"X509_USER_PROXY": self.proxy_fname})
            except RuntimeError, e:
                self.errors.append((time.time(), "condor_off failed: %s" % e))
            except:
                tb = traceback.format_exception(sys.exc_info()[0],
                                                sys.exc_info()[1],
                                                sys.exc_info()[2])
                self.errors.append(
                    (time.time(),
                     "condor_off failed: %s" % string.join(tb, '')))

        self.need_cleanup = False
        ilog('Finished cleanup.')

    def go_request_glideins(self):
예제 #8
0
        
        # Stop all the glideins I can see
        ilog('Getting glidein pool status data.')
        try:
          pool_status=condorMonitor.CondorStatus()
          pool_status.load(self.glidekeeper_constraint,[('GLIDEIN_COLLECTOR_NAME','s'),('GLIDEIN_MASTER_NAME','s')])
          pool_data=pool_status.fetchStored()
        except:
          self.errors.append((time.time(),"condor_status failed"))

        for k in pool_data.keys():
            el=pool_data[k]
            ilog('Now killing pool with data: (%s -> %s)'%(dbgp(k), dbgp(el)))
            try:
                condorExe.exe_cmd("../sbin/condor_off","-master -pool %s %s"%(el['GLIDEIN_COLLECTOR_NAME'],el['GLIDEIN_MASTER_NAME']))
            except RuntimeError, e:
                self.errors.append((time.time(),"condor_off failed: %s"%e))
            except:
                tb = traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],
                                                sys.exc_info()[2])
                self.errors.append((time.time(),"condor_off failed: %s"%string.join(tb,'')))

        self.need_cleanup = False
        ilog('Finished cleanup.')
    
    def go_request_glideins(self):
        ilog('Entered go_request_glideins.')
        from glideinwms.frontend import glideinFrontendInterface
        from glideinwms.lib import condorMonitor, condorExe
        from glideinwms.frontend.glideinFrontendPlugins import proxy_plugins, createCredentialList