fence-agents/SOURCES/bz1886074-1-fencing-source_...

18 lines
751 B
Diff

--- a/lib/fencing.py.py 2022-04-22 10:25:59.347139685 +0200
+++ b/lib/fencing.py.py 2022-04-22 10:26:05.127169492 +0200
@@ -1115,6 +1115,14 @@
except pexpect.ExceptionPexpect:
pass
+def source_env(env_file):
+ # POSIX: name shall not contain '=', value doesn't contain '\0'
+ output = subprocess.check_output("source {} && env -0".format(env_file), shell=True,
+ executable="/bin/sh")
+ # replace env
+ os.environ.clear()
+ os.environ.update(line.partition('=')[::2] for line in output.decode("utf-8").split('\0'))
+
# Convert array of format [[key1, value1], [key2, value2], ... [keyN, valueN]] to dict, where key is
# in format a.b.c.d...z and returned dict has key only z
def array_to_dict(array):