本文整理匯總了Python中fuelweb_test.models.nailgun_client.NailgunClient.update_nodes方法的典型用法代碼示例。如果您正苦於以下問題:Python NailgunClient.update_nodes方法的具體用法?Python NailgunClient.update_nodes怎麽用?Python NailgunClient.update_nodes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類fuelweb_test.models.nailgun_client.NailgunClient
的用法示例。
在下文中一共展示了NailgunClient.update_nodes方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: FuelWebClient
# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import update_nodes [as 別名]
#.........這裏部分代碼省略.........
cluster_id, self.client.get_networks(cluster_id)['networks'])
@logwrap
def run_ostf(self, cluster_id, test_sets=None,
should_fail=0, should_pass=0):
test_sets = test_sets \
if test_sets is not None \
else ['smoke', 'sanity']
self.client.ostf_run_tests(cluster_id, test_sets)
self.assert_ostf_run(
cluster_id,
should_fail=should_fail,
should_pass=should_pass
)
@logwrap
def task_wait(self, task, timeout, interval=5):
try:
wait(
lambda: self.client.get_task(
task['id'])['status'] != 'running',
interval=interval,
timeout=timeout
)
except TimeoutError:
raise TimeoutError(
"Waiting task \"{task}\" timeout {timeout} sec "
"was exceeded: ".format(task=task["name"], timeout=timeout))
return self.client.get_task(task['id'])
@logwrap
def update_nodes(self, cluster_id, nodes_dict,
pending_addition=True, pending_deletion=False):
# update nodes in cluster
nodes_data = []
for node_name in nodes_dict:
devops_node = self.environment.get_virtual_environment().\
node_by_name(node_name)
wait(lambda:
self.get_nailgun_node_by_devops_node(devops_node)['online'],
timeout=60 * 2)
node = self.get_nailgun_node_by_devops_node(devops_node)
assert_true(node['online'], 'Node {} is online'.format(node['mac']))
node_data = {
'cluster_id': cluster_id,
'id': node['id'],
'pending_addition': pending_addition,
'pending_deletion': pending_deletion,
'pending_roles': nodes_dict[node_name],
'name': '{}_{}'.format(
node_name,
"_".join(nodes_dict[node_name])
)
}
nodes_data.append(node_data)
# assume nodes are going to be updated for one cluster only
cluster_id = nodes_data[-1]['cluster_id']
node_ids = [str(node_info['id']) for node_info in nodes_data]
self.client.update_nodes(nodes_data)
nailgun_nodes = self.client.list_cluster_nodes(cluster_id)
示例2: FuelWebClient
# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import update_nodes [as 別名]
#.........這裏部分代碼省略.........
def run_ostf(
self, cluster_id, test_sets=None, should_fail=0, tests_must_be_passed=None, timeout=None, failed_test_name=None
):
test_sets = test_sets or ["smoke", "sanity"]
timeout = timeout or 30 * 60
self.client.ostf_run_tests(cluster_id, test_sets)
if tests_must_be_passed:
self.assert_ostf_run_certain(cluster_id, tests_must_be_passed, timeout)
else:
logger.info("Try to run assert ostf with " "expected fail name {0}".format(failed_test_name))
self.assert_ostf_run(
cluster_id, should_fail=should_fail, timeout=timeout, failed_test_name=failed_test_name
)
@logwrap
def run_single_ostf_test(self, cluster_id, test_sets=None, test_name=None, should_fail=0):
self.client.ostf_run_singe_test(cluster_id, test_sets, test_name)
self.assert_ostf_run(cluster_id, should_fail=should_fail)
@logwrap
def task_wait(self, task, timeout, interval=5):
try:
wait(lambda: self.client.get_task(task["id"])["status"] != "running", interval=interval, timeout=timeout)
except TimeoutError:
raise TimeoutError(
'Waiting task "{task}" timeout {timeout} sec '
"was exceeded: ".format(task=task["name"], timeout=timeout)
)
return self.client.get_task(task["id"])
@logwrap
def update_nodes(self, cluster_id, nodes_dict, pending_addition=True, pending_deletion=False):
# update nodes in cluster
nodes_data = []
for node_name in nodes_dict:
devops_node = self.environment.get_virtual_environment().node_by_name(node_name)
wait(lambda: self.get_nailgun_node_by_devops_node(devops_node)["online"], timeout=60 * 2)
node = self.get_nailgun_node_by_devops_node(devops_node)
assert_true(node["online"], "Node {} is online".format(node["mac"]))
node_data = {
"cluster_id": cluster_id,
"id": node["id"],
"pending_addition": pending_addition,
"pending_deletion": pending_deletion,
"pending_roles": nodes_dict[node_name],
"name": "{}_{}".format(node_name, "_".join(nodes_dict[node_name])),
}
nodes_data.append(node_data)
# assume nodes are going to be updated for one cluster only
cluster_id = nodes_data[-1]["cluster_id"]
node_ids = [str(node_info["id"]) for node_info in nodes_data]
self.client.update_nodes(nodes_data)
nailgun_nodes = self.client.list_cluster_nodes(cluster_id)
cluster_node_ids = map(lambda _node: str(_node["id"]), nailgun_nodes)
assert_true(all([node_id in cluster_node_ids for node_id in node_ids]))
self.update_nodes_interfaces(cluster_id)
return nailgun_nodes
示例3: wait_free_nodes
# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import update_nodes [as 別名]
should_be_nodes = lab_config['roller']['controller']['count'] + \
lab_config['roller']['compute']['count']
wait_free_nodes(lab_config, should_be_nodes)
# add nodes to cluster
LOG.info("StageX:START Assign nodes to cluster")
if assign_method == 'hw_pin':
while len(client.list_cluster_nodes(cluster_id)) < should_be_nodes:
for node in client.list_nodes():
node_new = strict_pin_node_to_cluster(node, lab_config)
if node_new:
client.update_node(node['id'], node_new)
# FIXME add at least timeout
time.sleep(5)
else:
client.update_nodes(simple_pin_nodes_to_cluster(client.list_nodes(),
lab_config['roller']))
LOG.info("StageX: END Assign nodes to cluster")
# assign\create network role to nic per node
LOG.info("StageX: Assign network role to nic per node")
if assign_method == 'hw_pin':
for node in client.list_cluster_nodes(cluster_id):
upd_ifs = strict_pin_nw_to_node(node, client.get_node_interfaces(
node['id']), lab_config)
if upd_ifs:
client.put_node_interfaces(
[{'id': node['id'],
'interfaces': upd_ifs}])
else:
for node in client.list_cluster_nodes(cluster_id):
upd_ifs = simple_pin_nw_to_node(node, client.get_node_interfaces(
示例4: FuelWebClient
# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import update_nodes [as 別名]
#.........這裏部分代碼省略.........
wait(
lambda: self.client.get_task(
task['id'])['status'] != 'running',
interval=interval,
timeout=timeout
)
except TimeoutError:
raise TimeoutError(
"Waiting task \"{task}\" timeout {timeout} sec "
"was exceeded: ".format(task=task["name"], timeout=timeout))
return self.client.get_task(task['id'])
@logwrap
def task_wait_progress(self, task, timeout, interval=5, progress=None):
try:
logger.info(
'start to wait with timeout {0} '
'interval {1}'.format(timeout, interval))
wait(
lambda: self.client.get_task(
task['id'])['progress'] >= progress,
interval=interval,
timeout=timeout
)
except TimeoutError:
raise TimeoutError(
"Waiting task \"{task}\" timeout {timeout} sec "
"was exceeded: ".format(task=task["name"], timeout=timeout))
return self.client.get_task(task['id'])
@logwrap
def update_nodes(self, cluster_id, nodes_dict,
pending_addition=True, pending_deletion=False):
# update nodes in cluster
nodes_data = []
for node_name in nodes_dict:
devops_node = self.environment.get_virtual_environment().\
node_by_name(node_name)
wait(lambda:
self.get_nailgun_node_by_devops_node(devops_node)['online'],
timeout=60 * 2)
node = self.get_nailgun_node_by_devops_node(devops_node)
assert_true(node['online'],
'Node {} is online'.format(node['mac']))
node_data = {
'cluster_id': cluster_id,
'id': node['id'],
'pending_addition': pending_addition,
'pending_deletion': pending_deletion,
'pending_roles': nodes_dict[node_name],
'name': '{}_{}'.format(
node_name,
"_".join(nodes_dict[node_name])
)
}
nodes_data.append(node_data)
# assume nodes are going to be updated for one cluster only
cluster_id = nodes_data[-1]['cluster_id']
node_ids = [str(node_info['id']) for node_info in nodes_data]
self.client.update_nodes(nodes_data)
示例5: setup_env
# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import update_nodes [as 別名]
#.........這裏部分代碼省略.........
network['network_size'] = len(list(IPNetwork((network['cidr']))))
network_conf['networks'] = network_list
# update neutron settings
if "net_provider" in env.settings:
if env.settings["net_provider"] == 'neutron':
# check if we need to set vlan tags
if env.settings["net_segment_type"] == 'vlan' and 'neutron_vlan_range' in env.settings:
network_conf['neutron_parameters']['L2']['phys_nets']['physnet2']['vlan_range'] = env.settings['neutron_vlan_range']
# check and update networks CIDR/netmask/size/etc
if 'net04' in env.net_cidr:
network_conf['neutron_parameters']['predefined_networks']['net04']['L3']['cidr'] = env.net_cidr['net04']
network_conf['neutron_parameters']['predefined_networks']['net04']['L3']['gateway'] = str(list(IPNetwork(env.net_cidr['net04']))[1])
if 'public' in env.net_cidr:
network_conf['neutron_parameters']['predefined_networks']['net04_ext']['L3']['cidr'] = env.net_cidr['public']
if env.gateway:
network_conf['neutron_parameters']['predefined_networks']['net04_ext']['L3']['gateway'] = env.gateway
else:
network_conf['neutron_parameters']['predefined_networks']['net04_ext']['L3']['gateway'] = str(list(IPNetwork(env.net_cidr['public']))[1])
if 'net04_ext' in env.net_ip_ranges:
network_conf['neutron_parameters']['predefined_networks']['net04_ext']['L3']['floating'] = env.net_ip_ranges["net04_ext"]
else:
network_conf['neutron_parameters']['predefined_networks']['net04_ext']['L3']['floating'] = get_range(env.net_cidr['public'], 2)
# push updated network to Fuel API
client.update_network(cluster_id, networks=network_conf, all_set=True)
# configure cluster attributes
attributes = client.get_cluster_attributes(cluster_id)
for option in env.settings:
section = False
if option in ('savanna', 'murano', 'ceilometer'):
section = 'additional_components'
if option in ('volumes_ceph', 'images_ceph', 'volumes_lvm'):
section = 'storage'
if option in ('libvirt_type', 'vlan_splinters'):
section = 'common'
if section:
attributes['editable'][section][option]['value'] = env.settings[option]
attributes['editable']['common']['debug']['value'] = True
client.update_cluster_attributes(cluster_id, attributes)
# get all nodes
for i in range(18):
all_nodes = client.list_nodes()
if len(all_nodes) < len(env.node_roles) + len(env.special_roles):
time.sleep(10)
# check if we have enough nodes for our test case
if len(all_nodes) < len(env.node_roles) + len(env.special_roles):
return "Not enough nodes"
nodes_data = []
node_local_id = 0
# go through unassigned nodes and update their pending_roles according to environment settings
for node in all_nodes:
if node['cluster'] == None and (node_local_id < len(env.node_roles) or node['mac'] in env.special_roles):
if node['mac'] in env.special_roles:
node_role = env.special_roles[node['mac']]
else:
node_role = env.node_roles[node_local_id]
node_local_id += 1
node_data = {
'cluster_id': cluster_id,
'id': node['id'],
'pending_addition': "true",
'pending_roles': node_role
}
nodes_data.append(node_data)
# add nodes to cluster
client.update_nodes(nodes_data)
# check if we assigned all nodes we wanted to
cluster_nodes = client.list_cluster_nodes(cluster_id)
if len(cluster_nodes) != len(env.node_roles) + len(env.special_roles):
return "Not enough nodes"
# move networks to appropriate nodes interfaces (according to environment settings)
for node in cluster_nodes:
node_id = node['id']
interfaces_dict = env.interfaces
interfaces = client.get_node_interfaces(node_id)
for interface in interfaces:
interface_name = interface['name']
interface['assigned_networks'] = []
for allowed_network in interface['allowed_networks']:
key_exists = interface_name in interfaces_dict
if key_exists and \
allowed_network['name'] \
in interfaces_dict[interface_name]:
interface['assigned_networks'].append(allowed_network)
client.put_node_interfaces(
[{'id': node_id, 'interfaces': interfaces}])
return "OK"
示例6: FuelWebClient
# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import update_nodes [as 別名]
#.........這裏部分代碼省略.........
wait(
lambda: self.client.get_task(
task['id'])['status'] != 'running',
interval=interval,
timeout=timeout
)
except TimeoutError:
raise TimeoutError(
"Waiting task \"{task}\" timeout {timeout} sec "
"was exceeded: ".format(task=task["name"], timeout=timeout))
return self.client.get_task(task['id'])
@logwrap
def task_wait_progress(self, task, timeout, interval=5, progress=None):
try:
logger.info(
'start to wait with timeout {0} '
'interval {1}'.format(timeout, interval))
wait(
lambda: self.client.get_task(
task['id'])['progress'] >= progress,
interval=interval,
timeout=timeout
)
except TimeoutError:
raise TimeoutError(
"Waiting task \"{task}\" timeout {timeout} sec "
"was exceeded: ".format(task=task["name"], timeout=timeout))
return self.client.get_task(task['id'])
@logwrap
def update_nodes(self, cluster_id, nodes_dict,
pending_addition=True, pending_deletion=False):
# update nodes in cluster
nodes_data = []
for node_name in nodes_dict:
devops_node = self.environment.get_virtual_environment().\
node_by_name(node_name)
wait(lambda:
self.get_nailgun_node_by_devops_node(devops_node)['online'],
timeout=60 * 2)
node = self.get_nailgun_node_by_devops_node(devops_node)
assert_true(node['online'],
'Node {} is online'.format(node['mac']))
node_data = {
'cluster_id': cluster_id,
'id': node['id'],
'pending_addition': pending_addition,
'pending_deletion': pending_deletion,
'pending_roles': nodes_dict[node_name],
'name': '{}_{}'.format(
node_name,
"_".join(nodes_dict[node_name])
)
}
nodes_data.append(node_data)
# assume nodes are going to be updated for one cluster only
cluster_id = nodes_data[-1]['cluster_id']
node_ids = [str(node_info['id']) for node_info in nodes_data]
self.client.update_nodes(nodes_data)
示例7: FuelWebClient
# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import update_nodes [as 別名]
#.........這裏部分代碼省略.........
@logwrap
def is_node_discovered(self, nailgun_node):
return any(
map(
lambda node: node["mac"] == nailgun_node["mac"] and node["status"] == "discover",
self.client.list_nodes(),
)
)
@logwrap
def run_network_verify(self, cluster_id):
return self.client.verify_networks(cluster_id, self.client.get_networks(cluster_id)["networks"])
@logwrap
def run_ostf(self, cluster_id, test_sets=None, should_fail=0, should_pass=0):
test_sets = test_sets if test_sets is not None else ["smoke", "sanity"]
self.client.ostf_run_tests(cluster_id, test_sets)
self.assert_ostf_run(cluster_id, should_fail=should_fail, should_pass=should_pass)
@logwrap
def task_wait(self, task, timeout, interval=5):
try:
wait(lambda: self.client.get_task(task["id"])["status"] != "running", interval=interval, timeout=timeout)
except TimeoutError:
raise TimeoutError(
'Waiting task "{task}" timeout {timeout} sec '
"was exceeded: ".format(task=task["name"], timeout=timeout)
)
return self.client.get_task(task["id"])
@logwrap
def update_nodes(self, cluster_id, nodes_dict, pending_addition=True, pending_deletion=False):
# update nodes in cluster
nodes_data = []
for node_name in nodes_dict:
devops_node = self.environment.get_virtual_environment().node_by_name(node_name)
node = self.get_nailgun_node_by_devops_node(devops_node)
node_data = {
"cluster_id": cluster_id,
"id": node["id"],
"pending_addition": pending_addition,
"pending_deletion": pending_deletion,
"pending_roles": nodes_dict[node_name],
"name": "{}_{}".format(node_name, "_".join(nodes_dict[node_name])),
}
nodes_data.append(node_data)
# assume nodes are going to be updated for one cluster only
cluster_id = nodes_data[-1]["cluster_id"]
node_ids = [str(node_info["id"]) for node_info in nodes_data]
self.client.update_nodes(nodes_data)
nailgun_nodes = self.client.list_cluster_nodes(cluster_id)
cluster_node_ids = map(lambda _node: str(_node["id"]), nailgun_nodes)
assert_true(all([node_id in cluster_node_ids for node_id in node_ids]))
self.update_nodes_interfaces(cluster_id)
return nailgun_nodes
@logwrap
def update_node_networks(self, node_id, interfaces_dict):
interfaces = self.client.get_node_interfaces(node_id)
for interface in interfaces: