def infosys_based(entry_name,opt_dict,infosys_types):
    # find out which entries I need to look at
    # gather downtime fds for them
    config_els={}
    if entry_name=='factory':
        return 0 # nothing to do... the whole factory cannot be controlled by infosys
    elif entry_name in ('entries','all'):
        # all==entries in this case, since there is nothing to do for the factory
        glideinDescript=glideFactoryConfig.GlideinDescript()
        entries=string.split(glideinDescript.data['Entries'],',')
        for entry in entries:
            config_els[entry]={}
    else:
        config_el={}
        config_els[entry_name]={}

    # load the infosys info
    import cgWDictFile
    import cgWConsts

    for entry in config_els.keys():
        infosys_fd=cgWDictFile.InfoSysDictFile(cgWConsts.get_entry_submit_dir('.',entry),cgWConsts.INFOSYS_FILE)
        infosys_fd.load()

        if len(infosys_fd.keys)==0:
            # entry not associated with any infosys, cannot be managed, ignore
            del config_els[entry]
            continue

        compatible_infosys=False
        for k in infosys_fd.keys:
            infosys_type=infosys_fd[k][0]
            if infosys_type in infosys_types:
                compatible_infosys=True
                break
        if not compatible_infosys:
            # entry not associated with a compatible infosys, cannot be managed, ignore
            del config_els[entry]
            continue
            
        config_els[entry]['infosys_fd']=infosys_fd

    if len(config_els.keys())==0:
        return 0 # nothing to do
    # all the remaining entries are handled by one of the supported infosys

    # summarize
    infosys_data={}
    for entry in config_els.keys():
        infosys_fd=config_els[entry]['infosys_fd']
        for k in infosys_fd.keys:
            infosys_type=infosys_fd[k][0]
            server=infosys_fd[k][1]
            ref=infosys_fd[k][2]
            if not infosys_data.has_key(infosys_type):
                infosys_data[infosys_type]={}
            infosys_data_type=infosys_data[infosys_type]
            if not infosys_data_type.has_key(server):
                infosys_data_type[server]=[]
            infosys_data_type[server].append({'ref':ref,'entry_name':entry})

    # get production entries
    production_entries=[]
    for infosys_type in infosys_data.keys():
        if infosys_type in infosys_types:
            infosys_data_type=infosys_data[infosys_type]
            for server in infosys_data_type.keys():
                infosys_data_server=infosys_data_type[server]
                if infosys_type=="RESS":
                    production_entries+=get_production_ress_entries(server,infosys_data_server)
                elif infosys_type=="BDII":
                    production_entries+=get_production_bdii_entries(server,infosys_data_server)
                else:
                    raise RuntimeError, "Unknown infosys type '%s'"%infosys_type # should never get here

    # Use the info to put the 
    entry_keys=config_els.keys()
    entry_keys.sort()
    for entry in entry_keys:
        if entry in production_entries:
            print "%s up"%entry
            up(entry,['up'])
        else:
            print "%s down"%entry
            down(entry,['down']) 
    
    return 0
Example #2
0
 def get_sub_work_dir(self,base_dir):
     return cgWConsts.get_entry_submit_dir(base_dir,self.sub_name)