Contents
Introduction / API Support
Example Code
Download / Links
Credits / Copyrights / Author
|
Example Code
Below is a PyCss example that retrieves the switch_table information for nominated nodes.
from pycss import *
ALL = 0 # (Default)
FREE = 1
USED = 2
a = swtbl_status( ["nodeA","nodeB"], FREE )
print a
Below is an example of mixing pyloadl and pycss in order to search for possible switch table adapter windows that have not been released when a LoadLeveler completes.
from string import join, split, strip
import os, socket
from pyloadl import *
from pycss import *
from pwd import *
# Global Data Structures
stepstate = [
"I", "P", "ST", "R",
"CP", "XP", "RP",
"VP", "C", "X", "RM",
"V", "CA", "NR", "TX",
"?", "SX", "H", "D",
"NQ", "E", "EP"
]
debug = 0
query = ll_query(JOBS)
if not PyCObjValid(query):
ll_deallocate(query)
exit(-1)
retval = ll_set_request(query, QUERY_ALL, "", ALL_DATA)
job, number, error = ll_get_objs(query, LL_CM, "")
mach_task = {}
if number > 0:
while PyCObjValid(job):
step = ll_get_data(job, LL_JobGetFirstStep)
while PyCObjValid(step):
jid = ll_get_data(step, LL_StepID)
Dispatch = ll_get_data(step, LL_StepDispatchTime)
Mach_cnt = ll_get_data(step, LL_StepMachineCount)
state = ll_get_data(step, LL_StepState)
Status = stepstate[state]
#print "Examining %s %s" % (jid,Status)
if ( Status == "R" ):
# Retrieve Machine and task information for job
machine_obj = ll_get_data(step, LL_StepGetFirstMachine)
if PyCObjValid(machine_obj):
node_obj = ll_get_data(step, LL_StepGetFirstNode)
while PyCObjValid(node_obj):
task_obj = ll_get_data(node_obj, LL_NodeGetFirstTask)
while PyCObjValid(task_obj):
task_inst_obj = ll_get_data(task_obj, LL_TaskGetFirstTaskInstance)
while PyCObjValid(task_inst_obj):
task_id = ll_get_data(task_inst_obj, LL_TaskInstanceTaskID)
task_mach = ll_get_data(task_inst_obj, LL_TaskInstanceMachineName)
task_adpt_obj = ll_get_data(task_inst_obj, LL_TaskInstanceGetFirstAdapterUsage)
if PyCObjValid(task_adpt_obj):
window_id = ll_get_data(task_adpt_obj, LL_AdapterUsageWindow)
#print "Node %s Task ID %s Adapter Window %s" % (task_mach,task_id,window_id)
if window_id != -1:
t = []
if not mach_task.has_key(task_mach):
mach_task[task_mach] = t
t = mach_task[task_mach]
t.append(window_id)
mach_task[task_mach] = t
task_inst_obj = ll_get_data(task_obj, LL_TaskGetNextTaskInstance)
task_obj = ll_get_data(node_obj, LL_NodeGetNextTask)
node_obj = ll_get_data(step, LL_StepGetNextNode)
step = ll_get_data(job, LL_JobGetNextStep)
job = ll_next_obj(query)
ll_free_objs(query)
ll_deallocate(query)
#
# For each machine entry check the windowID list against
# each node for used windows looking for differences
#
# swtbl_status returns (0, [ [adapter, window, node, node, user, 2298, 192570, 4194304, date, '47955'], ...)
queryObject = ll_query(MACHINES)
if not PyCObjValid(queryObject):
print "Query MACHINES: ll_query() returns NULL."
exit(-1)
retval = ll_set_request(queryObject, QUERY_ALL, "", ALL_DATA)
machine, obj_count, err_code = ll_get_objs(queryObject, LL_CM, "")
if err_code != 0:
print "Query MACHINES: ll_get_objs() returns NULL. Error code = %d" % err_code
exit(-1)
while PyCObjValid(machine):
name = ll_get_data(machine, LL_MachineName)
if debug: print "Name: %s" % name
if (name):
data = []
window = []
node_list = [name]
if debug: print "Getting Switch Table for %s" % name
error, adapter_list = swtbl_status(node_list,2)
if not mach_task.has_key(name):
for b in adapter_list:
window.append(str(b[1]))
data.append("%2s %4s %s" % (b[1],b[4],b[8]))
else:
wid = mach_task[name]
for b in adapter_list:
if b[1] not in wid:
window.append(str(b[1]))
data.append("%2s %4s %s" % (b[1],b[4],b[8]))
if window:
window_string = string.join(window, ',')
print "Node %s has windows %s loaded which are not used" % (name, window_string)
for a in data:
print "\t%s" % a
if debug: print "Next Object"
machine = ll_next_obj(queryObject)
ll_free_objs(queryObject)
ll_deallocate(queryObject)
# Sample output
Node t01n04c.localnet has windows 1,2,3,4,5,6,7,8,9,11,12,13,14,15,16 loaded which are not used
1 mark Mon_Oct_10_18:46:51_BST_2005
2 mark Mon_Oct_10_18:46:51_BST_2005
3 mark Tue_Oct_11_17:07:18_BST_2005
4 mark Tue_Oct_11_17:07:18_BST_2005
5 mark Tue_Oct_11_17:07:18_BST_2005
6 mark Tue_Oct_11_17:07:18_BST_2005
7 mark Tue_Oct_11_17:07:18_BST_2005
8 mark Tue_Oct_11_17:07:18_BST_2005
9 mark Tue_Oct_11_17:07:18_BST_2005
11 mark Mon_Oct_10_18:46:51_BST_2005
12 mark Mon_Oct_10_18:46:51_BST_2005
13 mark Mon_Oct_10_18:46:51_BST_2005
14 mark Mon_Oct_10_18:46:51_BST_2005
15 mark Mon_Oct_10_18:46:51_BST_2005
16 mark Mon_Oct_10_18:46:51_BST_2005
Node t02n01c.localnet has windows 5,7 loaded which are not used
5 mary Tue_Oct_11_15:32:39_BST_2005
7 mary Tue_Oct_11_15:52:22_BST_2005
|
|