本文整理汇总了Python中Cobalt.Proxy.ComponentProxy.set_queues方法的典型用法代码示例。如果您正苦于以下问题:Python ComponentProxy.set_queues方法的具体用法?Python ComponentProxy.set_queues怎么用?Python ComponentProxy.set_queues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cobalt.Proxy.ComponentProxy
的用法示例。
在下文中一共展示了ComponentProxy.set_queues方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update
# 需要导入模块: from Cobalt.Proxy import ComponentProxy [as 别名]
# 或者: from Cobalt.Proxy.ComponentProxy import set_queues [as 别名]
def update (self, spec):
if spec.has_key("users"):
qm = ComponentProxy("queue-manager")
try:
qm.set_queues([{'name':self.queue,}], {'users':spec['users']}, "bgsched")
except ComponentLookupError:
logger.error("unable to contact queue manager when updating reservation users")
raise
# try the above first -- if we can't contact the queue-manager, don't update the users
if spec.has_key('cycle') and not self.cycle:
#we have just turned this into a cyclic reservation and need a cycle_id.
spec['cycle_id'] = self.cycle_id_gen.get()
#get the user name of whoever issued the command
user_name = None
if spec.has_key('__cmd_user'):
user_name = spec['__cmd_user']
del spec['__cmd_user']
#if we're defering, pull out the 'defer' entry and send a cobalt db message.
#there really isn't a corresponding field to update
deferred = False
if spec.has_key('defer'):
logger.info("Res %s/%s: Deferring cyclic reservation: %s",
self.res_id, self.cycle_id, self.name)
dbwriter.log_to_db(user_name, "deferred", "reservation", self)
del spec['defer']
deferred = True
Data.update(self, spec)
if not deferred or not self.running:
#we only want this if we aren't defering. If we are, the cycle will
#take care of the new data object creation.
dbwriter.log_to_db(user_name, "modifying", "reservation", self)
示例2: update
# 需要导入模块: from Cobalt.Proxy import ComponentProxy [as 别名]
# 或者: from Cobalt.Proxy.ComponentProxy import set_queues [as 别名]
def update (self, spec):
if spec.has_key("users"):
qm = ComponentProxy(self.COMP_QUEUE_MANAGER)
try:
qm.set_queues([{'name':self.queue,}], {'users':spec['users']}, "bgsched")
except ComponentLookupError:
logger.error("unable to contact queue manager when updating reservation users")
raise
# try the above first -- if we can't contact the queue-manager, don't update the users
Data.update(self, spec)
示例3: q_del
# 需要导入模块: from Cobalt.Proxy import ComponentProxy [as 别名]
# 或者: from Cobalt.Proxy.ComponentProxy import set_queues [as 别名]
def q_del (self, *args, **kwargs):
reservations = Cobalt.Data.DataDict.q_del(self, *args, **kwargs)
qm = ComponentProxy('queue-manager')
queues = [spec['name'] for spec in qm.get_queues([{'name':"*"}])]
spec = [{'name': reservation.queue} for reservation in reservations \
if reservation.createdQueue and reservation.queue in queues and \
not self.q_get([{'queue':reservation.queue}])]
try:
qm.set_queues(spec, {'state':"dead"}, "bgsched")
except Exception, e:
logger.error("problem disabling reservation queue (%s)" % e)
示例4: q_del
# 需要导入模块: from Cobalt.Proxy import ComponentProxy [as 别名]
# 或者: from Cobalt.Proxy.ComponentProxy import set_queues [as 别名]
def q_del (self, *args, **kwargs):
'''Delete a reservation from tracking.
Side Effects: Removes a queue from tracking.
Logs that the reservation has terminated.
Emits a terminated database record
Attempts to mark the queue dead in the queue-manager.
Marks the reservation as dying
'''
reservations = Cobalt.Data.DataDict.q_del(self, *args, **kwargs)
qm = ComponentProxy('queue-manager')
queues = [spec['name'] for spec in qm.get_queues([{'name':"*"}])]
spec = [{'name': reservation.queue} for reservation in reservations \
if reservation.createdQueue and reservation.queue in queues \
and not self.q_get([{'queue':reservation.queue}])]
try:
qm.set_queues(spec, {'state':"dead"}, "bgsched")
except Exception, err:
logger.error("problem disabling reservation queue (%s)" % err)
示例5: int
# 需要导入模块: from Cobalt.Proxy import ComponentProxy [as 别名]
# 或者: from Cobalt.Proxy.ComponentProxy import set_queues [as 别名]
try:
if i != '*':
dummy = int(i)
except:
print prop + ' value is not a number'
raise SystemExit, 1
if val.count(':') == 2:
t = val.split(':')
val = str(int(t[0])*60 + int(t[1]))
elif val.count(':') == 0:
pass
else:
print 'Time for ' + prop + ' is not valid, must be in hh:mm:ss or mm format'
updates.update({prop.lower():val})
try:
response = cqm.set_queues(spec, updates, whoami)
except xmlrpclib.Fault, flt:
if flt.faultCode == QueueError.fault_code:
print flt.faultString
sys.exit(1)
elif opts['unsetq']:
updates = {}
for prop in opts['unsetq'].split(' '):
updates[prop.lower()] = None
response = cqm.set_queues(spec, updates, whoami)
elif opts['stopq']:
response = cqm.set_queues(spec, {'state':'stopped'}, whoami)
elif opts['startq']:
response = cqm.set_queues(spec, {'state':'running'}, whoami)
elif opts['drainq']: