本文整理汇总了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
示例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"]))
示例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
示例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']))
示例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',
]))