Checking inventory file presence and format
Unless the inventory consists of only localhost, we are going to check it's presence and formatting, before actually starting validations. Docstring of the 'read_cli_data_file' was expanded to provide more info. Signed-off-by: Jiri Podivin <jpodivin@redhat.com> Change-Id: I44a3081f64b169d874d1b790b9739ad13e556714
This commit is contained in:
parent
9163d8bcbc
commit
87cafc60f4
@ -104,6 +104,13 @@ def write_junitxml(output_junitxml, results):
|
||||
|
||||
def read_cli_data_file(data_file):
|
||||
"""Read CLI data (YAML/JSON) file.
|
||||
:param data_file: Path to the requested file.
|
||||
:type data_file: ``path like``
|
||||
|
||||
:returns: Parsed YAML/JSON file
|
||||
:rtype: ``dict``
|
||||
|
||||
:raises: RuntimeError if the file doesn't exist or is malformed.
|
||||
"""
|
||||
try:
|
||||
with open(data_file, 'r') as _file:
|
||||
|
@ -171,6 +171,14 @@ class Run(BaseCommand):
|
||||
# Get config:
|
||||
config = self.base.config
|
||||
|
||||
# Verify properties of inventory file, if it isn't just 'localhost'
|
||||
if parsed_args.inventory.startswith('localhost'):
|
||||
self.app.LOG.debug(
|
||||
"You are using inline inventory. '{}'".format(
|
||||
parsed_args.inventory))
|
||||
else:
|
||||
common.read_cli_data_file(parsed_args.inventory)
|
||||
|
||||
v_actions = ValidationActions(
|
||||
parsed_args.validation_dir, log_path=parsed_args.validation_log_dir)
|
||||
# Ansible execution should be quiet while using the validations_json
|
||||
|
Loading…
x
Reference in New Issue
Block a user