本文整理汇总了Python中Cobalt.Proxy.ComponentProxy.get_reservations方法的典型用法代码示例。如果您正苦于以下问题:Python ComponentProxy.get_reservations方法的具体用法?Python ComponentProxy.get_reservations怎么用?Python ComponentProxy.get_reservations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cobalt.Proxy.ComponentProxy
的用法示例。
在下文中一共展示了ComponentProxy.get_reservations方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cobalt_query
# 需要导入模块: from Cobalt.Proxy import ComponentProxy [as 别名]
# 或者: from Cobalt.Proxy.ComponentProxy import get_reservations [as 别名]
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])
示例2: repr
# 需要导入模块: from Cobalt.Proxy import ComponentProxy [as 别名]
# 或者: from Cobalt.Proxy.ComponentProxy import get_reservations [as 别名]
# 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'])
示例3:
# 需要导入模块: from Cobalt.Proxy import ComponentProxy [as 别名]
# 或者: from Cobalt.Proxy.ComponentProxy import get_reservations [as 别名]
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:
示例4: ComponentProxy
# 需要导入模块: from Cobalt.Proxy import ComponentProxy [as 别名]
# 或者: from Cobalt.Proxy.ComponentProxy import get_reservations [as 别名]
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(":"):
示例5: for
# 需要导入模块: from Cobalt.Proxy import ComponentProxy [as 别名]
# 或者: from Cobalt.Proxy.ComponentProxy import get_reservations [as 别名]
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'])
示例6: ComponentProxy
# 需要导入模块: from Cobalt.Proxy import ComponentProxy [as 别名]
# 或者: from Cobalt.Proxy.ComponentProxy import get_reservations [as 别名]
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',