summaryrefslogtreecommitdiffstats
path: root/yardstick/common/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'yardstick/common/utils.py')
-rw-r--r--yardstick/common/utils.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/yardstick/common/utils.py b/yardstick/common/utils.py
index 3c5895f1e..e53f4b416 100644
--- a/yardstick/common/utils.py
+++ b/yardstick/common/utils.py
@@ -26,6 +26,7 @@ import sys
from functools import reduce
import yaml
+from six.moves import configparser
from oslo_utils import importutils
from oslo_serialization import jsonutils
@@ -144,3 +145,19 @@ def write_json_to_file(path, data, mode='w'):
def write_file(path, data, mode='w'):
with open(path, mode) as f:
f.write(data)
+
+
+def parse_ini_file(path):
+ parser = configparser.ConfigParser()
+ parser.read(path)
+
+ try:
+ default = {k: v for k, v in parser.items('DEFAULT')}
+ except configparser.NoSectionError:
+ default = {}
+
+ config = dict(DEFAULT=default,
+ **{s: {k: v for k, v in parser.items(
+ s)} for s in parser.sections()})
+
+ return config