Fix community init to respect cfg paths
The validation init did not respect the paths set on the config file. Now it does. Resolves: rhbz#2031069 Change-Id: Ia492b53f170d65f712a182a545ef09217449648c
This commit is contained in:
parent
eb5c38ee62
commit
1c89a4d7ce
@ -15,6 +15,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
|
||||||
from validations_libs import constants, utils
|
from validations_libs import constants, utils
|
||||||
from validations_libs.cli.base import BaseCommand
|
from validations_libs.cli.base import BaseCommand
|
||||||
@ -49,6 +50,15 @@ class CommunityValidationInit(BaseCommand):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument('--validation-dir', dest='validation_dir',
|
||||||
|
default=constants.ANSIBLE_VALIDATION_DIR,
|
||||||
|
help=("Path where the validation playbooks "
|
||||||
|
"is located."))
|
||||||
|
|
||||||
|
parser.add_argument('--ansible-base-dir', dest='ansible_base_dir',
|
||||||
|
default=constants.DEFAULT_VALIDATIONS_BASEDIR,
|
||||||
|
help=("Path where the ansible roles, library "
|
||||||
|
"and plugins are located."))
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
@ -56,7 +66,10 @@ class CommunityValidationInit(BaseCommand):
|
|||||||
# Merge config and CLI args:
|
# Merge config and CLI args:
|
||||||
self.base.set_argument_parser(self, parsed_args)
|
self.base.set_argument_parser(self, parsed_args)
|
||||||
|
|
||||||
co_validation = com_val(parsed_args.validation_name)
|
co_validation = com_val(
|
||||||
|
parsed_args.validation_name,
|
||||||
|
validation_dir=parsed_args.validation_dir,
|
||||||
|
ansible_base_dir=parsed_args.ansible_base_dir)
|
||||||
|
|
||||||
if co_validation.is_community_validations_enabled(self.base.config):
|
if co_validation.is_community_validations_enabled(self.base.config):
|
||||||
LOG.debug(
|
LOG.debug(
|
||||||
@ -79,7 +92,7 @@ class CommunityValidationInit(BaseCommand):
|
|||||||
.format(
|
.format(
|
||||||
co_validation.role_name,
|
co_validation.role_name,
|
||||||
constants.COMMUNITY_ROLES_DIR,
|
constants.COMMUNITY_ROLES_DIR,
|
||||||
constants.ANSIBLE_ROLES_DIR)
|
os.path.join(parsed_args.ansible_base_dir, "roles/"))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -93,7 +106,7 @@ class CommunityValidationInit(BaseCommand):
|
|||||||
.format(
|
.format(
|
||||||
co_validation.playbook_name,
|
co_validation.playbook_name,
|
||||||
constants.COMMUNITY_PLAYBOOKS_DIR,
|
constants.COMMUNITY_PLAYBOOKS_DIR,
|
||||||
constants.ANSIBLE_VALIDATION_DIR)
|
parsed_args.validation_dir)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
import os
|
||||||
# @matbu backward compatibility for stable/train
|
# @matbu backward compatibility for stable/train
|
||||||
try:
|
try:
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@ -35,9 +36,16 @@ class CommunityValidation:
|
|||||||
from a template.
|
from a template.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, validation_name):
|
def __init__(
|
||||||
|
self,
|
||||||
|
validation_name,
|
||||||
|
validation_dir=constants.ANSIBLE_VALIDATION_DIR,
|
||||||
|
ansible_base_dir=constants.DEFAULT_VALIDATIONS_BASEDIR):
|
||||||
"""Construct Role and Playbook."""
|
"""Construct Role and Playbook."""
|
||||||
|
|
||||||
self._validation_name = validation_name
|
self._validation_name = validation_name
|
||||||
|
self.validation_dir = validation_dir
|
||||||
|
self.ansible_base_dir = ansible_base_dir
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
"""Execute the actions necessary to create a new community validation
|
"""Execute the actions necessary to create a new community validation
|
||||||
@ -106,11 +114,12 @@ class CommunityValidation:
|
|||||||
|
|
||||||
:rtype: ``Boolean``
|
:rtype: ``Boolean``
|
||||||
"""
|
"""
|
||||||
|
roles_dir = os.path.join(self.ansible_base_dir, "roles/")
|
||||||
non_community_roles = []
|
non_community_roles = []
|
||||||
if Path(constants.ANSIBLE_ROLES_DIR).exists():
|
if Path(roles_dir).exists():
|
||||||
non_community_roles = [
|
non_community_roles = [
|
||||||
Path(x).name
|
Path(x).name
|
||||||
for x in Path(constants.ANSIBLE_ROLES_DIR).iterdir()
|
for x in Path(roles_dir).iterdir()
|
||||||
if x.is_dir()
|
if x.is_dir()
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -131,10 +140,10 @@ class CommunityValidation:
|
|||||||
:rtype: ``Boolean``
|
:rtype: ``Boolean``
|
||||||
"""
|
"""
|
||||||
non_community_playbooks = []
|
non_community_playbooks = []
|
||||||
if Path(constants.ANSIBLE_VALIDATION_DIR).exists():
|
if Path(self.validation_dir).exists():
|
||||||
non_community_playbooks = [
|
non_community_playbooks = [
|
||||||
Path(x).name
|
Path(x).name
|
||||||
for x in Path(constants.ANSIBLE_VALIDATION_DIR).iterdir()
|
for x in Path(self.validation_dir).iterdir()
|
||||||
if x.is_file()
|
if x.is_file()
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user