Merge "Get validation groups info from groups.yaml file"
This commit is contained in:
commit
735acf94e3
@ -94,16 +94,6 @@ ANSIBLE_TRIPLEO_PLAYBOOKS = \
|
||||
|
||||
VALIDATION_GROUPS_INFO = '%s/groups.yaml' % DEFAULT_VALIDATIONS_BASEDIR
|
||||
|
||||
VALIDATION_GROUPS = ['no-op',
|
||||
'openshift-on-openstack',
|
||||
'prep',
|
||||
'pre-introspection',
|
||||
'pre-deployment',
|
||||
'post-deployment',
|
||||
'pre-upgrade',
|
||||
'post-upgrade']
|
||||
|
||||
|
||||
# ctlplane network defaults
|
||||
CTLPLANE_CIDR_DEFAULT = '192.168.24.0/24'
|
||||
CTLPLANE_DHCP_START_DEFAULT = ['192.168.24.5']
|
||||
|
@ -151,7 +151,7 @@ class TestValidatorGroupInfo(utils.TestCommand):
|
||||
# Get the command object to test
|
||||
self.cmd = tripleo_validator.TripleOValidatorGroupInfo(self.app, None)
|
||||
|
||||
@mock.patch('tripleoclient.utils.parse_all_validation_groups_on_disk',
|
||||
@mock.patch('tripleoclient.utils.prepare_validation_groups_for_display',
|
||||
return_value=GROUPS_LIST)
|
||||
def test_show_group_info(self, mock_validations):
|
||||
arglist = []
|
||||
|
@ -2148,19 +2148,38 @@ def get_validation_parameters(validation):
|
||||
return dict()
|
||||
|
||||
|
||||
def parse_all_validation_groups_on_disk(groups_file_path=None):
|
||||
results = []
|
||||
|
||||
def read_validation_groups_file(groups_file_path=None):
|
||||
"""Load groups.yaml file and return a dictionary with its contents"""
|
||||
if not groups_file_path:
|
||||
groups_file_path = constants.VALIDATION_GROUPS_INFO
|
||||
|
||||
if not os.path.exists(groups_file_path):
|
||||
return results
|
||||
return []
|
||||
|
||||
with open(groups_file_path, 'r') as grps:
|
||||
contents = yaml.safe_load(grps)
|
||||
|
||||
for grp_name, grp_desc in sorted(contents.items()):
|
||||
return contents
|
||||
|
||||
|
||||
def get_validation_group_name_list():
|
||||
"""Get the validation group name list only"""
|
||||
results = []
|
||||
|
||||
groups = read_validation_groups_file()
|
||||
|
||||
if groups and isinstance(dict, groups):
|
||||
for grp_name in six.viewkeys(groups):
|
||||
results.append(grp_name)
|
||||
|
||||
return results
|
||||
|
||||
|
||||
def prepare_validation_groups_for_display():
|
||||
results = []
|
||||
groups = read_validation_groups_file()
|
||||
|
||||
for grp_name, grp_desc in sorted(groups.items()):
|
||||
results.append((grp_name, grp_desc[0].get('description')))
|
||||
|
||||
return results
|
||||
|
@ -39,10 +39,12 @@ RESET = "\033[0;0m"
|
||||
FAILED_VALIDATION = "{}FAILED{}".format(RED, RESET)
|
||||
PASSED_VALIDATION = "{}PASSED{}".format(GREEN, RESET)
|
||||
|
||||
GROUP_FILE = constants.VALIDATION_GROUPS_INFO
|
||||
|
||||
|
||||
class _CommaListGroupAction(argparse.Action):
|
||||
def __call__(self, parser, namespace, values, option_string=None):
|
||||
opts = constants.VALIDATION_GROUPS
|
||||
opts = oooutils.get_validation_group_name_list()
|
||||
for value in values.split(','):
|
||||
if value not in opts:
|
||||
message = ("Invalid choice: {value} (choose from {choice})"
|
||||
@ -65,12 +67,11 @@ class TripleOValidatorGroupInfo(command.Lister):
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
group_file = constants.VALIDATION_GROUPS_INFO
|
||||
group = oooutils.parse_all_validation_groups_on_disk(group_file)
|
||||
group = oooutils.prepare_validation_groups_for_display()
|
||||
|
||||
if not group:
|
||||
raise exceptions.CommandError(
|
||||
"Could not find groups information file %s" % group_file)
|
||||
"Could not find groups information file %s" % GROUP_FILE)
|
||||
|
||||
group_info = []
|
||||
for gp in group:
|
||||
@ -444,7 +445,7 @@ class TripleOValidatorRun(command.Command):
|
||||
|
||||
else:
|
||||
for pb in parsed_args.validation_name:
|
||||
if pb not in constants.VALIDATION_GROUPS:
|
||||
if pb not in oooutils.get_validation_group_name_list():
|
||||
playbooks.append(pb + '.yaml')
|
||||
else:
|
||||
raise exceptions.CommandError(
|
||||
|
Loading…
Reference in New Issue
Block a user