Add --env_vars option support for CLI for user env
Changes:
- added new option --env_vars
- added code to parse the env and load it
How to test: (Assuming YAML has this env var)
--env_vars '{"foo_name" : "value"}'
OEM:
- mycmd ${foo_name}
Change-Id: I001e6ee1105ab5d2a5ab06126b2039bdb1fb9e9a
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/ffdc/collect_ffdc.py b/ffdc/collect_ffdc.py
index e753857..730f830 100644
--- a/ffdc/collect_ffdc.py
+++ b/ffdc/collect_ffdc.py
@@ -38,10 +38,14 @@
show_default=True,
help="Select protocol (SSH, SCP, REDFISH) to communicate with remote host. \
Default: all available.")
+@click.option('-e', '--env_vars', show_default=True,
+ help="Environment variables as dictionary e.g: {'var':value}")
@click.option('--log_level', default="INFO",
show_default=True,
help="python logging level (CRITICAL, ERROR, WARNING, INFO, DEBUG)")
-def cli_ffdc(remote, username, password, ffdc_config, location, remote_type, remote_protocol, log_level):
+def cli_ffdc(remote, username, password,
+ ffdc_config, location, remote_type,
+ remote_protocol, env_vars, log_level):
r"""
Stand alone CLI to generate and collect FFDC from the selected target.
"""
@@ -50,15 +54,15 @@
if input_options_ok(remote, username, password, ffdc_config, remote_type):
thisFFDC = FFDCCollector(remote, username, password,
- ffdc_config, location,
- remote_type, remote_protocol, log_level)
+ ffdc_config, location, remote_type,
+ remote_protocol, env_vars, log_level)
thisFFDC.collect_ffdc()
if len(os.listdir(thisFFDC.ffdc_dir_path)) == 0:
click.echo("\n\tFFDC Collection from " + remote + " has failed.\n\n")
else:
click.echo(str("\n\t" + str(len(os.listdir(thisFFDC.ffdc_dir_path)))
- + " files were retrieved from " + remote))
+ + " files were retrieved from " + remote))
click.echo("\tFiles are stored in " + thisFFDC.ffdc_dir_path)
click.echo("\tTotal elapsed time " + thisFFDC.elapsed_time + "\n\n")