1
0
mirror of https://github.com/oVirt/ovirt-ansible-disaster-recovery.git synced 2026-02-05 15:46:40 +01:00

CI: fixing CI errors (pylint)

Fixing various pylint issues:
- Misplaced "__future__" import.
- String "format()" should have indices for parameters.
- Using "sys.exit()" instead of "exit()".

The following errors were fixed:
  [2020-10-11T14:03:52.304Z] Running sanity test 'pylint' with Python 3.6
  [2020-10-11T14:05:00.632Z] ERROR: Found 14 pylint issue(s) which need to be resolved:
  [2020-10-11T14:05:00.632Z] ERROR: roles/disaster_recovery/callback_plugins/stdout.py:6:0: misplaced-future: __future__ import is not the first non docstring statement
  [2020-10-11T14:05:00.632Z] ERROR: roles/disaster_recovery/files/fail_back.py:81:20: ansible-format-automatic-specification: Format string contains automatic field numbering specification
  [2020-10-11T14:05:00.632Z] ERROR: roles/disaster_recovery/files/fail_back.py:93:20: ansible-format-automatic-specification: Format string contains automatic field numbering specification
  [2020-10-11T14:05:00.632Z] ERROR: roles/disaster_recovery/files/fail_back.py:98:20: ansible-format-automatic-specification: Format string contains automatic field numbering specification
  [2020-10-11T14:05:00.632Z] ERROR: roles/disaster_recovery/files/fail_back.py:154:12: consider-using-sys-exit: Consider using sys.exit()
  [2020-10-11T14:05:00.632Z] ERROR: roles/disaster_recovery/files/fail_over.py:113:12: consider-using-sys-exit: Consider using sys.exit()
  [2020-10-11T14:05:00.632Z] ERROR: roles/disaster_recovery/files/generate_vars.py:54:12: consider-using-sys-exit: Consider using sys.exit()
  [2020-10-11T14:05:00.632Z] ERROR: roles/disaster_recovery/files/generate_vars.py:55:21: ansible-format-automatic-specification: Format string contains automatic field numbering specification
  [2020-10-11T14:05:00.632Z] ERROR: roles/disaster_recovery/files/generate_vars.py:72:12: consider-using-sys-exit: Consider using sys.exit()
  [2020-10-11T14:05:00.632Z] ERROR: roles/disaster_recovery/files/validator.py:65:12: consider-using-sys-exit: Consider using sys.exit()
  [2020-10-11T14:05:00.633Z] ERROR: roles/disaster_recovery/files/validator.py:69:12: consider-using-sys-exit: Consider using sys.exit()
  [2020-10-11T14:05:00.633Z] ERROR: roles/disaster_recovery/files/validator.py:73:12: consider-using-sys-exit: Consider using sys.exit()
  [2020-10-11T14:05:00.633Z] ERROR: roles/disaster_recovery/files/validator.py:567:16: consider-using-sys-exit: Consider using sys.exit()
  [2020-10-11T14:05:00.633Z] ERROR: roles/disaster_recovery/files/validator.py:594:16: consider-using-sys-exit: Consider using sys.exit()
  [2020-10-11T14:05:00.633Z] See documentation for help: https://docs.ansible.com/ansible/2.9/dev_guide/testing/sanity/pylint.html

Signed-off-by: Pavel Bar <pbar@redhat.com>
This commit is contained in:
Pavel Bar
2020-10-11 20:16:32 +03:00
parent d142e97ea7
commit 2bd0754b0d
5 changed files with 20 additions and 20 deletions

View File

@@ -1,12 +1,11 @@
from datetime import datetime
#!/usr/bin/python3
from ansible.plugins.callback import CallbackBase
# Make coding more python3-ish, this is required for contributions to Ansible
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
# not only visible to ansible-doc, it also 'declares' the options the plugin
from ansible.plugins.callback import CallbackBase
# Not only visible to ansible-doc, it also 'declares' the options the plugin
# requires and how to configure them.
DOCUMENTATION = '''
callback: stdout
@@ -20,7 +19,7 @@ DOCUMENTATION = '''
class CallbackModule(CallbackBase):
"""
This callback module output the inforamtion with a specific style.
This callback module output the information with a specific style.
"""
CALLBACK_VERSION = 2.0
CALLBACK_TYPE = 'aggregate'

View File

@@ -78,7 +78,7 @@ class FailBack:
vault_pass = input(INPUT + PREFIX + vault_pass_msg + END)
os.system("export vault_password=\"" + vault_pass + "\"")
info_msg = ("Starting cleanup process of setup '{}' for "
info_msg = ("Starting cleanup process of setup '{0}' for "
"oVirt ansible disaster recovery".format(target_host))
log.info(info_msg)
print("\n%s%s%s%s" % (INFO, PREFIX, info_msg, END))
@@ -90,13 +90,13 @@ class FailBack:
else:
self._log_to_console(command_cleanup, log)
info_msg = ("Finished cleanup of setup '{}' "
info_msg = ("Finished cleanup of setup '{0}' "
"for oVirt ansible disaster recovery".format(source_map))
log.info(info_msg)
print("\n%s%s%s%s" % (INFO, PREFIX, info_msg, END))
info_msg = ("Starting failback process to setup '{}' from setup '{}' "
"for oVirt ansible disaster recovery"
info_msg = ("Starting failback process to setup '{0}' "
"from setup '{1}' for oVirt ansible disaster recovery"
.format(target_host, source_map))
log.info(info_msg)
print("\n%s%s%s%s" % (INFO, PREFIX, info_msg, END))
@@ -151,7 +151,7 @@ class FailBack:
"failback operation failed, please check log file for "
"further details.%s"
% (FAIL, e, END))
exit()
sys.exit()
def _init_vars(self, conf_file):
""" Declare constants """

View File

@@ -110,7 +110,7 @@ class FailOver:
"failover operation failed, please check log file for "
"further details.%s"
% (FAIL, e, END))
exit()
sys.exit()
def _init_vars(self, conf_file):
""" Declare constants """

View File

@@ -50,8 +50,8 @@ class GenerateMappingFile:
password,
ca_file):
self._print_error(log)
exit()
extra_vars = "site={} username={} password={} ca={} var_file={}".\
sys.exit()
extra_vars = "site={0} username={1} password={2} ca={3} var_file={4}".\
format(site, username, password, ca_file, var_file_path)
command = [
"ansible-playbook", ansible_play,
@@ -68,7 +68,7 @@ class GenerateMappingFile:
if not os.path.isfile(var_file_path):
log.error("Can not find output file in '%s'.", var_file_path)
self._print_error(log)
exit()
sys.exit()
log.info("Var file location: '%s'", var_file_path)
self._print_success(log)

View File

@@ -4,6 +4,7 @@ from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import os
import sys
import yaml
import ovirtsdk4 as sdk
@@ -61,15 +62,15 @@ class ValidateMappingFile:
or not self._entity_validator(python_vars)
or not self._validate_failback_leftovers()):
self._print_finish_error()
exit()
sys.exit()
if not self._validate_hosted_engine(python_vars):
self._print_finish_error()
exit()
sys.exit()
if not self._validate_export_domain(python_vars):
self._print_finish_error()
exit()
sys.exit()
self._print_finish_success()
def _validate_lists_in_mapping_file(self, mapping_vars):
@@ -542,7 +543,7 @@ class ValidateMappingFile:
x[key1_a],
x[key1_b],
END))
exit()
sys.exit()
primary_dc_name = ''
if key1_c in x:
primary_dc_name = x[key1_c]
@@ -569,7 +570,7 @@ class ValidateMappingFile:
val1_b,
x[val1_b],
END))
exit()
sys.exit()
secondary_dc_name = ''
if val1_c in x:
secondary_dc_name = x[val1_c]