Example #1
0
def freeSlots(multiplier = 1.0, minusRunning = False, allowedStates = ['Normal'], knownCmsSites = None):
    """
    Get free resources from wmbs.

    Specify multiplier to apply a ratio to the actual numbers.
    minusRunning control if running jobs should be counted
    """
    from WMCore.ResourceControl.ResourceControl import ResourceControl
    rc_sites = ResourceControl().listThresholdsForCreate()
    thresholds = defaultdict(lambda: 0)
    jobCounts = defaultdict(dict)
    for name, site in rc_sites.items():
        if not site.get('cms_name'):
            logging.warning("Not fetching work for %s, cms_name not defined" % name)
            continue
        if knownCmsSites and site['cms_name'] not in knownCmsSites:
            logging.warning("%s doesn't appear to be a known cms site, work may fail to be acquired for it" % site['cms_name'])
        if site['state'] not in allowedStates:
            continue
        slots = site['total_slots']
        thresholds[site['cms_name']] += (slots * multiplier)
        if minusRunning:
            jobCounts[site['cms_name']] = dict((k, jobCounts[site['cms_name']].get(k, 0) + site['pending_jobs'].get(k, 0))
                                               for k in site['pending_jobs'])

    return dict(thresholds), dict(jobCounts)
Example #2
0
def freeSlots(multiplier = 1.0, minusRunning = False, onlyDrain = False, skipDrain = True, knownCmsSites = None):
    """
    Get free resources from wmbs.

    Specify multiplier to apply a ratio to the actual numbers.
    minusRunning control if running jobs should be counted
    """
    from WMCore.ResourceControl.ResourceControl import ResourceControl
    rc_sites = ResourceControl().listThresholdsForCreate()
    sites = defaultdict(lambda: 0)
    for name, site in rc_sites.items():
        if not site.get('cms_name'):
            logging.warning("Not fetching work for %s, cms_name not defined" % name)
            continue
        if knownCmsSites and site['cms_name'] not in knownCmsSites:
            logging.warning("%s doesn't appear to be a known cms site, work may fail to be acquired for it" % site['cms_name'])
        if onlyDrain and not site.get('drain'):
            continue
        if skipDrain and site.get('drain'):
            continue
        slots = site['total_slots']
        if minusRunning:
            slots -= site['running_jobs']
        if slots > 0:
            sites[site['cms_name']] += (slots * multiplier)
    return dict(sites)
Example #3
0
def freeSlots(multiplier=1.0,
              minusRunning=False,
              allowedStates=['Normal'],
              knownCmsSites=None):
    """
    Get free resources from wmbs.

    Specify multiplier to apply a ratio to the actual numbers.
    minusRunning control if running jobs should be counted
    """
    rc_sites = ResourceControl().listThresholdsForCreate()
    thresholds = defaultdict(lambda: 0)
    jobCounts = defaultdict(dict)
    for name, site in rc_sites.items():
        if not site.get('cms_name'):
            logging.warning("Not fetching work for %s, cms_name not defined",
                            name)
            continue
        if knownCmsSites and site['cms_name'] not in knownCmsSites:
            logging.warning(
                "%s doesn't appear to be a known cms site, work may fail to be acquired for it",
                site['cms_name'])
        if site['state'] not in allowedStates:
            continue
        slots = site['total_slots']
        thresholds[site['cms_name']] += (slots * multiplier)
        if minusRunning:
            jobCounts[site['cms_name']] = dict(
                (k, jobCounts[site['cms_name']].get(k, 0) +
                 site['pending_jobs'].get(k, 0)) for k in site['pending_jobs'])

    return dict(thresholds), dict(jobCounts)
Example #4
0
def freeSlots(multiplier = 1.0, minusRunning = False, allowedStates = ['Normal'], knownCmsSites = None):
    """
    Get free resources from wmbs.

    Specify multiplier to apply a ratio to the actual numbers.
    minusRunning control if running jobs should be counted
    """
    from WMCore.ResourceControl.ResourceControl import ResourceControl
    rc_sites = ResourceControl().listThresholdsForCreate()
    sites = defaultdict(lambda: 0)
    for name, site in rc_sites.items():
        if not site.get('cms_name'):
            logging.warning("Not fetching work for %s, cms_name not defined" % name)
            continue
        if knownCmsSites and site['cms_name'] not in knownCmsSites:
            logging.warning("%s doesn't appear to be a known cms site, work may fail to be acquired for it" % site['cms_name'])
        if site['state'] not in allowedStates:
            continue
        slots = site['total_slots']
        if minusRunning:
            slots -= site['pending_jobs']
        sites[site['cms_name']] += (slots * multiplier)

    # At the end delete entries < 1
    # This allows us to combine multiple sites under the same CMS_Name
    # Without going nuts
    for site in sites.keys():
        if sites[site] < 1:
            del sites[site]
    return dict(sites)
Example #5
0
def freeSlots(multiplier = 1.0, minusRunning = False):
    """
    Get free resources from wmbs.

    Specify multiplier to apply a ratio to the actual numbers.
    minusRunning control if running jobs should be counted
    """
    from WMCore.ResourceControl.ResourceControl import ResourceControl
    rc_sites = ResourceControl().listThresholdsForCreate()
    sites = defaultdict(lambda: 0)
    for name, site in rc_sites.items():
        if not site.get('cms_name'):
            logging.warning("Not fetching work for %s, cms_name not defined" % name)
            continue
        slots = site['total_slots']
        if minusRunning:
            slots -= site['running_jobs']
        if slots > 0:
            sites[site['cms_name']] += (slots * multiplier)
    return dict(sites)
Example #6
0
def freeSlots(multiplier=1.0,
              minusRunning=False,
              allowedStates=['Normal'],
              knownCmsSites=None):
    """
    Get free resources from wmbs.

    Specify multiplier to apply a ratio to the actual numbers.
    minusRunning control if running jobs should be counted
    """
    from WMCore.ResourceControl.ResourceControl import ResourceControl
    rc_sites = ResourceControl().listThresholdsForCreate()
    sites = defaultdict(lambda: 0)
    for name, site in rc_sites.items():
        if not site.get('cms_name'):
            logging.warning("Not fetching work for %s, cms_name not defined" %
                            name)
            continue
        if knownCmsSites and site['cms_name'] not in knownCmsSites:
            logging.warning(
                "%s doesn't appear to be a known cms site, work may fail to be acquired for it"
                % site['cms_name'])
        if site['state'] not in allowedStates:
            continue
        slots = site['total_slots']
        if minusRunning:
            slots -= site['pending_jobs']
        sites[site['cms_name']] += (slots * multiplier)

    # At the end delete entries < 1
    # This allows us to combine multiple sites under the same CMS_Name
    # Without going nuts
    for site in sites.keys():
        if sites[site] < 1:
            del sites[site]
    return dict(sites)