当前位置: 首页>>代码示例>>Python>>正文


Python Group.get_by_name方法代码示例

本文整理汇总了Python中eru.models.Group.get_by_name方法的典型用法代码示例。如果您正苦于以下问题:Python Group.get_by_name方法的具体用法?Python Group.get_by_name怎么用?Python Group.get_by_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eru.models.Group的用法示例。


在下文中一共展示了Group.get_by_name方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: list_group_pod

# 需要导入模块: from eru.models import Group [as 别名]
# 或者: from eru.models.Group import get_by_name [as 别名]
def list_group_pod(id_or_name):
    if id_or_name.isdigit():
        group = Group.get(int(id_or_name))
    else:
        group = Group.get_by_name(id_or_name)
    if not group:
        abort(404, 'Group %s not found' % id_or_name)
    return group.list_pods(g.start, g.limit)
开发者ID:CMGS,项目名称:eru-core,代码行数:10,代码来源:sys.py

示例2: list_group_pod

# 需要导入模块: from eru.models import Group [as 别名]
# 或者: from eru.models.Group import get_by_name [as 别名]
def list_group_pod(id_or_name):
    if id_or_name.isdigit():
        group = Group.get(int(id_or_name))
    else:
        group = Group.get_by_name(id_or_name)
    if not group:
        raise EruAbortException(consts.HTTP_NOT_FOUND, 'Group %s not found' % id_or_name)
    return group.list_pods(g.start, g.limit)
开发者ID:BlueKarl,项目名称:eru-core,代码行数:10,代码来源:sys.py

示例3: assign_pod_to_group

# 需要导入模块: from eru.models import Group [as 别名]
# 或者: from eru.models.Group import get_by_name [as 别名]
def assign_pod_to_group(pod_name):
    data = request.get_json()

    group = Group.get_by_name(data['group_name'])
    pod = Pod.get_by_name(pod_name)
    if not group or not pod:
        raise EruAbortException(code.HTTP_BAD_REQUEST)

    if not pod.assigned_to_group(group):
        raise EruAbortException(code.HTTP_BAD_REQUEST)
    return {'r':0, 'msg': code.OK}
开发者ID:lcsandy,项目名称:eru-core,代码行数:13,代码来源:sys.py

示例4: group_max_containers

# 需要导入模块: from eru.models import Group [as 别名]
# 或者: from eru.models.Group import get_by_name [as 别名]
def group_max_containers(group_name):
    pod_name = request.args.get('pod_name', type=str, default='')
    cores_per_container = request.args.get('ncore', type=int, default=1)

    group = Group.get_by_name(group_name)
    if not group:
        raise EruAbortException(code.HTTP_BAD_REQUEST)
    pod = Pod.get_by_name(pod_name)
    if not pod:
        raise EruAbortException(code.HTTP_BAD_REQUEST)

    return {'r':0, 'msg': code.OK, 'data': group.get_max_containers(pod, cores_per_container)}
开发者ID:marswon,项目名称:eru-core,代码行数:14,代码来源:sys.py

示例5: assign_pod_to_group

# 需要导入模块: from eru.models import Group [as 别名]
# 或者: from eru.models.Group import get_by_name [as 别名]
def assign_pod_to_group(pod_name):
    data = request.get_json()

    group = Group.get_by_name(data['group_name'])
    pod = Pod.get_by_name(pod_name)
    if not group or not pod:
        raise EruAbortException(consts.HTTP_BAD_REQUEST, 'No group/pod found')

    if not pod.assigned_to_group(group):
        raise EruAbortException(consts.HTTP_BAD_REQUEST, 'Assign failed')
    current_app.logger.info('Pod (name=%s) assigned to group (name=%s)',
            pod_name, data['group_name'])
    return {'r':0, 'msg': consts.OK}
开发者ID:BlueKarl,项目名称:eru-core,代码行数:15,代码来源:sys.py

示例6: assign_pod_to_group

# 需要导入模块: from eru.models import Group [as 别名]
# 或者: from eru.models.Group import get_by_name [as 别名]
def assign_pod_to_group(pod_name):
    data = request.get_json()

    group = Group.get_by_name(data['group_name'])
    pod = Pod.get_by_name(pod_name)
    if not group or not pod:
        abort(404, 'No group/pod found')

    if not pod.assigned_to_group(group):
        abort(400, 'Assign failed')
    current_app.logger.info('Pod (name=%s) assigned to group (name=%s)',
            pod_name, data['group_name'])
    return {'r':0, 'msg': consts.OK}
开发者ID:CMGS,项目名称:eru-core,代码行数:15,代码来源:sys.py

示例7: group_max_containers

# 需要导入模块: from eru.models import Group [as 别名]
# 或者: from eru.models.Group import get_by_name [as 别名]
def group_max_containers(group_name):
    pod_name = request.args.get('pod_name', default='')
    core_require = request.args.get('ncore', type=float, default=1)

    group = Group.get_by_name(group_name)
    if not group:
        abort(400, 'No group found')
    pod = Pod.get_by_name(pod_name)
    if not pod:
        abort(400, 'No pod found')

    ncore, nshare = pod.get_core_allocation(core_require)
    return {'r':0, 'msg': consts.OK, 'data': get_max_container_count(group, pod, ncore, nshare)}
开发者ID:CMGS,项目名称:eru-core,代码行数:15,代码来源:sys.py

示例8: assign_host_to_group

# 需要导入模块: from eru.models import Group [as 别名]
# 或者: from eru.models.Group import get_by_name [as 别名]
def assign_host_to_group(addr):
    data = request.get_json()

    group = Group.get_by_name(data['group_name'])
    if not group:
        raise EruAbortException(code.HTTP_BAD_REQUEST)

    host = Host.get_by_addr(addr)
    if not host:
        raise EruAbortException(code.HTTP_BAD_REQUEST)

    if not host.assigned_to_group(group):
        raise EruAbortException(code.HTTP_BAD_REQUEST)
    return {'r':0, 'msg': code.OK}
开发者ID:lcsandy,项目名称:eru-core,代码行数:16,代码来源:sys.py

示例9: group_max_containers

# 需要导入模块: from eru.models import Group [as 别名]
# 或者: from eru.models.Group import get_by_name [as 别名]
def group_max_containers(group_name):
    pod_name = request.args.get('pod_name', type=str, default='')
    core_require = request.args.get('ncore', type=float, default=1)

    group = Group.get_by_name(group_name)
    if not group:
        raise EruAbortException(consts.HTTP_BAD_REQUEST, 'No group found')
    pod = Pod.get_by_name(pod_name)
    if not pod:
        raise EruAbortException(consts.HTTP_BAD_REQUEST, 'No pod found')

    core_require = int(core_require * pod.core_share) # 是说一个容器要几个核...
    ncore = core_require / pod.core_share
    nshare = core_require % pod.core_share

    return {'r':0, 'msg': consts.OK, 'data': group.get_max_containers(pod, ncore, nshare)}
开发者ID:BlueKarl,项目名称:eru-core,代码行数:18,代码来源:sys.py

示例10: assign_host_to_group

# 需要导入模块: from eru.models import Group [as 别名]
# 或者: from eru.models.Group import get_by_name [as 别名]
def assign_host_to_group(addr):
    data = request.get_json()

    group = Group.get_by_name(data['group_name'])
    if not group:
        raise EruAbortException(consts.HTTP_BAD_REQUEST, 'No group found')

    host = Host.get_by_addr(addr)
    if not host:
        raise EruAbortException(consts.HTTP_BAD_REQUEST, 'No host found')

    if not host.assigned_to_group(group):
        raise EruAbortException(consts.HTTP_BAD_REQUEST, 'Assign failed')
    current_app.logger.info('Host (addr=%s) assigned to group (name=%s)',
            addr, data['group_name'])
    return {'r':0, 'msg': consts.OK}
开发者ID:BlueKarl,项目名称:eru-core,代码行数:18,代码来源:sys.py

示例11: validate_instance

# 需要导入模块: from eru.models import Group [as 别名]
# 或者: from eru.models.Group import get_by_name [as 别名]
def validate_instance(group_name, pod_name, appname, version):
    group = Group.get_by_name(group_name)
    if not group:
        abort(400, 'Group `%s` not found' % group_name)

    pod = Pod.get_by_name(pod_name)
    if not pod:
        abort(400, 'Pod `%s` not found' % pod_name)

    app = App.get_by_name(appname)
    if not app:
        abort(400, 'App `%s` not found' % appname)

    version = app.get_version(version)
    if not version:
        abort(400, 'Version `%s` not found' % version)

    return group, pod, app, version
开发者ID:CMGS,项目名称:eru-core,代码行数:20,代码来源:deploy.py

示例12: validate_instance

# 需要导入模块: from eru.models import Group [as 别名]
# 或者: from eru.models.Group import get_by_name [as 别名]
def validate_instance(group_name, pod_name, appname, version):
    group = Group.get_by_name(group_name)
    if not group:
        raise EruAbortException(code.HTTP_BAD_REQUEST, 'Group `%s` not found' % group_name)

    pod = Pod.get_by_name(pod_name)
    if not pod:
        raise EruAbortException(code.HTTP_BAD_REQUEST, 'Pod `%s` not found' % pod_name)

    application = App.get_by_name(appname)
    if not application:
        raise EruAbortException(code.HTTP_BAD_REQUEST, 'App `%s` not found' % appname)

    version = application.get_version(version)
    if not version:
        raise EruAbortException(code.HTTP_BAD_REQUEST, 'Version `%s` not found' % version)

    return group, pod, application, version
开发者ID:marswon,项目名称:eru-core,代码行数:20,代码来源:deploy.py

示例13: test_group_pod

# 需要导入模块: from eru.models import Group [as 别名]
# 或者: from eru.models.Group import get_by_name [as 别名]
def test_group_pod(test_db):
    g1 = Group.create('group1', 'group1')
    g2 = Group.create('group1', 'group1')
    assert g1 is not None
    assert g1.name == 'group1'
    assert g2 is None

    p1 = Pod.create('pod1', 'pod1')
    p2 = Pod.create('pod1', 'pod1')
    assert p1 is not None
    assert p1.name == 'pod1'
    assert p2 is None

    g3 = Group.get_by_name('group1')
    assert g3.id == g1.id

    p3 = Pod.get_by_name('pod1')
    assert p3.id == p1.id

    assert p3.assigned_to_group(g3)
    assert p3.get_free_public_hosts(10) == []
    assert g3.get_max_containers(p3, 1, 2) == 0
    assert g3.get_free_cores(p3, 1, 1, 2) == {}
开发者ID:lcsandy,项目名称:eru-core,代码行数:25,代码来源:test_models.py


注:本文中的eru.models.Group.get_by_name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。