예제 #1
0
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
0
파일: pod.py 프로젝트: CMGS/eru-core
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
0
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
0
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
0
파일: resource.py 프로젝트: CMGS/eru-core
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
0
파일: pod.py 프로젝트: timfeirg/eru-core
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