本文整理汇总了Python中eru.models.Pod.get方法的典型用法代码示例。如果您正苦于以下问题:Python Pod.get方法的具体用法?Python Pod.get怎么用?Python Pod.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eru.models.Pod
的用法示例。
在下文中一共展示了Pod.get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_pod
# 需要导入模块: from eru.models import Pod [as 别名]
# 或者: from eru.models.Pod import get [as 别名]
def get_pod(id_or_name):
if id_or_name.isdigit():
pod = Pod.get(int(id_or_name))
else:
pod = Pod.get_by_name(id_or_name)
if not pod:
raise EruAbortException(consts.HTTP_NOT_FOUND, 'Pod %s not found' % id_or_name)
return pod
示例2: _get_pod
# 需要导入模块: from eru.models import Pod [as 别名]
# 或者: from eru.models.Pod import get [as 别名]
def _get_pod(id_or_name):
if id_or_name.isdigit():
pod = Pod.get(int(id_or_name))
else:
pod = Pod.get_by_name(id_or_name)
if not pod:
abort(404, 'Pod %s not found' % id_or_name)
return pod
示例3: list_pod_hosts
# 需要导入模块: from eru.models import Pod [as 别名]
# 或者: from eru.models.Pod import get [as 别名]
def list_pod_hosts(id_or_name):
if id_or_name.isdigit():
pod = Pod.get(int(id_or_name))
else:
pod = Pod.get_by_name(id_or_name)
if not pod:
raise EruAbortException(consts.HTTP_NOT_FOUND, 'Pod %s not found' % id_or_name)
show_all = request.args.get('all', type=bool, default=False)
return pod.list_hosts(g.start, g.limit, show_all=show_all)
示例4: get_pod_resource
# 需要导入模块: from eru.models import Pod [as 别名]
# 或者: from eru.models.Pod import get [as 别名]
def get_pod_resource(pod_id):
pod = Pod.get(pod_id)
if not pod:
raise EruAbortException(code.HTTP_NOT_FOUND, 'Pod %s not found' % pod_id)
core_count = sum(len(h.cores.all()) for h in pod.hosts.all())
free_cores = [c for h in pod.hosts.all() for c in h.get_free_cores()]
return {
'core_count': core_count,
'free_cores': [c.label for c in free_cores],
}
示例5: get_pod_resource
# 需要导入模块: from eru.models import Pod [as 别名]
# 或者: from eru.models.Pod import get [as 别名]
def get_pod_resource(pod_id):
pod = Pod.get(pod_id)
if not pod:
abort(404, 'Pod %s not found' % pod_id)
core_count = sum(len(h.cores) for h in pod.hosts.all())
free_excluded_cores = [c for h in pod.hosts.all() for c in h.get_free_cores()[0]]
free_shared_cores = [c for h in pod.hosts.all() for c in h.get_free_cores()[1]]
return {
'core_count': core_count,
'free_excluded_cores': [c.label for c in free_excluded_cores],
'free_shared_cores': [c.label for c in free_shared_cores],
}
示例6: _get_pod
# 需要导入模块: from eru.models import Pod [as 别名]
# 或者: from eru.models.Pod import get [as 别名]
def _get_pod(id_or_name):
pod = Pod.get(id_or_name) or Pod.get_by_name(id_or_name)
if not pod:
abort(404, 'Pod %s not found' % id_or_name)
return pod