def cobalt_query(state): cqm = ComponentProxy('queue-manager', defer=True) scheduler = ComponentProxy('scheduler', defer=True) if state not in ('running', 'queued', 'reservation'): return None # Templates for queries to coblat query_job = dict.fromkeys(job_query_fields, '*') query_res = dict.fromkeys(reservation_query_fields, '*') if state == 'reservation': return scheduler.get_reservations([query_res]) if state == 'running' or state == 'starting': query_job['state'] = 'running' query_job['location'] = '*' if state == 'queued': query_job['state'] = 'queued' query_job['score'] = '*' return cqm.get_jobs([query_job])
# sys.exit(1) for part in parts: system.set_cleaning(part, None, whoami) print "Initiating cleanup on block %s" % part sys.exit(0) if opts.list_blocks: # need to cascade up busy and non-functional flags # print "buildRackTopology sees : " + repr(parts) # # partinfo = Cobalt.Util.buildRackTopology(parts) try: scheduler = ComponentProxy("scheduler", defer=False) if sys_type == 'bgq': reservations = scheduler.get_reservations([{'queue':"*", 'partitions':"*", 'active':True, 'block_passthrough':'*'}]) elif sys_type == 'bgp': reservations = scheduler.get_reservations([{'queue':"*", 'partitions':"*", 'active':True}]) except ComponentLookupError: print "Failed to connect to scheduler; no reservation data available" reservations = [] expanded_parts = {} for res in reservations: for res_part in res['partitions'].split(":"): for p in parts: if p['name'] == res_part: if expanded_parts.has_key(res['queue']): if sys_type == 'bgq': expanded_parts[res['queue']].update(p['relatives'])
print "Failed to connect to scheduler" raise SystemExit, 1 cluster = False try: if "cluster" in ComponentProxy("system", defer=False).get_implementation(): cluster = True except ComponentLookupError: print "Failed to connect to system component" raise SystemExit, 1 reservations = scheduler.get_reservations([{ 'name': '*', 'users': '*', 'start': '*', 'duration': '*', 'partitions': '*', 'cycle': '*', 'queue': '*' }]) output = [] if '-l' in sys.argv: verbose = True header = [('Reservation', 'Queue', 'User', 'Start', 'Duration', 'End Time', 'Cycle Time', 'Partitions')] else: verbose = False header = [('Reservation', 'Queue', 'User', 'Start', 'Duration', 'Partitions')] for res in reservations:
except ComponentLookupError: print "Failed to connect to scheduler" raise SystemExit, 1 spec = [{'tag':'partition', 'name':'*', 'queue':'*', 'state':'*', 'size':'*', 'functional':'*', 'scheduled':'*', 'children':'*', 'backfill_time':"*", 'draining':"*"}] try: parts = system.get_partitions(spec) except xmlrpclib.Fault, flt: if flt.faultCode == NotSupportedError.fault_code: print "incompatible with cluster support: try nodelist" raise SystemExit, 1 else: raise reservations = scheduler.get_reservations([{'queue':"*", 'partitions':"*", 'active':True}]) expanded_parts = {} for res in reservations: for res_part in res['partitions'].split(":"): for p in parts: if p['name'] == res_part: if expanded_parts.has_key(res['queue']): expanded_parts[res['queue']].update(p['children']) else: expanded_parts[res['queue']] = sets.Set( p['children'] ) expanded_parts[res['queue']].add(p['name']) for res in reservations: for p in parts:
raise SystemExit, 1 if not args: print "releaseres [--version] -p <partition> name" raise SystemExit, 1 try: scheduler = ComponentProxy("scheduler", defer=False) except ComponentLookupError: print "Failed to connect to scheduler" raise SystemExit, 1 # Check if reservation exists spec = [{'name': arg} for arg in args] try: result = scheduler.get_reservations(spec) except xmlrpclib.Fault, flt: if flt.faultCode == 1: print "Error communicating with queue manager" sys.exit(1) if len(result) and len(result) != len(args): print "Reservation subset matched" elif not result: print "No Reservations matched" raise SystemExit, 1 try: result = scheduler.del_reservations(spec, pwd.getpwuid(os.getuid())[0]) except xmlrpclib.Fault, flt: if flt.faultCode == 1:
sys.exit(1) opt, args = p.parse_args() reservation_names = args try: scheduler = ComponentProxy("scheduler", defer=False) except ComponentLookupError: print "Failed to connect to scheduler" sys.exit(1) # Check if reservation exists spec = [{'name': rname, 'users':"*", 'start':'*', 'cycle':'*', 'duration':'*'} for rname in reservation_names] try: result = scheduler.get_reservations(spec) except: print "Error communicating with scheduler" sys.exit(1) if len(result) and len(result) != len(args): print "Reservation subset matched" elif not result: print "No Reservations matched" sys.exit(1) user_name = pwd.getpwuid(os.getuid())[0] for spec in result: if not spec['users'] or user_name not in spec['users'].split(":"):
if cycle_time: try: minutes = Cobalt.Util.get_time(cycle_time) except Cobalt.Exceptions.TimeFormatError, e: print "invalid cycle time specification: %s" % e.args[0] sys.exit(1) cycle_time = 60 * minutes # modify the existing reservation instead of creating a new one if '-m' in sys.argv[1:]: if '-n' not in sys.argv[1:]: print "-m must by called with -n <reservation name>" raise SystemExit rname = [arg for (opt, arg) in opts if opt == '-n'][0] query = [{'name':rname, 'start':'*', 'cycle':'*', 'duration':'*'}] res_list = scheduler.get_reservations(query) if not res_list: print "cannot find reservation named '%s'" % rname raise SystemExit, 1 updates = {} if '-D' in sys.argv: res = res_list[0] if start or cycle_time: print "Cannot use -D while changing start or cycle time" raise SystemExit, 1 if not res['cycle']: print "Cannot use -D on a non-cyclic reservation" raise SystemExit, 1 start = res['start'] duration = res['duration'] cycle = float(res['cycle'])
if cycle_time: try: minutes = Cobalt.Util.get_time(cycle_time) except Cobalt.Exceptions.TimeFormatError, e: print "invalid cycle time specification: %s" % e.args[0] sys.exit(1) cycle_time = 60 * minutes # modify the existing reservation instead of creating a new one if '-m' in sys.argv[1:]: if '-n' not in sys.argv[1:]: print "-m must by called with -n <reservation name>" raise SystemExit rname = [arg for (opt, arg) in opts if opt == '-n'][0] query = [{'name': rname, 'start': '*', 'cycle': '*', 'duration': '*'}] res_list = scheduler.get_reservations(query) if not res_list: print "cannot find reservation named '%s'" % rname raise SystemExit, 1 updates = {} if '-D' in sys.argv: res = res_list[0] if start or cycle_time: print "Cannot use -D while changing start or cycle time" raise SystemExit, 1 if not res['cycle']: print "Cannot use -D on a non-cyclic reservation" raise SystemExit, 1 start = res['start'] duration = res['duration'] cycle = float(res['cycle'])
Cobalt.Logging.setup_logging('showres', to_syslog=False, level=20) try: scheduler = ComponentProxy("scheduler", defer=False) except ComponentLookupError: print "Failed to connect to scheduler" raise SystemExit, 1 cluster = False try: if "cluster" in ComponentProxy("system", defer=False).get_implementation(): cluster = True except ComponentLookupError: print "Failed to connect to system component" raise SystemExit, 1 reservations = scheduler.get_reservations([{'name':'*', 'users':'*', 'start':'*', 'duration':'*', 'partitions':'*', 'cycle': '*', 'queue': '*', 'res_id': '*', 'cycle_id': '*', 'project':'*'}]) output = [] verbose = False really_verbose = False header = [('Reservation', 'Queue', 'User', 'Start', 'Duration', 'Partitions')] if '-l' in sys.argv: verbose = True header = [('Reservation', 'Queue', 'User', 'Start', 'Duration', 'End Time', 'Cycle Time', 'Partitions')] if '-x' in sys.argv: really_verbose = True header = [('Reservation', 'Queue', 'User', 'Start', 'Duration',
sys.exit(0) if opts.list_blocks: # need to cascade up busy and non-functional flags # print "buildRackTopology sees : " + repr(parts) # # partinfo = Cobalt.Util.buildRackTopology(parts) try: scheduler = ComponentProxy("scheduler", defer=False) if sys_type == 'bgq': reservations = scheduler.get_reservations([{ 'queue': "*", 'partitions': "*", 'active': True, 'block_passthrough': '*' }]) elif sys_type == 'bgp': reservations = scheduler.get_reservations([{ 'queue': "*", 'partitions': "*", 'active': True }]) except ComponentLookupError: print "Failed to connect to scheduler; no reservation data available" reservations = [] expanded_parts = {}
Cobalt.Logging.setup_logging('showres', to_syslog=False, level=20) try: scheduler = ComponentProxy("scheduler", defer=False) except ComponentLookupError: print "Failed to connect to scheduler" raise SystemExit, 1 cluster = False try: if "cluster" in ComponentProxy("system", defer=False).get_implementation(): cluster = True except ComponentLookupError: print "Failed to connect to system component" raise SystemExit, 1 reservations = scheduler.get_reservations([{'name':'*', 'users':'*', 'start':'*', 'duration':'*', 'partitions':'*', 'cycle': '*', 'queue': '*', 'res_id': '*', 'cycle_id': '*', 'project':'*', 'block_passthrough':'*'}]) output = [] verbose = False really_verbose = False header = [('Reservation', 'Queue', 'User', 'Start', 'Duration', 'Passthrough', 'Partitions')] if '-l' in sys.argv: verbose = True header = [('Reservation', 'Queue', 'User', 'Start', 'Duration', 'End Time', 'Cycle Time', 'Passthrough', 'Partitions',)] if '-x' in sys.argv: really_verbose = True header = [('Reservation', 'Queue', 'User', 'Start', 'Duration',