Example #1
0
def llstate(nodes=None, filter=None):
    """LoadLeveler State of netwerk node"""

    machines = []
    query = ll.ll_query(ll.MACHINES)
    if not ll.PyCObjValid(query):
        log.error('Error during pyloadl.ll_query')
        return machines

    if nodes is not None:
        rc = ll.ll_set_request(query, ll.QUERY_HOST, nodes, ll.ALL_DATA)
    else:
        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 machines

    machine, 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(machine):
            data = functools.partial(ll.ll_get_data, machine)
            startd = data(ll.LL_MachineStartdState)
            if filter is None or startd in filter:
                machines.append({
                    'name': data(ll.LL_MachineName),
                    'startd': startd,
                    'schedd': data(ll.LL_MachineScheddState),
                    'loadavg': data(ll.LL_MachineLoadAverage),
                    'conf_classes': element_count(
                        data(ll.LL_MachineConfiguredClassList)),
                    'avail_classes': element_count(
                        data(ll.LL_MachineAvailableClassList)),
                    'drain_classes': element_count(
                        data(ll.LL_MachineDrainClassList)),
                    'run': data(ll.LL_MachineStartdRunningJobs)
                })

            machine = ll.ll_next_obj(query)

    ll.ll_free_objs(machine)
    ll.ll_deallocate(query)

    return machines
Example #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
Example #3
0
                        adapterusagewindow = pyloadl.ll_get_data(taskadapterusage_element,pyloadl.LL_AdapterUsageWindow)
                        #print "adapterusagewindow (%s)" % adapterusagewindow
                        taskinstanceadapterwindowmap_string = taskinstanceadapterwindowmap_string + "%s@%s" % (adapterusagetag,adapterusagewindow)
                        taskadapterusage_element = pyloadl.ll_get_data(taskinstance_element,pyloadl.LL_TaskInstanceGetNextAdapterUsage)
                        firstadapterusage = 0
                    taskinstance_element = pyloadl.ll_get_data(task_element,pyloadl.LL_TaskGetNextTaskInstance)
                    firsttaskinstanceelement = 0
                task_element = pyloadl.ll_get_data(node_element,pyloadl.LL_NodeGetNextTask)
                firstelement = 0
            new_step['resourcesreq_string'] = resourcesreq_string
            new_step['initiatormap_string'] = initiatormap_string
            new_step['taskinstancemachinemap_string'] = taskinstancemachinemap_string
            new_step['taskinstanceadapterwindowmap_string'] = taskinstanceadapterwindowmap_string
            node_element = pyloadl.ll_get_data(step_element,pyloadl.LL_StepGetNextNode)
        step_element = pyloadl.ll_get_data(job,pyloadl.LL_JobGetNextStep)
    job = pyloadl.ll_next_obj(query_element)
    #print new_step
    step_list.append(new_step)

# iterate through all jobs to get elapsed wallclock time from the startd
#print "getting wallclockused"
for jobindex in range(len(step_list)) :
    if step_list[jobindex]['state'] in [pyloadl.STATE_RUNNING,
                     pyloadl.STATE_STARTING,
                     pyloadl.STATE_PREEMPTED,
                     pyloadl.STATE_PREEMPT_PENDING,
                     pyloadl.STATE_RESUME_PENDING,
                     pyloadl.STATE_REMOVE_PENDING,] :
        query_element = pyloadl.ll_query(pyloadl.JOBS)
        rc = pyloadl.ll_set_request(query_element,pyloadl.QUERY_STEPID,(step_list[jobindex]['stepid'],""),pyloadl.ALL_DATA)
        if rc != 0 :
Example #4
0
    sys.stdout.write("#cat_delim#")
    sys.stdout.write("State:%s#cat_delim#" % (pyloadl.ll_get_data(machine_ptr, pyloadl.LL_MachineStartdState),))
    adapter_ptr = pyloadl.ll_get_data(machine_ptr, pyloadl.LL_MachineGetFirstAdapter)
    adapter_index = 0
    first_element = 1
    while pyloadl.PyCObjValid(adapter_ptr):
        if first_element == 0:
            #    sys.stdout.write("+")
            sys.stdout.write("#cat_delim#")
        adapter_index = adapter_index + 1
        sys.stdout.write(
            "AdapterName%s:%s;" % (adapter_index, pyloadl.ll_get_data(adapter_ptr, pyloadl.LL_AdapterName))
        )
        sys.stdout.write(
            "AdapterTotalWindowCount:%s;" % (pyloadl.ll_get_data(adapter_ptr, pyloadl.LL_AdapterTotalWindowCount),)
        )
        sys.stdout.write(
            "AdapterAvailWindowCount:%s" % (pyloadl.ll_get_data(adapter_ptr, pyloadl.LL_AdapterAvailWindowCount),)
        )
        # Trying to get this info results in
        # ds001:/work/kenneth/test/catalina/pyloadl)./qm_LL.py
        # cat_delim#Machine:ds395#cat_delim#Arch:R6000#cat_delim#OpSys:AIX52#cat_delim#Disk:195576#cat_delim#Pool:1#cat_delim#ConfiguredClasses:Diag+Diag+Diag+Diag+Diag+Diag+Diag+Diag+special+special+special+special+special+special+special+special+special+special+special+special+special+special+special+special+normal+normal+normal+normal+normal+normal+normal+normal+normal+normal+normal+normal+normal+normal+normal+normal+high+high+high+high+high+high+high+high+high+high+high+high+high+high+high+high#cat_delim#AvailableClasses:Diag+Diag+Diag+Diag+Diag+Diag+Diag+Diag+special+special+special+special+special+special+special+special+special+special+special+special+special+special+special+special+normal+normal+normal+normal+normal+normal+normal+normal+normal+normal+normal+normal+normal+normal+normal+normal+high+high+high+high+high+high+high+high+high+high+high+high+high+high+high+high#cat_delim#Feature:batch+high+Power4+CPUs8+MEM32+GPFS-WAN#cat_delim#Max_Starters:16#cat_delim#Memory:30464#cat_delim#Cpus:8#cat_delim#resourcesmap:ConsumableMemory#cat_sep#24576#cat_sep#24576+ConsumableCpus#cat_sep#8#cat_sep#8+RDMA#cat_sep#4#cat_sep#4#cat_delim#State:Idle#cat_delim#AdapterName1:networks;AdapterTotalWindowCount:16;AdapterAvailWindowCount:16IOT/Abort trap(coredump)
        # ds001:/work/kenneth/test/catalina/pyloadl)
        # sys.stdout.write("AdapterCommInterface:%s" % (pyloadl.ll_get_data(adapter_ptr,pyloadl.LL_AdapterCommInterface),))
        adapter_ptr = pyloadl.ll_get_data(machine_ptr, pyloadl.LL_MachineGetNextAdapter)
        first_element = 0
    print ""
    machine_ptr = pyloadl.ll_next_obj(query_element)

print "qm FINISHED"