本文整理汇总了Python中nailgun.objects.NodeCollection.reset_network_template方法的典型用法代码示例。如果您正苦于以下问题:Python NodeCollection.reset_network_template方法的具体用法?Python NodeCollection.reset_network_template怎么用?Python NodeCollection.reset_network_template使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nailgun.objects.NodeCollection
的用法示例。
在下文中一共展示了NodeCollection.reset_network_template方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_nodes
# 需要导入模块: from nailgun.objects import NodeCollection [as 别名]
# 或者: from nailgun.objects.NodeCollection import reset_network_template [as 别名]
def update_nodes(cls, instance, nodes_ids):
"""Update Cluster nodes by specified node IDs
Nodes with specified IDs will replace existing ones in Cluster
:param instance: Cluster instance
:param nodes_ids: list of nodes ids
:returns: None
"""
# TODO(NAME): sepatate nodes
# for deletion and addition by set().
new_nodes = []
if nodes_ids:
new_nodes = db().query(models.Node).filter(
models.Node.id.in_(nodes_ids)
)
nodes_to_remove = [n for n in instance.nodes
if n not in new_nodes]
nodes_to_add = [n for n in new_nodes
if n not in instance.nodes]
for node in nodes_to_add:
if not node.online:
raise errors.NodeOffline(
u"Cannot add offline node "
u"'{0}' to environment".format(node.id)
)
# we should reset hostname to default value to guarantee
# hostnames uniqueness for nodes outside clusters
from nailgun.objects import Node
for node in nodes_to_remove:
node.hostname = Node.default_slave_name(node)
map(instance.nodes.remove, nodes_to_remove)
map(instance.nodes.append, nodes_to_add)
net_manager = cls.get_network_manager(instance)
map(
net_manager.clear_assigned_networks,
nodes_to_remove
)
map(
net_manager.clear_bond_configuration,
nodes_to_remove
)
cls.replace_provisioning_info_on_nodes(instance, [], nodes_to_remove)
cls.replace_deployment_info_on_nodes(instance, [], nodes_to_remove)
from nailgun.objects import NodeCollection
NodeCollection.reset_network_template(nodes_to_remove)
map(
net_manager.assign_networks_by_default,
nodes_to_add
)
cls.update_nodes_network_template(instance, nodes_to_add)
db().flush()