Browse Source

Constants path formatting unification

Paths in the constants.py are now formatted
using a single function, the os.path.join.

This both normalizes the code and reduces
chance of errors and confusion arising
from nonstandard paths.

Signed-off-by: Jiri Podivin <jpodivin@redhat.com>
Change-Id: I761c4449579590b9081a78627eeac754d6b04e2a
changes/31/790031/14
Jiri Podivin 3 months ago
parent
commit
a70ad12043
  1. 9
      validations_libs/constants.py
  2. 8
      validations_libs/utils.py

9
validations_libs/constants.py

@ -18,9 +18,12 @@ DEFAULT_VALIDATIONS_BASEDIR = '/usr/share/ansible/'
ANSIBLE_VALIDATION_DIR = '/usr/share/ansible/validation-playbooks'
VALIDATION_GROUPS_INFO = '%s/groups.yaml' % DEFAULT_VALIDATIONS_BASEDIR
VALIDATION_GROUPS_INFO = os.path.join(
DEFAULT_VALIDATIONS_BASEDIR,
'groups.yaml')
VALIDATIONS_LOG_BASEDIR = os.path.join(os.environ.get('HOME'), 'validations')
VALIDATION_ANSIBLE_ARTIFACT_PATH = '{}/artifacts/'.format(
VALIDATIONS_LOG_BASEDIR)
VALIDATION_ANSIBLE_ARTIFACT_PATH = os.path.join(
VALIDATIONS_LOG_BASEDIR,
'artifacts')

8
validations_libs/utils.py

@ -66,7 +66,7 @@ def create_artifacts_dir(log_path=constants.VALIDATIONS_LOG_BASEDIR,
:type log_path: `string`
:param prefix: Playbook name
:type prefix: `string`
:return: The UUID of the validation and the absolute Path of the log file
:return: The UUID of the validation and the absolute path of the log file
:rtype: `string`, `string`
"""
artifact_dir = os.path.join(log_path, 'artifacts')
@ -79,11 +79,13 @@ def create_artifacts_dir(log_path=constants.VALIDATIONS_LOG_BASEDIR,
except (OSError, PermissionError):
LOG.exception(
(
"Error while creating Ansible artifacts log file."
"Please check the access rights for {}"
"Error while creating Ansible artifacts directory. "
"Please check the access rights for: '{}'"
).format(log_dir)
)
raise RuntimeError()
def parse_all_validations_on_disk(path, groups=None):
"""Return a list of validations metadata which can be sorted by Groups

Loading…
Cancel
Save