本文整理匯總了Python中fuelweb_test.models.nailgun_client.NailgunClient.get_node_interfaces方法的典型用法代碼示例。如果您正苦於以下問題:Python NailgunClient.get_node_interfaces方法的具體用法?Python NailgunClient.get_node_interfaces怎麽用?Python NailgunClient.get_node_interfaces使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類fuelweb_test.models.nailgun_client.NailgunClient
的用法示例。
在下文中一共展示了NailgunClient.get_node_interfaces方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: FuelWebClient
# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import get_node_interfaces [as 別名]
#.........這裏部分代碼省略.........
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
@logwrap
def update_node_networks(self, node_id, interfaces_dict):
interfaces = self.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)
self.client.put_node_interfaces(
[{'id': node_id, 'interfaces': interfaces}])
@logwrap
def update_node_disk(self, node_id, disks_dict):
disks = self.client.get_node_disks(node_id)
for disk in disks:
dname = disk['name']
if dname not in disks_dict:
continue
for volume in disk['volumes']:
vname = volume['name']
if vname in disks_dict[dname]:
volume['size'] = disks_dict[dname][vname]
self.client.put_node_disks(node_id, disks)
@logwrap
def update_redhat_credentials(
self, license_type=help_data.REDHAT_LICENSE_TYPE,
username=help_data.REDHAT_USERNAME, password=help_data.REDHAT_PASSWORD,
satellite_host=help_data.REDHAT_SATELLITE_HOST,
示例2: FuelWebClient
# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import get_node_interfaces [as 別名]
#.........這裏部分代碼省略.........
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
@logwrap
def update_node_networks(self, node_id, interfaces_dict):
# fuelweb_admin is always on eth0
interfaces_dict["eth0"] = interfaces_dict.get("eth0", [])
if "fuelweb_admin" not in interfaces_dict["eth0"]:
interfaces_dict["eth0"].append("fuelweb_admin")
interfaces = self.client.get_node_interfaces(node_id)
all_networks = dict()
for interface in interfaces:
all_networks.update({net["name"]: net for net in interface["assigned_networks"]})
for interface in interfaces:
name = interface["name"]
interface["assigned_networks"] = [all_networks[i] for i in interfaces_dict.get(name, [])]
self.client.put_node_interfaces([{"id": node_id, "interfaces": interfaces}])
@logwrap
def update_node_disk(self, node_id, disks_dict):
disks = self.client.get_node_disks(node_id)
for disk in disks:
dname = disk["name"]
if dname not in disks_dict:
continue
for volume in disk["volumes"]:
vname = volume["name"]
if vname in disks_dict[dname]:
volume["size"] = disks_dict[dname][vname]
self.client.put_node_disks(node_id, disks)
@logwrap
def update_redhat_credentials(
self,
license_type=help_data.REDHAT_LICENSE_TYPE,
username=help_data.REDHAT_USERNAME,
password=help_data.REDHAT_PASSWORD,
satellite_host=help_data.REDHAT_SATELLITE_HOST,
activation_key=help_data.REDHAT_ACTIVATION_KEY,
示例3: strict_pin_node_to_cluster
# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import get_node_interfaces [as 別名]
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(
node['id']), lab_config.get('roller'))
if upd_ifs:
client.put_node_interfaces(
[{'id': node['id'],
'interfaces': upd_ifs}])
LOG.info("StageX: END Assign network role to nic per node")
if START_DEPLOYMENT.lower() == 'true':
示例4: FuelWebClient
# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import get_node_interfaces [as 別名]
#.........這裏部分代碼省略.........
'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, raw_data=None):
# fuelweb_admin is always on eth0
interfaces_dict['eth0'] = interfaces_dict.get('eth0', [])
if 'fuelweb_admin' not in interfaces_dict['eth0']:
interfaces_dict['eth0'].append('fuelweb_admin')
interfaces = self.client.get_node_interfaces(node_id)
if raw_data:
interfaces.append(raw_data)
all_networks = dict()
for interface in interfaces:
all_networks.update(
{net['name']: net for net in interface['assigned_networks']})
for interface in interfaces:
name = interface["name"]
interface['assigned_networks'] = \
[all_networks[i] for i in interfaces_dict.get(name, [])]
self.client.put_node_interfaces(
[{'id': node_id, 'interfaces': interfaces}])
@logwrap
def update_node_disk(self, node_id, disks_dict):
disks = self.client.get_node_disks(node_id)
for disk in disks:
dname = disk['name']
if dname not in disks_dict:
continue
for volume in disk['volumes']:
vname = volume['name']
if vname in disks_dict[dname]:
volume['size'] = disks_dict[dname][vname]
self.client.put_node_disks(node_id, disks)
@logwrap
示例5: setup_env
# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import get_node_interfaces [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 get_node_interfaces [as 別名]
#.........這裏部分代碼省略.........
'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, raw_data=None):
# fuelweb_admin is always on eth0
interfaces_dict['eth0'] = interfaces_dict.get('eth0', [])
if 'fuelweb_admin' not in interfaces_dict['eth0']:
interfaces_dict['eth0'].append('fuelweb_admin')
interfaces = self.client.get_node_interfaces(node_id)
if raw_data:
interfaces.append(raw_data)
all_networks = dict()
for interface in interfaces:
all_networks.update(
{net['name']: net for net in interface['assigned_networks']})
for interface in interfaces:
name = interface["name"]
interface['assigned_networks'] = \
[all_networks[i] for i in interfaces_dict.get(name, [])]
self.client.put_node_interfaces(
[{'id': node_id, 'interfaces': interfaces}])
@logwrap
def update_node_disk(self, node_id, disks_dict):
disks = self.client.get_node_disks(node_id)
for disk in disks:
dname = disk['name']
if dname not in disks_dict:
continue
for volume in disk['volumes']:
vname = volume['name']
if vname in disks_dict[dname]:
volume['size'] = disks_dict[dname][vname]
self.client.put_node_disks(node_id, disks)
@logwrap
示例7: FuelWebClient
# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import get_node_interfaces [as 別名]
#.........這裏部分代碼省略.........
@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:
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)
self.client.put_node_interfaces([{"id": node_id, "interfaces": interfaces}])
@logwrap
def update_redhat_credentials(
self,
license_type=help_data.REDHAT_LICENSE_TYPE,
username=help_data.REDHAT_USERNAME,
password=help_data.REDHAT_PASSWORD,
satellite_host=help_data.REDHAT_SATELLITE_HOST,
activation_key=help_data.REDHAT_ACTIVATION_KEY,
):
# release name is in environment variable OPENSTACK_RELEASE
release_id = self.client.get_release_id("RHOS")
self.client.update_redhat_setup(
{
"release_id": release_id,
"username": username,
"license_type": license_type,
"satellite": satellite_host,
"password": password,
"activation_key": activation_key,
}
)