To create a Catalina client, write the appropriate Python script: This one prints name, account and QOS for every job: ---------------------------------------------------------------- #!/usr/local/apps/python/bin/python import sys sys.path.append('/paci/loadl/catalina/install') import Catalina # Open database for read access: jobs_db_handle = Catalina.open_ro_db(Catalina.JOBS_DB, 'read') # Retrieve a dictionary of jobs: jobs_dict = jobs_db_handle[0] # For every job, print its name, account and QOS: for job in jobs_dict.values() : print "name: %s, account: %s, QOS: %s" % \ (job['name'], job['account'], job['QOS']) # Close the database: Catalina.close_ro_db(jobs_db_handle) ---------------------------------------------------------------- This one opens the database in write mode, to allow changing a reservation. This example takes a res id and a comma-delimited list of users and sets the job_restriction for that reservation to allow a job by any of the specified users. ---------------------------------------------------------------- #!/usr/local/apps/python/bin/python # Import the sys module import sys # Add the path to the Catalina module sys.path.append('/paci/loadl/catalina/install') # Import the Catalina module import Catalina # Import some useful utility modules import getopt import re # set the list of accepted command line options options = ['res_id=', 'users='] # Retrieve command line args args = sys.argv[1:] # Parse the long options optlist, lineargs = getopt.getopt(args, '', options) argdict = {} for pair in optlist : argdict[pair[0]] = pair[1] # Exit, unless both --res_id and --users were provided if not argdict.has_key('--res_id') or not argdict.has_key('--users') : print "both --res_id= and --users= required!" sys.exit(1) # Change the users string into a string that forms a Python list of users # "['user1','user2','user3',...]" users_string = argdict['--users'] if users_string != '' : users_string = "['" + users_string + "']" users_string = re.sub(",", "','", users_string) else : users_string = '[]' # Set res_id res_id = argdict['--res_id'] # Form the Python job restriction code fragment restricting the reservation # to jobs with a user in the list job_restriction = \ "if input_tuple[0]['user'] in " + users_string + " : result = 0" # Get the reservations database name from the Catalina module RESERVATIONS_DB = Catalina.RESERVATIONS_DB # Open the reservations database in 'write' mode, get the handle reservations_db_handle = Catalina.open_db(RESERVATIONS_DB,'write') # With exception handling, retrieve the specified job try : temp_res = Catalina.get_object(res_id, reservations_db_handle) except 'KeyNotFound' : print "Reservation (%s) not found in Catalina DB" % res_id Catalina.close_db(reservations_db_handle) sys.exit(1) # Use the Catalina update_object_attribute method to change an object Catalina.update_object_attribute( 'job_restriction', job_restriction, temp_res, reservations_db_handle ) # Close the database. Changes don't take effect until the DB is closed Catalina.close_db(reservations_db_handle) ---------------------------------------------------------------- Databases are listed in catalina.quickstart. The three main ones are: RESERVATIONS_DB RESOURCE_DB JOBS_DB Catalina methods for manipulating databases and objects: open_db(db_name, db_mode) This opens the specified db, pausing the scheduler iteration. db_name should be the string representing the database. db_mode can be 'write' or 'read'. The database handle is returned close_db (db_handle) closes the database open_ro_db (db_name, db_mode) This opens the readonly cache file for the db. The scheduler is not paused. close_ro_db (db_handle) closes the database update_object_attribute(name, value, object, db_handle) after an object is retrieved from the database, it can be modified with this method. name is the name of the attribute to change value is the value to assign to the attribute object is the object to be modified db_handle is the database containing the object delete_object(name, db_handle) deletes object from database name is name of the object db_handle is the database containing the object