validations_libs.validation_logs module¶
- class validations_libs.validation_logs.ValidationLog(uuid=None, validation_id=None, logfile=None, log_path='/home/zuul/src/opendev.org/openstack/validations-libs/.tox/docs/validations', extension='json')[source]¶
Bases:
objectAn object for encapsulating a Validation Log file
- property get_duration¶
Return duration of Ansible runtime
- Return type
string
- property get_host_group¶
Return host group
- Returns
A comma-separated list of host(s)
- Return type
string
- property get_hosts_status¶
Return status by host(s)
- Returns
A comma-separated string of host with its status
- Return type
string- Example
>>> logfile = '/tmp/123_foo_2020-03-30T13:17:22.447857Z.json' >>> val = ValidationLog(logfile=logfile) >>> print(val.get_hosts_status) 'localhost,PASSED, webserver1,FAILED, webserver2,PASSED'
- property get_logfile_content¶
Return logfile content
- Return type
dict
- property get_logfile_datetime¶
Return log file datetime from a UUID and a validation ID
- Returns
The datetime of the log file
- Return type
list- Example
>>> logfile = '/tmp/123_foo_2020-03-30T13:17:22.447857Z.json' >>> val = ValidationLog(logfile=logfile) >>> print(val.get_logfile_datetime) ['2020-03-30T13:17:22.447857Z']
- property get_logfile_infos¶
Return log file information from the log file basename
- Returns
A list with the UUID, the validation name and the datetime of the log file
- Return type
list- Example
>>> logfile = '/tmp/123_foo_2020-03-30T13:17:22.447857Z.json' >>> val = ValidationLog(logfile=logfile) >>> print(val.get_logfile_infos) ['123', 'foo', '2020-03-30T13:17:22.447857Z']
- property get_plays¶
Return a list of Playbook data
- property get_start_time¶
Return Ansible start time
- Return type
string
- property get_status¶
Return validation status
- Returns
‘FAILED’ if there is failure(s), ‘PASSED’ if not. If no tasks have been executed, it returns ‘NOT_RUN’.
- Return type
string
- property get_tasks_data¶
Return a list of task from validation output
- property get_unreachable_hosts¶
Return unreachable hosts
- Returns
A list of unreachable host(s)
- Return type
string- Example
Multiple unreachable hosts
>>> logfile = '/tmp/123_foo_2020-03-30T13:17:22.447857Z.json' >>> val = ValidationLog(logfile=logfile) >>> print(val.get_unreachable_hosts) 'localhost, webserver2'
Only one unreachable host
>>> logfile = '/tmp/123_foo_2020-03-30T13:17:22.447857Z.json' >>> val = ValidationLog(logfile=logfile) >>> print(val.get_unreachable_hosts) 'localhost'
No unreachable host
>>> logfile = '/tmp/123_foo_2020-03-30T13:17:22.447857Z.json' >>> val = ValidationLog(logfile=logfile) >>> print(val.get_unreachable_hosts) ''
- property get_uuid¶
Return log uuid
- Return type
string
- property get_validation_id¶
Return validation id
- Return type
string
- is_valid_format()[source]¶
Return True if the log file is a valid validation format
The validation log file has to contain three level of data.
playswill contain the Ansible execution logs of the playbooksstatwill contain the statistics for each targeted hostsvalidation_outputwill contain only the warning or failed tasks
{ 'plays': [], 'stats': {}, 'validation_output': [] }
- Returns
Trueif the log file is valid,Falseif not.- Return type
boolean
- class validations_libs.validation_logs.ValidationLogs(logs_path='/home/zuul/src/opendev.org/openstack/validations-libs/.tox/docs/validations')[source]¶
Bases:
objectAn object for encapsulating the Validation Log files
- get_all_logfiles(extension='json')[source]¶
Return logfiles from logs_path
- Parameters
extension (
string) – The extension file (Defaults to ‘json’)- Returns
A list of the absolute path log files
- Return type
list
- get_all_logfiles_content()[source]¶
Return logfiles content
- Returns
A list of the contents of every log files available
- Return type
list
- get_logfile_by_uuid(uuid)[source]¶
Return logfiles by uuid
- Parameters
uuid (
string) – The UUID of the validation execution- Returns
The list of the log files by UUID
- Return type
list
- get_logfile_by_uuid_validation_id(uuid, validation_id)[source]¶
Return logfiles by uuid and validation_id
- Parameters
uuid (
string) – The UUID of the validation executionvalidation_id (
string) – The ID of the validation
- Returns
A list of the log files by UUID and validation_id
- Return type
list
- get_logfile_by_validation(validation_id)[source]¶
Return logfiles by validation_id
- Parameters
validation_id (
string) – The ID of the validation- Returns
The list of the log files for a validation
- Return type
list
- get_logfile_content_by_uuid(uuid)[source]¶
Return logfiles content by uuid
- Parameters
uuid (
string) – The UUID of the validation execution- Returns
The list of the log files contents by UUID
- Return type
list
- get_logfile_content_by_uuid_validation_id(uuid, validation_id)[source]¶
Return logfiles content filter by uuid and validation_id
- Parameters
uuid (
string) – The UUID of the validation executionvalidation_id (
string) – The ID of the validation
- Returns
A list of the log files content by UUID and validation_id
- Return type
list
- get_logfile_content_by_validation(validation_id)[source]¶
Return logfiles content by validation_id
- Parameters
validation_id (
string) – The ID of the validation- Returns
The list of the log files contents for a validation
- Return type
list
- get_results(uuid, validation_id=None)[source]¶
Return a list of validation results by uuid Can be filter by validation_id
- Parameters
uuid (
string` or ``list) – The UUID of the validation executionvalidation_id (
string) – The ID of the validation
- Returns
A list of the log files content by UUID and validation_id
- Return type
list- Example
>>> v_logs = ValidationLogs() >>> uuid = '78df1c3f-dfc3-4a1f-929e-f51762e67700' >>> print(v_logs.get_results(uuid=uuid) [{'Duration': '0:00:00.514', 'Host_Group': 'undercloud,Controller', 'Status': 'FAILED', 'Status_by_Host': 'undercloud,FAILED, underclou1d,FAILED', 'UUID': '78df1c3f-dfc3-4a1f-929e-f51762e67700', 'Unreachable_Hosts': 'undercloud', 'Validations': 'check-cpu'}]