summaryrefslogtreecommitdiffstats
path: root/apex/common/parsers.py
diff options
context:
space:
mode:
authorTim Rozet <trozet@redhat.com>2017-09-08 16:57:36 -0400
committerTim Rozet <trozet@redhat.com>2017-09-13 10:13:06 -0400
commitcb606f45e3852432787ed895dc55665caa950161 (patch)
treea987204e28ed22ee3e149c7a03d9e723c2e53a21 /apex/common/parsers.py
parent8d3d5e679fba8e4140730e60809fc4f71cdc098e (diff)
Migrates clean to python
ci/clean.sh will be removed in a future patch after releng is updated to use python. JIRA: APEX-509 JIRA: APEX-319 Change-Id: If890db2fc5a31833ad28ec6f04589e25457bd380 Signed-off-by: Tim Rozet <trozet@redhat.com>
Diffstat (limited to 'apex/common/parsers.py')
-rw-r--r--apex/common/parsers.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/apex/common/parsers.py b/apex/common/parsers.py
index 8744c862..91b8905b 100644
--- a/apex/common/parsers.py
+++ b/apex/common/parsers.py
@@ -71,3 +71,28 @@ def parse_overcloudrc(in_file):
logging.debug("os cred not found in: {}".format(line))
return creds
+
+
+def parse_ifcfg_file(in_file):
+ """
+ Parses ifcfg file information
+ :param in_file:
+ :return: dictionary of ifcfg key value pairs
+ """
+ ifcfg_params = {
+ 'IPADDR': '',
+ 'NETMASK': '',
+ 'GATEWAY': '',
+ 'METRIC': '',
+ 'DNS1': '',
+ 'DNS2': '',
+ 'PREFIX': ''
+ }
+ with open(in_file, 'r') as fh:
+ for line in fh:
+ for param in ifcfg_params.keys():
+ match = re.search("^\s*{}=(.*)$".format(param), line)
+ if match:
+ ifcfg_params[param] = match.group(1)
+ break
+ return ifcfg_params