def assign_labeled_network(api):
"""
Adds the labeled network to the cluster and asserts the hosts are attached
"""
engine = api.system_service()
labeled_net = engine.networks_service().list(
search='name={}'.format(LABELED_NET_NAME))[0]
# the logical network will be automatically assigned to all host network
# interfaces with that label asynchronously
cluster_service = test_utils.get_cluster_service(engine, CLUSTER_NAME)
nt.assert_true(
cluster_service.networks_service().add(labeled_net)
)
hosts_service = engine.hosts_service()
for host in test_utils.hosts_in_cluster_v4(engine, CLUSTER_NAME):
host_service = hosts_service.host_service(id=host.id)
testlib.assert_true_within_short(
functools.partial(_host_is_attached_to_network, engine,
host_service, LABELED_NET_NAME))
评论列表
文章目录