Bailey Henry 92d5562f6d libvirt: Add configuration files for mad and default
yaml files for mad and default

Test plan:
    PASS: Create configuration files with all needed data
    PASS: Ensure all data is usable
    PASS: No Pylint/Bashate errors
    PASS: Regression test succeeded

Story: 2010816
Task: 48350

Change-Id: Id7a380a64348501396b139ebb57ff0f42825ffce
Signed-off-by: Bailey Henry <Henry.Bailey@windriver.com>
2023-07-18 14:46:57 +00:00

47 lines
1015 B
Python
Executable File

#!/usr/bin/python3
import sys
import yaml
def print_help():
print("./config.py <config_file> <key>",
file=sys.stderr)
def readvalue(config_file, key):
try:
with open(config_file, 'r', encoding="utf-8") as f:
data = yaml.load(f, Loader=yaml.Loader)
value = data[key]
print(value)
except yaml.YAMLError as e:
print('YAMLError: %s' % e, file=sys.stderr)
except KeyError as e:
print('KeyError: %s' % e, file=sys.stderr)
if __name__ == "__main__":
args = sys.argv[1:]
if '--help' in args:
print_help()
sys.exit(1)
if len(args) == 2:
input_file = args[0]
input_key = args[1]
readvalue(input_file, input_key)
elif len(args) < 2:
print("Error: missing required arguments.",
file=sys.stderr)
print_help()
sys.exit(1)
else:
print("Error: too many arguments.",
file=sys.stderr)
print_help()
sys.exit(1)