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


Python HostMaintenance.iter_batches方法代码示例

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


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

示例1: test_rack_grouping

# 需要导入模块: from apache.aurora.admin.host_maintenance import HostMaintenance [as 别名]
# 或者: from apache.aurora.admin.host_maintenance.HostMaintenance import iter_batches [as 别名]
def test_rack_grouping():
    old_grouping_functions = HostMaintenance.GROUPING_FUNCTIONS.copy()
    HostMaintenance.GROUPING_FUNCTIONS["by_rack"] = rack_grouping

    example_host_list = [
        "west-aaa-001.example.com",
        "west-aaa-002.example.com",
        "west-xyz-002.example.com",
        "east-xyz-003.example.com",
        "east-xyz-004.example.com",
    ]

    try:
        batches = list(HostMaintenance.iter_batches(example_host_list, 1, "by_rack"))
        assert batches[0] == Hosts(set(["west-aaa-001.example.com", "west-aaa-002.example.com"]))
        assert batches[1] == Hosts(
            set(["west-xyz-002.example.com", "east-xyz-003.example.com", "east-xyz-004.example.com"])
        )

        batches = list(HostMaintenance.iter_batches(example_host_list, 2, "by_rack"))
        assert batches[0] == Hosts(set(example_host_list))

        batches = list(HostMaintenance.iter_batches(example_host_list, 3, "by_rack"))
        assert batches[0] == Hosts(set(example_host_list))

        with pytest.raises(ValueError):
            list(HostMaintenance.iter_batches(example_host_list, 0))

    finally:
        HostMaintenance.GROUPING_FUNCTIONS = old_grouping_functions
开发者ID:retrack,项目名称:incubator-aurora,代码行数:32,代码来源:test_host_maintenance.py

示例2: test_default_grouping

# 需要导入模块: from apache.aurora.admin.host_maintenance import HostMaintenance [as 别名]
# 或者: from apache.aurora.admin.host_maintenance.HostMaintenance import iter_batches [as 别名]
def test_default_grouping():
    example_host_list = ["xyz321.example.com", "bar337.example.com", "foo001.example.com"]

    batches = list(HostMaintenance.iter_batches(example_host_list, 1))
    assert batches[0] == Hosts(set(["bar337.example.com"]))
    assert batches[1] == Hosts(set(["foo001.example.com"]))
    assert batches[2] == Hosts(set(["xyz321.example.com"]))

    batches = list(HostMaintenance.iter_batches(example_host_list, 2))
    assert batches[0] == Hosts(set(["bar337.example.com", "foo001.example.com"]))
    assert batches[1] == Hosts(set(["xyz321.example.com"]))
开发者ID:retrack,项目名称:incubator-aurora,代码行数:13,代码来源:test_host_maintenance.py

示例3: test_none_grouping

# 需要导入模块: from apache.aurora.admin.host_maintenance import HostMaintenance [as 别名]
# 或者: from apache.aurora.admin.host_maintenance.HostMaintenance import iter_batches [as 别名]
def test_none_grouping():
  example_host_list = [
    'xyz321.example.com',
    'bar337.example.com',
    'foo001.example.com',
  ]

  batches = list(HostMaintenance.iter_batches(example_host_list, 'none'))
  assert batches[0] == Hosts(set(example_host_list))
  assert len(batches) == 1
开发者ID:KancerEzeroglu,项目名称:aurora,代码行数:12,代码来源:test_host_maintenance.py

示例4: test_default_grouping

# 需要导入模块: from apache.aurora.admin.host_maintenance import HostMaintenance [as 别名]
# 或者: from apache.aurora.admin.host_maintenance.HostMaintenance import iter_batches [as 别名]
def test_default_grouping():
  example_host_list = [
    'xyz321.example.com',
    'bar337.example.com',
    'foo001.example.com',
  ]

  batches = list(HostMaintenance.iter_batches(example_host_list))
  assert batches[0] == Hosts(set(['bar337.example.com']))
  assert batches[1] == Hosts(set(['foo001.example.com']))
  assert batches[2] == Hosts(set(['xyz321.example.com']))
开发者ID:dhardy92,项目名称:incubator-aurora,代码行数:13,代码来源:test_host_maintenance.py

示例5: test_rack_grouping

# 需要导入模块: from apache.aurora.admin.host_maintenance import HostMaintenance [as 别名]
# 或者: from apache.aurora.admin.host_maintenance.HostMaintenance import iter_batches [as 别名]
def test_rack_grouping():
  example_host_list = [
    'west-aaa-001.example.com',
    'west-aaa-002.example.com',
    'west-xyz-002.example.com',
    'east-xyz-003.example.com',
    'east-xyz-004.example.com',
  ]

  with group_by_rack():
    batches = list(HostMaintenance.iter_batches(example_host_list, 'by_rack'))
    assert batches[0] == Hosts(set([
        'west-aaa-001.example.com',
        'west-aaa-002.example.com'
    ]))
    assert batches[1] == Hosts(set([
        'west-xyz-002.example.com',
        'east-xyz-003.example.com',
        'east-xyz-004.example.com',
    ]))
开发者ID:dhardy92,项目名称:incubator-aurora,代码行数:22,代码来源:test_host_maintenance.py


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