本文整理汇总了Python中bkr.server.model.Job.cancel_jobs_by_user方法的典型用法代码示例。如果您正苦于以下问题:Python Job.cancel_jobs_by_user方法的具体用法?Python Job.cancel_jobs_by_user怎么用?Python Job.cancel_jobs_by_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bkr.server.model.Job
的用法示例。
在下文中一共展示了Job.cancel_jobs_by_user方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _remove
# 需要导入模块: from bkr.server.model import Job [as 别名]
# 或者: from bkr.server.model.Job import cancel_jobs_by_user [as 别名]
def _remove(self, user, method, **kw):
if user == identity.current.user:
raise BX(_('You cannot remove yourself'))
# cancel all running and queued jobs
Job.cancel_jobs_by_user(user, 'User %s removed' % user.user_name)
# Return all systems in use by this user
for system in System.query.filter(System.user==user):
reservation = system.open_reservation
system.unreserve(reservation=reservation, service=method, user=user)
# Return all loaned systems in use by this user
for system in System.query.filter(System.loaned==user):
system.record_activity(user=identity.current.user, service=method,
action=u'Changed', field=u'Loaned To',
old=u'%s' % system.loaned, new=u'None')
system.loaned = None
# Change the owner to the caller
for system in System.query.filter(System.owner==user):
system.owner = identity.current.user
system.record_activity(user=identity.current.user, service=method,
action=u'Changed', field=u'Owner',
old=u'%s' % user, new=u'%s' % identity.current.user)
# Finally remove the user
user.removed=datetime.utcnow()
示例2: _remove
# 需要导入模块: from bkr.server.model import Job [as 别名]
# 或者: from bkr.server.model.Job import cancel_jobs_by_user [as 别名]
def _remove(self, user, method, **kw):
if user == identity.current.user:
raise BX(_('You cannot remove yourself'))
# cancel all running and queued jobs
Job.cancel_jobs_by_user(user, 'User %s removed' % user.user_name)
# Return all systems in use by this user
for system in System.query.filter(System.user==user):
msg = ''
try:
reservation = system.open_reservation
system.unreserve(reservation=reservation,
service=method, user=user)
except BX, error_msg:
msg = 'Error: %s Action: %s' % (error_msg,system.release_action)
system.activity.append(SystemActivity(identity.current.user, method, '%s' % system.release_action, 'Return', '', msg))
system.activity.append(SystemActivity(identity.current.user, method, 'Returned', 'User', '%s' % user, ''))
示例3: _disable
# 需要导入模块: from bkr.server.model import Job [as 别名]
# 或者: from bkr.server.model.Job import cancel_jobs_by_user [as 别名]
def _disable(self, user, method,
msg='Your account has been temporarily disabled'):
# cancel all queued and running jobs
Job.cancel_jobs_by_user(user, msg)