diff options
Diffstat (limited to 'deploy/tempest.py')
-rw-r--r-- | deploy/tempest.py | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/deploy/tempest.py b/deploy/tempest.py index b28e1265..93dabbe3 100644 --- a/deploy/tempest.py +++ b/deploy/tempest.py @@ -94,6 +94,7 @@ def prepare_install(client): build_pxe_for_discover(cluster_id, client, deployment_interface) elif conf['host'] and conf['host'] == 'yes': isbare = False if 'isbare' in conf and conf['isbare'] == 0 else True + enable_dpdk = True if 'scenario' in conf and 'ovs_dpdk' in conf['scenario'] else False print("discover host...") discover_host(hosts_name, client) time.sleep(10) @@ -101,8 +102,8 @@ def prepare_install(client): hosts_info = get_hosts(client) cluster_info = get_cluster(client) cluster_id = cluster_info.id - add_hosts_interface(cluster_id, hosts_info, mac_address_map, - host_interface_map, vip, isbare, client) + update_hosts_interface(cluster_id, hosts_info, mac_address_map, + host_interface_map, vip, isbare, client, enable_dpdk) if len(hosts_name) == 1: protocol_type = 'LVM' service_name = 'cinder' @@ -163,13 +164,16 @@ def install_os_for_vm_step2(cluster_id, client): def discover_host(hosts_name, client): - while True: + retry = 90 + while retry: hosts_info = get_hosts(client) if len(hosts_info) == len(hosts_name): print('discover hosts success!') - break + return else: time.sleep(10) + retry = retry - 1 + err_exit('Failed to discover hosts') def update_network(cluster_id, network_map, client): @@ -199,9 +203,9 @@ def get_cluster(client): return cluster_info -def add_hosts_interface(cluster_id, hosts_info, mac_address_map, - host_interface_map, - vip, isbare, client): +def update_hosts_interface(cluster_id, hosts_info, mac_address_map, + host_interface_map, vip, + isbare, client, enable_dpdk): for host in hosts_info: dha_host_name = None host = host.to_dict() @@ -214,6 +218,11 @@ def add_hosts_interface(cluster_id, hosts_info, mac_address_map, if interface_name in host_interface_map: interface['assigned_networks'] = \ host_interface_map[interface_name] + if enable_dpdk: + for assigned_network in interface['assigned_networks']: + if assigned_network['name'] == 'physnet1': + interface['vswitch_type'] = 'dvs' + break for nodename in mac_address_map: if interface['mac'] in mac_address_map[nodename]: dha_host_name = nodename @@ -228,11 +237,38 @@ def add_hosts_interface(cluster_id, hosts_info, mac_address_map, host['os_version'] = iso_path + filename if host['os_version'] == iso_path: print("do not have os iso file in /var/lib/daisy/kolla/.") + if enable_dpdk: + host['hugepages'] = str(get_hugepages(host)) + host['hugepagesize'] = '1G' client.hosts.update(host['id'], **host) + host_info = client.hosts.get(host['id']).to_dict() + if host_info.get('suggest_dvsc_cpus') and host_info['suggest_dvsc_cpus'][0] > 0: + host_isolcpus = {'isolcpus': host_info['suggest_dvsc_cpus']} + client.hosts.update(host['id'], **host_isolcpus) print("update role...") add_host_role(cluster_id, host['id'], dha_host_name, vip, client) +def get_hugepages(host): + total_str = str(host['memory']['total']) + total = int(filter(str.isdigit, total_str)) + unit = filter(str.isalpha, total_str).lower() + + if unit == 'kb': + total = total / 1024 / 1024 + elif unit == 'mb': + total = total / 1024 + elif unit == 'gb': + pass + elif unit == 'b' or unit == '': + total = total / 1024 / 1024 / 1024 + num = total * 6 / 10 + if num % 2 != 0: + num = num + 1 + + return num + + def add_host_role(cluster_id, host_id, dha_host_name, vip, client): role_meta = {'filters': {'cluster_id': cluster_id}} role_list_generator = client.roles.list(**role_meta) |