本文整理匯總了Python中fuelweb_test.models.nailgun_client.NailgunClient.get_networks方法的典型用法代碼示例。如果您正苦於以下問題:Python NailgunClient.get_networks方法的具體用法?Python NailgunClient.get_networks怎麽用?Python NailgunClient.get_networks使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類fuelweb_test.models.nailgun_client.NailgunClient
的用法示例。
在下文中一共展示了NailgunClient.get_networks方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: verify_network
# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import get_networks [as 別名]
def verify_network(admin_node_ip, env_name):
client = NailgunClient(admin_node_ip)
cluster_id = client.get_cluster_id(env_name)
env = load_env(env_name)
task = client.verify_networks(cluster_id, client.get_networks(cluster_id)['networks'])
result = task_wait(client, task, 300, 10)
if result['status'] == 'ready':
return "OK"
else:
return result['message']
示例2: FuelWebClient
# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import get_networks [as 別名]
#.........這裏部分代碼省略.........
registered. Otherwise return None.
"""
mac_addresses = map(lambda interface: interface.mac_address.capitalize(), devops_node.interfaces)
for nailgun_node in self.client.list_nodes():
if nailgun_node["mac"].capitalize() in mac_addresses:
nailgun_node["devops_name"] = devops_node.name
return nailgun_node
return None
@logwrap
def get_ssh_for_node(self, node_name):
ip = self.get_nailgun_node_by_devops_node(self.environment.get_virtual_environment().node_by_name(node_name))[
"ip"
]
return self.environment.get_ssh_to_remote(ip)
@logwrap
def get_ssh_for_role(self, nodes_dict, role):
node_name = sorted(filter(lambda name: role in nodes_dict[name], nodes_dict.keys()))[0]
return self.get_ssh_for_node(node_name)
@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, 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)
)
示例3: FuelWebClient
# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import get_networks [as 別名]
#.........這裏部分代碼省略.........
mac_addresses = map(
lambda interface: interface.mac_address.capitalize(),
devops_node.interfaces
)
for nailgun_node in self.client.list_nodes():
if nailgun_node['mac'].capitalize() in mac_addresses:
nailgun_node['devops_name'] = devops_node.name
return nailgun_node
return None
@logwrap
def get_ssh_for_node(self, node_name):
ip = self.get_nailgun_node_by_devops_node(
self.environment.get_virtual_environment().
node_by_name(node_name))['ip']
return self.environment.get_ssh_to_remote(ip)
@logwrap
def get_ssh_for_role(self, nodes_dict, role):
node_name = sorted(filter(lambda name: role in nodes_dict[name],
nodes_dict.keys()))[0]
return self.get_ssh_for_node(node_name)
@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
示例4: remove_env
# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import get_networks [as 別名]
# remove cluster, and create new
remove_env(lab_config["fuel-master"], lab_config["cluster"]["name"])
LOG.info('Creating cluster with:{0}'.format(
pprinter.pformat(lab_config["cluster"])))
client.create_cluster(data=lab_config["cluster"])
# update network and attributes
cluster_id = client.get_cluster_id(lab_config["cluster"]["name"])
if cluster_id is None:
LOG.error(
'Cluster with name %s not found!' % (lab_config["cluster"]["name"]))
sys.exit(1)
cluster_attributes = client.get_cluster_attributes(cluster_id)
cluster_net = client.get_networks(cluster_id)
for network in cluster_net["networks"]:
network_name = network["name"]
if network_name in lab_config["nets"]:
for value in lab_config["nets"][network_name]:
network[value] = lab_config["nets"][network_name][value]
cluster_net["networking_parameters"].update(
lab_config["networking_parameters"])
for section in lab_config["attributes"]:
attr = lab_config["attributes"][section]
for option in attr:
cluster_attributes['editable'][section][option]['value'] = \
lab_config["attributes"][section][option]
示例5: FuelWebClient
# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import get_networks [as 別名]
#.........這裏部分代碼省略.........
"""
devops_macs = {i.mac_address.upper() for i in devops_node.interfaces}
logger.debug('Look for nailgun node by macs %s', devops_macs)
for nailgun_node in self.client.list_nodes():
macs = {i['mac'] for i in nailgun_node['meta']['interfaces']}
if devops_macs == macs:
nailgun_node['devops_name'] = devops_node.name
return nailgun_node
return None
@logwrap
def get_ssh_for_node(self, node_name):
ip = self.get_nailgun_node_by_devops_node(
self.environment.get_virtual_environment().
node_by_name(node_name))['ip']
return self.environment.get_ssh_to_remote(ip)
@logwrap
def get_ssh_for_role(self, nodes_dict, role):
node_name = sorted(filter(lambda name: role in nodes_dict[name],
nodes_dict.keys()))[0]
return self.get_ssh_for_node(node_name)
@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):
logger.info('Run network verification at cluster %s', 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, 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 return_ostf_results(self, cluster_id, timeout):
set_result_list = self._ostf_test_wait(cluster_id, timeout)
tests_res = []
for set_result in set_result_list:
[tests_res.append({test['name']:test['status']})
for test in set_result['tests'] if test['status'] != 'disabled']
logger.info('OSTF test statuses are : {0}'.format(tests_res))
return tests_res
示例6: setup_env
# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import get_networks [as 別名]
def setup_env(admin_node_ip, env_name):
client = NailgunClient(admin_node_ip)
cluster_id = client.get_cluster_id(env_name)
release_id = client.get_release_id()
# delete previous cluster with the same name
if cluster_id:
client.delete_cluster(cluster_id)
for i in range(6):
cluster_id = client.get_cluster_id(env_name)
if cluster_id:
time.sleep(5)
if cluster_id:
return "Can't delete cluster"
# old cluster is gone so we're ok to create a new cluster
env = load_env(env_name)
data = env.data
if "net_provider" in env.settings:
data.update(
{
'net_provider': env.settings["net_provider"],
'net_segment_type': env.settings["net_segment_type"]
}
)
client.create_cluster(data=data)
time.sleep(5)
cluster_id = client.get_cluster_id(env_name)
# configure networks
network_conf = client.get_networks(cluster_id)
network_list = network_conf['networks']
for network in network_list:
# set vlan tags
if network["name"] in env.net_tag:
network['vlan_start'] = env.net_tag[network["name"]]
# set CIDR and related net stuff
if network["name"] in env.net_cidr:
network['cidr'] = env.net_cidr[network["name"]]
if network["name"] == "public":
if env.gateway:
network["gateway"] = env.gateway
else:
network["gateway"] = str(list(IPNetwork(network['cidr']))[1])
if network["name"] in env.net_ip_ranges:
network['ip_ranges'] = env.net_ip_ranges[network["name"]]
else:
if network["name"] == "public":
network['ip_ranges'] = get_range(network['cidr'], -1)
elif network["name"] == "floating":
network['ip_ranges'] = get_range(network['cidr'], 1)
else:
network['ip_ranges'] = get_range(network['cidr'], 0)
network['netmask'] = str(IPNetwork(network['cidr']).netmask)
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:
#.........這裏部分代碼省略.........
示例7: FuelWebClient
# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import get_networks [as 別名]
#.........這裏部分代碼省略.........
for task in tasks:
if task['name'] == 'redhat_setup' \
and task['result']['release_info']['release_id'] \
== release_id:
return self.task_wait(task, 60 * 120)
@logwrap
def update_vlan_network_fixed(
self, cluster_id, amount=1, network_size=256):
self.client.update_network(
cluster_id,
networking_parameters={
"net_manager": help_data.NETWORK_MANAGERS['vlan'],
"fixed_network_size": network_size,
"fixed_networks_amount": amount
}
)
@logwrap
def verify_network(self, cluster_id):
task = self.run_network_verify(cluster_id)
self.assert_task_success(task, 60 * 2, interval=10)
@logwrap
def update_nodes_interfaces(self, cluster_id):
net_provider = self.client.get_cluster(cluster_id)['net_provider']
if NEUTRON == net_provider:
assigned_networks = {
'eth1': ['public'],
'eth2': ['management'],
'eth4': ['storage'],
}
if self.client.get_networks(cluster_id).\
get("networking_parameters").\
get("segmentation_type") == \
NEUTRON_SEGMENT['vlan']:
assigned_networks.update({'eth3': ['private']})
else:
assigned_networks = {
'eth1': ['public'],
'eth2': ['management'],
'eth3': ['fixed'],
'eth4': ['storage'],
}
nailgun_nodes = self.client.list_cluster_nodes(cluster_id)
for node in nailgun_nodes:
self.update_node_networks(node['id'], assigned_networks)
@logwrap
def update_network_configuration(self, cluster_id):
logger.info('Update network settings of cluster %s', cluster_id)
net_config = self.client.get_networks(cluster_id)
new_settings = self.update_net_settings(net_config)
self.client.update_network(
cluster_id=cluster_id,
networking_parameters=new_settings["networking_parameters"],
networks=new_settings["networks"]
)
def update_net_settings(self, network_configuration):
for net in network_configuration.get('networks'):
self.set_network(net_config=net,
net_name=net['name'])
示例8: FuelWebClient
# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import get_networks [as 別名]
#.........這裏部分代碼省略.........
registered. Otherwise return None.
"""
mac_addresses = map(lambda interface: interface.mac_address.capitalize(), devops_node.interfaces)
for nailgun_node in self.client.list_nodes():
if nailgun_node["mac"].capitalize() in mac_addresses:
nailgun_node["devops_name"] = devops_node.name
return nailgun_node
return None
@logwrap
def get_ssh_for_node(self, node_name):
ip = self.get_nailgun_node_by_devops_node(self.environment.get_virtual_environment().node_by_name(node_name))[
"ip"
]
return self.environment.get_ssh_to_remote(ip)
@logwrap
def get_ssh_for_role(self, nodes_dict, role):
node_name = sorted(filter(lambda name: role in nodes_dict[name], nodes_dict.keys()))[0]
return self.get_ssh_for_node(node_name)
@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,