def main(): """ The main module """ # Move to the working directory try: if "GLIDEIN_FACTORY_DIR" in os.environ: os.chdir(os.environ["GLIDEIN_FACTORY_DIR"]) else: os.chdir("/var/lib/gwms-factory/work-dir/") except OSError as ose: logging.error("Cannot chdir to /var/lib/gwms-factory/work-dir/: %s", ose) return 1 # Parse command line options options = parse_opts() entry_name = options.entry_name wms_collector = options.wms_collector # Set some variables needed later on params = {} status_sf = {} nr_glideins = 1 idle_lifetime = 3600 * 24 factory_config = FactoryConfig() glidein_descript = gfc.GlideinDescript() frontend_descript = gfc.FrontendDescript() collector = htcondor.Collector(wms_collector) req_name = get_reqname(collector, options.fe_name, entry_name) logging.debug("Using reques name %s" % req_name) factory_config.submit_dir = '/var/lib/gwms-factory/work-dir' constraint_gc = '(MyType=="glideclient") && (Name=="%s")' % (req_name) ads_gc = collector.query(htcondor.AdTypes.Any, constraint_gc) if not ads_gc: logging.error("Cannot find glideclient classad using constraint %s", constraint_gc) return 1 else: ad_gc = ads_gc[0] log_debug(ad_gc, header='glideclient classad') # Load factory config and get some info that will go in the pilot classad glidein_descript.load_pub_key() sym_key_obj, frontend_sec_name = validate_frontend( ad_gc, frontend_descript, glidein_descript.data['PubKeyObj']) security_class = sym_key_obj.decrypt_hex( ad_gc['GlideinEncParamSecurityClass']) # GlideinSecurityClass proxyid = sym_key_obj.decrypt_hex(ad_gc['GlideinEncParamSubmitProxy']) user_name = frontend_descript.get_username(frontend_sec_name, security_class) # Prepare some values that ends up in the Arguments classad # of the pilot, i.e., the ClientWeb instance client_web_url = ad_gc['WebURL'] # -clientweb client_signtype = ad_gc['WebSignType'] # -signtype client_descript = ad_gc['WebDescriptFile'] # -clientdescript client_sign = ad_gc['WebDescriptSign'] # -clientsign client_group = ad_gc['GroupName'] # -clientgroup client_group_web_url = ad_gc['WebGroupURL'] # -clientwebgroup # -clientdescriptgroup client_group_descript = ad_gc['WebGroupDescriptFile'] client_group_sign = ad_gc['WebGroupDescriptSign'] # -clientsigngroup client_web = ClientWeb(client_web_url, client_signtype, client_descript, client_sign, client_group, client_group_web_url, client_group_descript, client_group_sign) # Create the submit_credentials object credentials = SubmitCredentials(user_name, security_class) credentials.id = proxyid credentials.cred_dir = '/var/lib/gwms-factory/client-proxies/user_%s/glidein_gfactory_instance' % user_name credfname = '%s_%s' % (ad_gc['ClientName'], proxyid) if not credentials.add_security_credential('SubmitProxy', credfname): fname = os.path.join(credentials.cred_dir, 'credential_%s' % credfname) logging.info(( "Problems getting credential file using credentials.add_security_credential." " Check file %s permissions"), fname) # Set the arguments # I was using escapeParam for GLIDECLIENT_ReqNode and GLIDECLIENT_Collector but turned out it's not necessary params['CONDOR_VERSION'] = 'default' params['CONDOR_OS'] = 'default' params['CONDOR_ARCH'] = 'default' params['GLIDECLIENT_ReqNode'] = ad_gc[ 'GlideinParamGLIDECLIENT_ReqNode'] params['GLIDECLIENT_Rank'] = ad_gc.get('GlideinParamGLIDECLIENT_Rank', "1") params['GLIDEIN_Collector'] = ad_gc['GlideinParamGLIDEIN_Collector'] params['USE_MATCH_AUTH'] = ad_gc['GlideinParamUSE_MATCH_AUTH'] params['Report_Failed'] = 'NEVER' # Now that we have everything submit the pilot! logging.getLogger().setLevel(logging.DEBUG) submitGlideins(entry_name, "test.test", int(nr_glideins), idle_lifetime, "test:test", credentials, client_web, params, status_sf, log=logging.getLogger(), factoryConfig=factory_config) return 0
client_web_url = cp_get(cp, "client_web", "clientweb", "", throw_exception=True) client_signtype = cp_get(cp, "client_web", "clientsigntype", "", throw_exception=True) client_descript = cp_get(cp, "client_web", "clientdescript", "", throw_exception=True) client_sign = cp_get(cp, "client_web", "clientsign", "", throw_exception=True) client_group = cp_get(cp, "client_web", "clientgroup", "", throw_exception=True) client_group_web_url = cp_get(cp, "client_web", "clientwebgroup", "", throw_exception=True) client_group_descript = cp_get(cp, "client_web", "clientdescriptgroup", "", throw_exception=True) client_group_sign = cp_get(cp, "client_web", "clientsigngroup", "", throw_exception=True) client_web = ClientWeb(client_web_url, client_signtype, client_descript, client_sign, client_group, client_group_web_url, client_group_descript, client_group_sign) # create the submit_credentials object credentials = SubmitCredentials(user_name, security_class) for option in cp.options("security_credentials"): credentials.add_security_credential(option, cp_get(cp, "security_credentials", option, "", throw_exception=True)) for option in cp.options("identity_credentials"): credentials.add_identity_credential(option, cp_get(cp, "identity_credentials", option, "", throw_exception=True)) # call the submit submitGlideins(entry_name, client_name, nr_glideins, frontend_name, credentials, client_web, params) except IniError, ie: print sys.stderr, "ini file error make this message better" except Exception, ex: print sys.stderr, "general error make this message better" if __name__ == "__main__": sys.exit(main())