diff options
author | Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com> | 2018-02-06 10:34:33 +0000 |
---|---|---|
committer | Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com> | 2018-02-06 14:50:04 +0000 |
commit | 1738c931ab93816007b5434c17d46842e488424a (patch) | |
tree | a0e217e9e1d2d16c58ff3d51cf389577f105907b /yardstick/common/utils.py | |
parent | e5775e7efbc55f116b4d4ac11ff87b8d8553247e (diff) |
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 <rodolfo.alonso.hernandez@intel.com>
Diffstat (limited to 'yardstick/common/utils.py')
-rw-r--r-- | yardstick/common/utils.py | 15 |
1 files changed, 15 insertions, 0 deletions
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 |