mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-05-14 21:42:17 +00:00
pylint: Fix pylint issues with modules.
Fix pylint warnings raised by enabling linter on ansible-freeipa roles.
This commit is contained in:
@@ -199,7 +199,9 @@ def main():
|
||||
|
||||
ansible_log.debug("-- CUSTODIA IMPORT DM PASSWORD --")
|
||||
|
||||
# pylint: disable=deprecated-method
|
||||
argspec = inspect.getargspec(custodia.import_dm_password)
|
||||
# pylint: enable=deprecated-method
|
||||
if "master_host_name" in argspec.args:
|
||||
custodia.import_dm_password(config.master_host_name)
|
||||
else:
|
||||
|
||||
@@ -56,8 +56,7 @@ from ansible.module_utils.ansible_ipa_replica import (
|
||||
|
||||
def main():
|
||||
ansible_module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
),
|
||||
argument_spec={},
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
|
||||
@@ -316,7 +316,9 @@ def main():
|
||||
ansible_log.debug("-- CONFIGURE DIRSRV --")
|
||||
# Configure dirsrv
|
||||
with redirect_stdout(ansible_log):
|
||||
# pylint: disable=deprecated-method
|
||||
argspec = inspect.getargspec(install_replica_ds)
|
||||
# pylint: enable=deprecated-method
|
||||
if "promote" in argspec.args:
|
||||
ds = install_replica_ds(config, options, ca_enabled,
|
||||
remote_api,
|
||||
@@ -336,9 +338,13 @@ def main():
|
||||
ca_file=cafile,
|
||||
pkcs12_info=dirsrv_pkcs12_info)
|
||||
|
||||
# pylint: disable=deprecated-method
|
||||
ansible_log.debug("-- INSTALL DNS RECORDS --")
|
||||
# pylint: enable=deprecated-method
|
||||
# Always try to install DNS records
|
||||
# pylint: disable=deprecated-method
|
||||
argspec = inspect.getargspec(install_dns_records)
|
||||
# pylint: enable=deprecated-method
|
||||
if "fstore" not in argspec.args:
|
||||
install_dns_records(config, options, remote_api)
|
||||
else:
|
||||
|
||||
@@ -202,7 +202,9 @@ def main():
|
||||
create_ipa_conf(fstore, config, ca_enabled,
|
||||
master=config.master_host_name)
|
||||
|
||||
# pylint: disable=deprecated-method
|
||||
argspec = inspect.getargspec(install_http)
|
||||
# pylint: enable=deprecated-method
|
||||
if "promote" in argspec.args:
|
||||
install_http(
|
||||
config,
|
||||
|
||||
@@ -161,7 +161,9 @@ def main():
|
||||
ansible_log.debug("-- INSTALL_KRB --")
|
||||
|
||||
with redirect_stdout(ansible_log):
|
||||
# pylint: disable=deprecated-method
|
||||
argspec = inspect.getargspec(install_krb)
|
||||
# pylint: enable=deprecated-method
|
||||
if "promote" in argspec.args:
|
||||
install_krb(
|
||||
config,
|
||||
|
||||
@@ -286,7 +286,9 @@ def main():
|
||||
# asks for HTTP certificate in newer ipa versions. In these versions
|
||||
# create_ipa_conf has the additional master argument.
|
||||
change_master_for_certmonger = False
|
||||
# pylint: disable=deprecated-method
|
||||
argspec = inspect.getargspec(create_ipa_conf)
|
||||
# pylint: enable=deprecated-method
|
||||
if "master" in argspec.args:
|
||||
change_master_for_certmonger = True
|
||||
|
||||
@@ -418,7 +420,9 @@ def main():
|
||||
# check selinux status, http and DS ports, NTP conflicting services
|
||||
try:
|
||||
with redirect_stdout(ansible_log):
|
||||
# pylint: disable=deprecated-method
|
||||
argspec = inspect.getargspec(common_check)
|
||||
# pylint: enable=deprecated-method
|
||||
if "skip_mem_check" in argspec.args:
|
||||
common_check(options.no_ntp, options.skip_mem_check,
|
||||
options.setup_ca)
|
||||
|
||||
@@ -138,15 +138,15 @@ else:
|
||||
|
||||
try:
|
||||
from ipaclient.install import timeconf
|
||||
time_service = "chronyd"
|
||||
ntpinstance = None
|
||||
time_service = "chronyd" # pylint: disable=invalid-name
|
||||
ntpinstance = None # pylint: disable=invalid-name
|
||||
except ImportError:
|
||||
try:
|
||||
from ipaclient.install import ntpconf as timeconf
|
||||
except ImportError:
|
||||
from ipaclient import ntpconf as timeconf
|
||||
from ipaserver.install import ntpinstance
|
||||
time_service = "ntpd"
|
||||
time_service = "ntpd" # pylint: disable=invalid-name
|
||||
|
||||
else:
|
||||
# IPA version < 4.6
|
||||
@@ -162,10 +162,10 @@ else:
|
||||
filemode='a', console_format='%(message)s')
|
||||
|
||||
@contextlib_contextmanager
|
||||
def redirect_stdout(f):
|
||||
sys.stdout = f
|
||||
def redirect_stdout(stream):
|
||||
sys.stdout = stream
|
||||
try:
|
||||
yield f
|
||||
yield stream
|
||||
finally:
|
||||
sys.stdout = sys.__stdout__
|
||||
|
||||
@@ -202,7 +202,8 @@ else:
|
||||
self.module.debug(msg)
|
||||
# self.module.warn(msg)
|
||||
|
||||
class installer_obj(object):
|
||||
# pylint: disable=too-many-instance-attributes, useless-object-inheritance
|
||||
class installer_obj(object): # pylint: disable=invalid-name
|
||||
def __init__(self):
|
||||
# CompatServerReplicaInstall
|
||||
self.ca_cert_files = None
|
||||
@@ -244,10 +245,10 @@ else:
|
||||
# (attr, repr(value)))
|
||||
# return value
|
||||
|
||||
def __getattr__(self, attr):
|
||||
logger.info(" --> ADDING missing installer.%s", attr)
|
||||
setattr(self, attr, None)
|
||||
return getattr(self, attr)
|
||||
def __getattr__(self, attrname):
|
||||
logger.info(" --> ADDING missing installer.%s", attrname)
|
||||
setattr(self, attrname, None)
|
||||
return getattr(self, attrname)
|
||||
|
||||
# def __setattr__(self, attr, value):
|
||||
# logger.debug(" --> Setting installer.%s to %s" %
|
||||
@@ -258,6 +259,9 @@ else:
|
||||
for name in self.__dict__:
|
||||
yield self, name
|
||||
|
||||
# pylint: enable=too-many-instance-attributes, useless-object-inheritance
|
||||
|
||||
# pylint: disable=attribute-defined-outside-init
|
||||
installer = installer_obj()
|
||||
options = installer
|
||||
|
||||
@@ -274,6 +278,7 @@ else:
|
||||
# ServerReplicaInstall
|
||||
options.subject_base = None
|
||||
options.ca_subject = None
|
||||
# pylint: enable=attribute-defined-outside-init
|
||||
|
||||
def gen_env_boostrap_finalize_core(etc_ipa, default_config):
|
||||
env = Env()
|
||||
@@ -295,9 +300,12 @@ else:
|
||||
# pylint: enable=no-member
|
||||
api.finalize()
|
||||
|
||||
def gen_ReplicaConfig():
|
||||
def gen_ReplicaConfig(): # pylint: disable=invalid-name
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
class ExtendedReplicaConfig(ReplicaConfig):
|
||||
# pylint: disable=useless-super-delegation
|
||||
def __init__(self, top_dir=None):
|
||||
# pylint: disable=super-with-arguments
|
||||
super(ExtendedReplicaConfig, self).__init__(top_dir)
|
||||
|
||||
# def __getattribute__(self, attr):
|
||||
@@ -306,12 +314,13 @@ else:
|
||||
# if attr not in ["__dict__", "knobs"]:
|
||||
# logger.debug(" <== Accessing config.%s (%s)" %
|
||||
# (attr, repr(value)))
|
||||
# return value
|
||||
# return value\
|
||||
# pylint: enable=useless-super-delegation
|
||||
|
||||
def __getattr__(self, attr):
|
||||
logger.info(" ==> ADDING missing config.%s", attr)
|
||||
setattr(self, attr, None)
|
||||
return getattr(self, attr)
|
||||
def __getattr__(self, attrname):
|
||||
logger.info(" ==> ADDING missing config.%s", attrname)
|
||||
setattr(self, attrname, None)
|
||||
return getattr(self, attrname)
|
||||
|
||||
# def __setattr__(self, attr, value):
|
||||
# logger.debug(" ==> Setting config.%s to %s" %
|
||||
@@ -322,7 +331,9 @@ else:
|
||||
def knobs(self):
|
||||
for name in self.__dict__:
|
||||
yield self, name
|
||||
# pylint: enable=too-many-instance-attributes
|
||||
|
||||
# pylint: disable=attribute-defined-outside-init
|
||||
# config = ReplicaConfig()
|
||||
config = ExtendedReplicaConfig()
|
||||
config.realm_name = api.env.realm
|
||||
@@ -338,10 +349,12 @@ else:
|
||||
config.basedn = api.env.basedn
|
||||
# config.subject_base = options.subject_base
|
||||
|
||||
# pylint: enable=attribute-defined-outside-init
|
||||
|
||||
return config
|
||||
|
||||
def replica_ds_init_info(ansible_log,
|
||||
config, options, ca_is_configured, remote_api,
|
||||
config, options_, ca_is_configured, remote_api,
|
||||
ds_ca_subject, ca_file,
|
||||
promote=False, pkcs12_info=None):
|
||||
|
||||
@@ -364,7 +377,7 @@ else:
|
||||
ca_subject = ds_ca_subject
|
||||
|
||||
ds = dsinstance.DsInstance(
|
||||
config_ldif=options.dirsrv_config_file)
|
||||
config_ldif=options_.dirsrv_config_file)
|
||||
ds.set_output(ansible_log)
|
||||
|
||||
# Source: ipaserver/install/dsinstance.py
|
||||
|
||||
Reference in New Issue
Block a user