コード例 #1
0
ファイル: qj_LL.py プロジェクト: kenneth59715/catalina
              'Preempt_Pending', 'Resume_Pending']

step_list = []

query_element = pyloadl.ll_query(pyloadl.JOBS)
rc = pyloadl.ll_set_request(query_element,pyloadl.QUERY_ALL,"",pyloadl.ALL_DATA)
if rc != 0 :
    print "rc (%s)" % rc
    raise Failure
job, job_count, rc = pyloadl.ll_get_objs(query_element,pyloadl.LL_CM,"")
if rc != 0 :
    print "rc (%s)" % rc
    raise Failure

while pyloadl.PyCObjValid(job) :
    credential_element = pyloadl.ll_get_data(job,pyloadl.LL_JobCredential)
    username_string = pyloadl.ll_get_data(credential_element,pyloadl.LL_CredentialUserName)
    #print username_string
    group_string = pyloadl.ll_get_data(credential_element,pyloadl.LL_CredentialGroupName)
    #print group_string
    submittime = pyloadl.ll_get_data(job,pyloadl.LL_JobSubmitTime)
    step_element = pyloadl.ll_get_data(job,pyloadl.LL_JobGetFirstStep)
    while pyloadl.PyCObjValid(step_element) :
        new_step = {}
        new_step['username'] = username_string
        new_step['group'] = group_string
        account = pyloadl.ll_get_data(step_element,pyloadl.LL_StepAccountNumber)
        new_step['account'] = account
        new_step['submittime'] = submittime
        stepstate = pyloadl.ll_get_data(step_element,pyloadl.LL_StepState)
        new_step['state'] = stepstate
コード例 #2
0
def llq(state_filter=None, user_filter=None):
    """LoadLeveler Job queue"""
    jobs = []
    query = ll.ll_query(ll.JOBS)
    if not ll.PyCObjValid(query):
        log.error('Error during pyloadl.ll_query')
        return jobs

    rc = ll.ll_set_request(query, ll.QUERY_ALL, '', ll.ALL_DATA)

    if rc != 0:
        log.error('Error during pyloadl.ll_set_request: %s', rc)
        ll.ll_deallocate(query)
        return jobs

    job, count, err = ll.ll_get_objs(query, ll.LL_CM, '')
    if err != 0:
        log.error('Error during pyloadl.ll_get_objs: %s', err)
    elif count > 0:
        while ll.PyCObjValid(job):
            name = ll.ll_get_data(job, ll.LL_JobName)
            cred = ll.ll_get_data(job, ll.LL_JobCredential)
            if ll.PyCObjValid(cred):
                user = ll.ll_get_data(cred, ll.LL_CredentialUserName)
                group = ll.ll_get_data(cred, ll.LL_CredentialGroupName)
                if user_filter is not None and user not in user_filter:
                    job = ll.ll_next_obj(query)
                    continue
            else:
                log.error('Error during pyloadl.ll_get_data for credentials')

            step = ll.ll_get_data(job, ll.LL_JobGetFirstStep)
            steps = []
            while ll.PyCObjValid(step):
                data = functools.partial(ll.ll_get_data, step)
                state = data(ll.LL_StepState)
                if state_filter is None or state in state_filter:
                    s = {
                        'id': data(ll.LL_StepID),
                        'state': state,
                        'pri': data(ll.LL_StepPriority),
                        'class': data(ll.LL_StepJobClass),
                        'parallel':
                            data(ll.LL_StepParallelMode) == ll.PARALLEL_TYPE,
                        'total_tasks': data(ll.LL_StepTotalTasksRequested),
                        'tasks_per_node':
                            data(ll.LL_StepTasksPerNodeRequested),
                        'blocking': data(ll.LL_StepBlocking),
                        'node_count': data(ll.LL_StepTotalNodesRequested),
                        'shared':
                            data(ll.LL_StepNodeUsage) == ll.SHARED,
                        'task_geometry': data(ll.LL_StepTaskGeometry),
                    }

                    # post process node_count and task_geometry
                    if s['node_count']:
                        nodes = ast.literal_eval(s['node_count'])
                        if isinstance(nodes, int):
                            s['node_count'] = [nodes] * 2
                        elif len(nodes) == 1:
                            s['node_count'] = nodes * 2
                        else:
                            log.error('Error during parsing of nodes_count')
                    else:
                        s['node_count'] = (1, 1)

                    if s['task_geometry']:
                        s['task_geometry'] = ast.literal_eval(
                            s['task_geometry'].translate(
                                None, '{} ').replace(')', '),')
                        )

                    # add to steps list
                    steps.append(s)

                step = ll.ll_get_data(job, ll.LL_JobGetNextStep)

            if steps:
                jobs.append({'name': name, 'user': user, 'group': group,
                             'steps': steps})
            job = ll.ll_next_obj(query)

    ll.ll_free_objs(job)
    ll.ll_deallocate(query)

    return jobs
コード例 #3
0
ファイル: qm_LL.py プロジェクト: kenneth59715/catalina
    return list_string


query_element = pyloadl.ll_query(pyloadl.MACHINES)
rc = pyloadl.ll_set_request(query_element, pyloadl.QUERY_ALL, "", pyloadl.ALL_DATA)
if rc != 0:
    print "rc (%s)" % rc
    raise Failure
machine_ptr, machine_count, rc = pyloadl.ll_get_objs(query_element, pyloadl.LL_CM, "")
if rc != 0:
    print "rc (%s)" % rc
    raise Failure

while pyloadl.PyCObjValid(machine_ptr):
    sys.stdout.write("#cat_delim#")
    sys.stdout.write("Machine:%s#cat_delim#" % pyloadl.ll_get_data(machine_ptr, pyloadl.LL_MachineName))
    sys.stdout.write("Arch:%s#cat_delim#" % pyloadl.ll_get_data(machine_ptr, pyloadl.LL_MachineArchitecture))
    sys.stdout.write("OpSys:%s#cat_delim#" % (pyloadl.ll_get_data(machine_ptr, pyloadl.LL_MachineOperatingSystem),))
    sys.stdout.write("Disk:%s#cat_delim#" % pyloadl.ll_get_data(machine_ptr, pyloadl.LL_MachineDisk))
    # PoolListSize = pyloadl.ll_get_data(machine_ptr,pyloadl.LL_MachinePoolList)
    item_list = pyloadl.ll_get_data(machine_ptr, pyloadl.LL_MachinePoolList)
    # pool_string = ""
    # first_pool = 1
    # for poolnumber in pool_list :
    #    if first_pool != 1 :
    #        pool_string = pool_string + '+'
    #    pool_string = pool_string + "%s" % (poolnumber,)
    #    first_pool = 0
    # sys.stdout.write("Pool:%s#cat_delim#" % (pool_string,))
    sys.stdout.write("Pool:%s#cat_delim#" % (get_list_string(item_list),))
    item_list = pyloadl.ll_get_data(machine_ptr, pyloadl.LL_MachineConfiguredClassList)