本文整理汇总了Python中foam.geni.db.GeniDB.updateSliverExpiration方法的典型用法代码示例。如果您正苦于以下问题:Python GeniDB.updateSliverExpiration方法的具体用法?Python GeniDB.updateSliverExpiration怎么用?Python GeniDB.updateSliverExpiration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类foam.geni.db.GeniDB
的用法示例。
在下文中一共展示了GeniDB.updateSliverExpiration方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: renewSliver
# 需要导入模块: from foam.geni.db import GeniDB [as 别名]
# 或者: from foam.geni.db.GeniDB import updateSliverExpiration [as 别名]
def renewSliver (slice_urn, creds, exptime):
from foam.geni.db import GeniDB
sliver_urn = GeniDB.getSliverURN(slice_urn)
reqexp = dateutil.parser.parse(str(exptime))
reqexp = _asUTC(reqexp)
max_expiration = _asUTC(datetime.datetime.utcnow()) + ConfigDB.getConfigItemByKey("geni.max-lease").getValue()
if reqexp > max_expiration:
raise BadSliverExpiration(
"The requested expiration date (%s) is past the allowed maximum expiration (%s)." %
(reqexp, max_expiration))
for cred in creds:
credexp = _asUTC(cred.expiration)
if reqexp > credexp:
continue
else:
GeniDB.updateSliverExpiration(sliver_urn, reqexp)
sobj = GeniDB.getSliverObj(sliver_urn)
sobj.resetExpireEmail()
sobj.store()
return sliver_urn
raise BadSliverExpiration(
"No credential found whose expiration is greater than or equal to the requested sliver expiration (%s)" %
(reqexp))
示例2: adminSetSliverExpiration
# 需要导入模块: from foam.geni.db import GeniDB [as 别名]
# 或者: from foam.geni.db.GeniDB import updateSliverExpiration [as 别名]
def adminSetSliverExpiration (self):
if not request.json:
return
try:
objs = self.validate(request.json, [("datetime", types.DateTime), ("urn", types.SliverURN)])
GeniDB.updateSliverExpiration(objs["urn"], objs["datetime"])
return jsonify({"status" : "success"})
except JSONValidationError, e:
jd = e.__json__()
return jsonify(jd, code = 1, msg = jd["exception"])