summaryrefslogtreecommitdiffstats
path: root/apex/common
diff options
context:
space:
mode:
authorFeng Pan <fpan@redhat.com>2017-09-13 18:25:34 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-09-13 18:25:34 +0000
commit7b3a8455baa35bdde4d7e078d88f9b17a6df9195 (patch)
tree0d0617382f42d30d4bb0a9a99248cb100006554c /apex/common
parent071de3a4a11326d5f0c371a2ebeed703f1a40980 (diff)
parentcb606f45e3852432787ed895dc55665caa950161 (diff)
Merge "Migrates clean to python"
Diffstat (limited to 'apex/common')
-rw-r--r--apex/common/exceptions.py8
-rw-r--r--apex/common/parsers.py25
2 files changed, 33 insertions, 0 deletions
diff --git a/apex/common/exceptions.py b/apex/common/exceptions.py
index c660213f..54d99834 100644
--- a/apex/common/exceptions.py
+++ b/apex/common/exceptions.py
@@ -10,3 +10,11 @@
class ApexDeployException(Exception):
pass
+
+
+class JumpHostNetworkException(Exception):
+ pass
+
+
+class ApexCleanException(Exception):
+ pass
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