Implement Validation Show Parameters

Change-Id: Ie3366f4f32dd87871315cc9f95f7c2335df25e4b
This commit is contained in:
Mathieu Bultel 2020-03-19 00:22:15 +01:00 committed by Gael Chamoulaud
parent 491a27b53c
commit fd95a175b7
3 changed files with 26 additions and 3 deletions

View File

@ -165,3 +165,16 @@ def get_validations_stats(log):
"Failed: {}".format(total_number, "Failed: {}".format(total_number,
passed_number, passed_number,
failed_number)} failed_number)}
def get_validations_parameters(validations_data, validation_name=[],
groups=[]):
params = {}
for val in validations_data['validations']:
v = Validation(val)
if v.id in validation_name or set(groups).intersection(v.groups):
params[v.id] = {
'parameters': (val.get('metadata') if val.get('metadata') else
val.get('parameters'))
}
return params

View File

@ -35,8 +35,9 @@ class Validation(object):
@property @property
def get_metadata(self): def get_metadata(self):
if self.dict['vars'].get('metadata'):
self.metadata = {'id': self.id} self.metadata = {'id': self.id}
self.metadata.update(self.dict['vars']['metadata']) self.metadata.update(self.dict['vars'].get('metadata'))
return self.metadata return self.metadata
@property @property
@ -52,7 +53,7 @@ class Validation(object):
@property @property
def groups(self): def groups(self):
return self.dict['vars']['metadata']['groups'] return self.dict['vars']['metadata'].get('groups')
@property @property
def get_id(self): def get_id(self):

View File

@ -136,3 +136,12 @@ class ValidationActions(object):
group_info.append((gp[0], gp[1], len(validations))) group_info.append((gp[0], gp[1], len(validations)))
column_name = ("Groups", "Description", "Number of Validations") column_name = ("Groups", "Description", "Number of Validations")
return (column_name, group_info) return (column_name, group_info)
def show_validations_parameters(self, validation, group=None):
"""Return Validations Parameters"""
validations = v_utils.parse_all_validations_on_disk(
constants.ANSIBLE_VALIDATION_DIR)
return v_utils.get_validations_parameters({'validations': validations},
validation,
group)