From 1738c931ab93816007b5434c17d46842e488424a Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Tue, 6 Feb 2018 10:34:33 +0000 Subject: Improve SampleVNF hugepages setup The goal of this function is to: - Read the default hugepage size. - Set 16GB of hugepages. - Check if the status of the last action. According to [1], the default hugepage size could be read in "/proc/meminfo", always in kB. Then "/proc/sys/vm/nr_hugepages" could be used to set the number of default hugepages. [1] https://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt JIRA: YARDSTICK-997 Change-Id: I762d1b16294ba1c1c2feee56610819ac358c7410 Signed-off-by: Rodolfo Alonso Hernandez --- yardstick/common/utils.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'yardstick/common/utils.py') diff --git a/yardstick/common/utils.py b/yardstick/common/utils.py index 8604e900f..495290122 100644 --- a/yardstick/common/utils.py +++ b/yardstick/common/utils.py @@ -22,6 +22,7 @@ import ipaddress import logging import os import random +import re import socket import subprocess import sys @@ -395,3 +396,17 @@ class Timer(object): def __getattr__(self, item): return getattr(self.delta, item) + + +def read_meminfo(ssh_client): + """Read "/proc/meminfo" file and parse all keys and values""" + + cpuinfo = six.BytesIO() + ssh_client.get_file_obj('/proc/meminfo', cpuinfo) + lines = cpuinfo.getvalue().decode('utf-8') + matches = re.findall(r"([\w\(\)]+):\s+(\d+)( kB)*", lines) + output = {} + for match in matches: + output[match[0]] = match[1] + + return output -- cgit 1.2.3-korg