summaryrefslogtreecommitdiffstats
path: root/deploy
diff options
context:
space:
mode:
authorAlex Yang <yangyang1@zte.com.cn>2018-04-19 11:11:54 +0800
committerAlex Yang <yangyang1@zte.com.cn>2018-04-19 11:11:54 +0800
commit8f2ee9b2e21fbd20e088a94f5292ffeb476d2895 (patch)
tree87b8690f11f7e77b175077895d608be90ab8afcb /deploy
parent6a7ee18538561c772b0bfbc48805e2a2de74a9c6 (diff)
Calculate hugepage num accoding to host's memory
Change-Id: I49cfa3265af776e3cdea5de59096ff3257f75fb0 Signed-off-by: Alex Yang <yangyang1@zte.com.cn>
Diffstat (limited to 'deploy')
-rw-r--r--deploy/tempest.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/deploy/tempest.py b/deploy/tempest.py
index 342a0205..93dabbe3 100644
--- a/deploy/tempest.py
+++ b/deploy/tempest.py
@@ -238,7 +238,7 @@ def update_hosts_interface(cluster_id, hosts_info, mac_address_map,
if host['os_version'] == iso_path:
print("do not have os iso file in /var/lib/daisy/kolla/.")
if enable_dpdk:
- host['hugepages'] = '80'
+ host['hugepages'] = str(get_hugepages(host))
host['hugepagesize'] = '1G'
client.hosts.update(host['id'], **host)
host_info = client.hosts.get(host['id']).to_dict()
@@ -249,6 +249,26 @@ def update_hosts_interface(cluster_id, hosts_info, mac_address_map,
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)