本文整理匯總了Python中fuelweb_test.models.nailgun_client.NailgunClient.delete_cluster方法的典型用法代碼示例。如果您正苦於以下問題:Python NailgunClient.delete_cluster方法的具體用法?Python NailgunClient.delete_cluster怎麽用?Python NailgunClient.delete_cluster使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類fuelweb_test.models.nailgun_client.NailgunClient
的用法示例。
在下文中一共展示了NailgunClient.delete_cluster方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: remove_env
# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import delete_cluster [as 別名]
def remove_env(admin_node_ip, env_name, dont_wait_for_nodes=True):
LOG.info('Removing cluster with name:{0}'.format(env_name))
client = NailgunClient(admin_node_ip)
cluster_id = client.get_cluster_id(env_name)
all_nodes = []
if cluster_id:
cluster_nodes = client.list_cluster_nodes(cluster_id)
if len(cluster_nodes) > 0:
all_nodes = client.list_nodes()
client.delete_cluster(cluster_id)
else:
LOG.info('Looks like cluster has not been created before.Okay')
return "OK"
# wait for cluster to disappear
rerty_c = 120
for i in range(rerty_c):
cluster_id = client.get_cluster_id(env_name)
LOG.info('Wait for cluster to disappear...try %s /%s' % (i, rerty_c))
if cluster_id:
time.sleep(10)
else:
break
# fail if cluster is still around
if cluster_id:
return "Can't delete cluster"
# wait for removed nodes to come back online
if not dont_wait_for_nodes:
for i in range(90):
cur_nodes = client.list_nodes()
if len(cur_nodes) < len(all_nodes):
LOG.info('Wait for nodes to came back. Should be:{0} '
'Currently:{1} ...try {2}'.format(
len(all_nodes), len(cur_nodes), i))
time.sleep(10)
if len(client.list_nodes()) < len(all_nodes) and not dont_wait_for_nodes:
return "Timeout while waiting for removed nodes ({}) to come back up".format(
len(cluster_nodes))
return "OK"
示例2: remove_env
# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import delete_cluster [as 別名]
def remove_env(admin_node_ip, env_name, dont_wait_for_nodes):
client = NailgunClient(admin_node_ip)
cluster_id = client.get_cluster_id(env_name)
need_to_wait_for_nodes = False
all_nodes = []
if cluster_id:
cluster_nodes = client.list_cluster_nodes(cluster_id)
if len(cluster_nodes) > 0:
need_to_wait_for_nodes = True
all_nodes = client.list_nodes()
client.delete_cluster(cluster_id)
else:
return "OK"
# wait for cluster to disappear
for i in range(60):
cluster_id = client.get_cluster_id(env_name)
if cluster_id:
time.sleep(10)
# fail if cluster is still around
if cluster_id:
return "Can't delete cluster"
# wait for removed nodes to come back online
if not dont_wait_for_nodes:
for i in range(90):
cur_nodes = client.list_nodes()
if len(cur_nodes) < len(all_nodes):
time.sleep(10)
if len(cur_nodes) < len(all_nodes) and not dont_wait_for_nodes:
return "Timeout while waiting for removed nodes ({}) to come back up".format(len(cluster_nodes))
return "OK"
示例3: setup_env
# 需要導入模塊: from fuelweb_test.models.nailgun_client import NailgunClient [as 別名]
# 或者: from fuelweb_test.models.nailgun_client.NailgunClient import delete_cluster [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:
#.........這裏部分代碼省略.........