Merge pull request #708 from rjeffman/pylint_enable_roles

Enable pylint for ansible-freeipa roles.
This commit is contained in:
Thomas Woerner
2022-01-13 13:42:16 +01:00
committed by GitHub
21 changed files with 133 additions and 66 deletions

View File

@@ -69,7 +69,7 @@ jobs:
- name: Run pylint - name: Run pylint
run: | run: |
pip install pylint==2.10.2 pip install pylint==2.10.2
pylint plugins --disable=import-error pylint plugins roles --disable=import-error
shellcheck: shellcheck:
name: Shellcheck name: Shellcheck

View File

@@ -61,7 +61,7 @@ from ipaplatform.paths import paths
def main(): def main():
module = AnsibleModule( module = AnsibleModule(
argument_spec=dict(), argument_spec={},
supports_check_mode=True, supports_check_mode=True,
) )

View File

@@ -45,12 +45,14 @@ def run_cmd(args, stdin=None):
if stdin: if stdin:
p_in = subprocess.PIPE p_in = subprocess.PIPE
p = subprocess.Popen(args, stdin=p_in, stdout=p_out, stderr=p_err, # pylint: disable=invalid-name
close_fds=True) with subprocess.Popen(
__temp, stderr = p.communicate(stdin) args, stdin=p_in, stdout=p_out, stderr=p_err, close_fds=True
) as p:
__temp, stderr = p.communicate(stdin)
if p.returncode != 0: if p.returncode != 0:
raise RuntimeError(stderr) raise RuntimeError(stderr)
def kinit_password(principal, password, ccache_name, config): def kinit_password(principal, password, ccache_name, config):
@@ -128,8 +130,9 @@ KRB5CONF_TEMPLATE = """
""" """
class ActionModule(ActionBase): class ActionModule(ActionBase): # pylint: disable=too-few-public-methods
# pylint: disable=too-many-return-statements
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
""" """
Handle credential cache transfer. Handle credential cache transfer.
@@ -149,8 +152,9 @@ class ActionModule(ActionBase):
Then the IPA commands can use this credential cache file. Then the IPA commands can use this credential cache file.
""" """
if task_vars is None: if task_vars is None:
task_vars = dict() task_vars = {}
# pylint: disable=super-with-arguments
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
principal = self._task.args.get('principal', None) principal = self._task.args.get('principal', None)
keytab = self._task.args.get('keytab', None) keytab = self._task.args.get('keytab', None)
@@ -168,7 +172,7 @@ class ActionModule(ActionBase):
return result return result
data = self._execute_module(module_name='ipaclient_get_facts', data = self._execute_module(module_name='ipaclient_get_facts',
module_args=dict(), task_vars=task_vars) module_args={}, task_vars=task_vars)
try: try:
domain = data['ansible_facts']['ipa']['domain'] domain = data['ansible_facts']['ipa']['domain']
@@ -195,7 +199,7 @@ class ActionModule(ActionBase):
ipa_realm=realm, ipa_realm=realm,
ipa_lifetime=lifetime)) ipa_lifetime=lifetime))
with open(krb5conf_name, 'w') as f: with open(krb5conf_name, 'w') as f: # pylint: disable=invalid-name
f.write(content) f.write(content)
if password: if password:

View File

@@ -133,7 +133,9 @@ def main():
# Add CA certs to a temporary NSS database # Add CA certs to a temporary NSS database
try: try:
# pylint: disable=deprecated-method
argspec = inspect.getargspec(tmp_db.create_db) argspec = inspect.getargspec(tmp_db.create_db)
# pylint: enable=deprecated-method
if "password_filename" not in argspec.args: if "password_filename" not in argspec.args:
tmp_db.create_db() tmp_db.create_db()
else: else:
@@ -181,7 +183,7 @@ def main():
module.warn( module.warn(
"Some capabilities including the ipa command capability " "Some capabilities including the ipa command capability "
"may not be available") "may not be available")
except errors.PublicError as e2: except errors.PublicError as e2: # pylint: disable=invalid-name
module.fail_json( module.fail_json(
msg="Cannot connect to the IPA server RPC interface: " msg="Cannot connect to the IPA server RPC interface: "
"%s" % e2) "%s" % e2)

View File

@@ -56,10 +56,12 @@ def is_ntpd_configured():
ntpd_conf_section = re.compile(r'^\s*\[ntpd\]\s*$') ntpd_conf_section = re.compile(r'^\s*\[ntpd\]\s*$')
try: try:
# pylint: disable=invalid-name
with open(SERVER_SYSRESTORE_STATE) as f: with open(SERVER_SYSRESTORE_STATE) as f:
for line in f.readlines(): for line in f.readlines():
if ntpd_conf_section.match(line): if ntpd_conf_section.match(line):
return True return True
# pylint: enable=invalid-name
return False return False
except IOError: except IOError:
return False return False
@@ -71,7 +73,7 @@ def is_dns_configured():
bind_conf_section = re.compile(r'^\s*dyndb\s+"ipa"\s+"[^"]+"\s+{$') bind_conf_section = re.compile(r'^\s*dyndb\s+"ipa"\s+"[^"]+"\s+{$')
try: try:
with open(NAMED_CONF) as f: with open(NAMED_CONF) as f: # pylint: disable=invalid-name
for line in f.readlines(): for line in f.readlines():
if bind_conf_section.match(line): if bind_conf_section.match(line):
return True return True
@@ -103,7 +105,7 @@ def is_client_configured():
# and /var/lib/ipa-client/sysrestore/sysrestore.state exists # and /var/lib/ipa-client/sysrestore/sysrestore.state exists
fstore = sysrestore.FileStore(paths.IPA_CLIENT_SYSRESTORE) fstore = sysrestore.FileStore(paths.IPA_CLIENT_SYSRESTORE)
return (os.path.isfile(paths.IPA_DEFAULT_CONF) and fstore.has_files()) return os.path.isfile(paths.IPA_DEFAULT_CONF) and fstore.has_files()
def is_server_configured(): def is_server_configured():
@@ -129,7 +131,9 @@ def get_ipa_conf():
def get_ipa_version(): def get_ipa_version():
try: try:
# pylint: disable=import-outside-toplevel
from ipapython import version from ipapython import version
# pylint: enable=import-outside-toplevel
except ImportError: except ImportError:
return None return None
else: else:
@@ -156,7 +160,7 @@ def get_ipa_version():
def main(): def main():
module = AnsibleModule( module = AnsibleModule(
argument_spec=dict(), argument_spec={},
supports_check_mode=True supports_check_mode=True
) )

View File

@@ -146,7 +146,7 @@ def get_host_diff(ipa_host, module_host):
:return: a dict representing the host attributes to apply :return: a dict representing the host attributes to apply
""" """
non_updateable_keys = ['ip_address'] non_updateable_keys = ['ip_address']
data = dict() data = {}
for key in non_updateable_keys: for key in non_updateable_keys:
if key in module_host: if key in module_host:
del module_host[key] del module_host[key]
@@ -173,7 +173,7 @@ def get_module_host(module):
:param module: the ansible module :param module: the ansible module
:returns: a dict representing the host attributes :returns: a dict representing the host attributes
""" """
data = dict() data = {}
certificates = module.params.get('certificates') certificates = module.params.get('certificates')
if certificates: if certificates:
data['usercertificate'] = certificates data['usercertificate'] = certificates
@@ -189,7 +189,7 @@ def get_module_host(module):
return data return data
def ensure_host_present(module, api, ipahost): def ensure_host_present(module, _api, ipahost):
""" """
Ensure host exists in IPA and has the same attributes. Ensure host exists in IPA and has the same attributes.
@@ -216,13 +216,13 @@ def ensure_host_present(module, api, ipahost):
# already has Keytab: true, then we need first to run # already has Keytab: true, then we need first to run
# ipa host-disable in order to remove OTP and keytab # ipa host-disable in order to remove OTP and keytab
if module.params.get('random') and ipahost['has_keytab'] is True: if module.params.get('random') and ipahost['has_keytab'] is True:
api.Command.host_disable(fqdn) _api.Command.host_disable(fqdn)
result = api.Command.host_mod(fqdn, **diffs) result = _api.Command.host_mod(fqdn, **diffs)
# Save random password as it is not displayed by host-show # Save random password as it is not displayed by host-show
if module.params.get('random'): if module.params.get('random'):
randompassword = result['result']['randompassword'] randompassword = result['result']['randompassword']
result = api.Command.host_show(fqdn) result = _api.Command.host_show(fqdn)
if module.params.get('random'): if module.params.get('random'):
result['result']['randompassword'] = randompassword result['result']['randompassword'] = randompassword
module.exit_json(changed=True, host=result['result']) module.exit_json(changed=True, host=result['result'])
@@ -236,17 +236,17 @@ def ensure_host_present(module, api, ipahost):
module_host = get_module_host(module) module_host = get_module_host(module)
# force creation of host even if there is no DNS record # force creation of host even if there is no DNS record
module_host["force"] = True module_host["force"] = True
result = api.Command.host_add(fqdn, **module_host) result = _api.Command.host_add(fqdn, **module_host)
# Save random password as it is not displayed by host-show # Save random password as it is not displayed by host-show
if module.params.get('random'): if module.params.get('random'):
randompassword = result['result']['randompassword'] randompassword = result['result']['randompassword']
result = api.Command.host_show(fqdn) result = _api.Command.host_show(fqdn)
if module.params.get('random'): if module.params.get('random'):
result['result']['randompassword'] = randompassword result['result']['randompassword'] = randompassword
module.exit_json(changed=True, host=result['result']) module.exit_json(changed=True, host=result['result'])
def ensure_host_absent(module, api, host): def ensure_host_absent(module, _api, host):
""" """
Ensure host does not exist in IPA. Ensure host does not exist in IPA.
@@ -265,7 +265,7 @@ def ensure_host_absent(module, api, host):
fqdn = unicode(module.params.get('fqdn')) fqdn = unicode(module.params.get('fqdn'))
try: try:
api.Command.host_del(fqdn) _api.Command.host_del(fqdn)
except Exception as e: except Exception as e:
module.fail_json(msg="Failed to remove host: %s" % e) module.fail_json(msg="Failed to remove host: %s" % e)

View File

@@ -82,7 +82,9 @@ def main():
statestore = sysrestore.StateFile(paths.IPA_CLIENT_SYSRESTORE) statestore = sysrestore.StateFile(paths.IPA_CLIENT_SYSRESTORE)
# pylint: disable=deprecated-method
argspec = inspect.getargspec(configure_nisdomain) argspec = inspect.getargspec(configure_nisdomain)
# pylint: enable=deprecated-method
if "statestore" not in argspec.args: if "statestore" not in argspec.args:
# NUM_VERSION < 40500: # NUM_VERSION < 40500:
configure_nisdomain(options=options, domain=domain) configure_nisdomain(options=options, domain=domain)

View File

@@ -113,7 +113,9 @@ def main():
if sync_time is not None: if sync_time is not None:
if options.conf_ntp: if options.conf_ntp:
# Attempt to configure and sync time with NTP server (chrony). # Attempt to configure and sync time with NTP server (chrony).
# pylint: disable=deprecated-method
argspec = inspect.getargspec(sync_time) argspec = inspect.getargspec(sync_time)
# pylint: enable=deprecated-method
if "options" not in argspec.args: if "options" not in argspec.args:
synced_ntp = sync_time(options.ntp_servers, options.ntp_pool, synced_ntp = sync_time(options.ntp_servers, options.ntp_pool,
fstore, statestore) fstore, statestore)
@@ -149,8 +151,8 @@ def main():
if options.ntp_servers: if options.ntp_servers:
ntp_servers = options.ntp_servers ntp_servers = options.ntp_servers
for s in ntp_servers: for _ntp_server in ntp_servers:
synced_ntp = timeconf.synconce_ntp(s, options.debug) synced_ntp = timeconf.synconce_ntp(_ntp_server, options.debug)
if synced_ntp: if synced_ntp:
break break

View File

@@ -199,7 +199,9 @@ def main():
ansible_log.debug("-- CUSTODIA IMPORT DM PASSWORD --") ansible_log.debug("-- CUSTODIA IMPORT DM PASSWORD --")
# pylint: disable=deprecated-method
argspec = inspect.getargspec(custodia.import_dm_password) argspec = inspect.getargspec(custodia.import_dm_password)
# pylint: enable=deprecated-method
if "master_host_name" in argspec.args: if "master_host_name" in argspec.args:
custodia.import_dm_password(config.master_host_name) custodia.import_dm_password(config.master_host_name)
else: else:

View File

@@ -56,8 +56,7 @@ from ansible.module_utils.ansible_ipa_replica import (
def main(): def main():
ansible_module = AnsibleModule( ansible_module = AnsibleModule(
argument_spec=dict( argument_spec={},
),
supports_check_mode=True, supports_check_mode=True,
) )

View File

@@ -316,7 +316,9 @@ def main():
ansible_log.debug("-- CONFIGURE DIRSRV --") ansible_log.debug("-- CONFIGURE DIRSRV --")
# Configure dirsrv # Configure dirsrv
with redirect_stdout(ansible_log): with redirect_stdout(ansible_log):
# pylint: disable=deprecated-method
argspec = inspect.getargspec(install_replica_ds) argspec = inspect.getargspec(install_replica_ds)
# pylint: enable=deprecated-method
if "promote" in argspec.args: if "promote" in argspec.args:
ds = install_replica_ds(config, options, ca_enabled, ds = install_replica_ds(config, options, ca_enabled,
remote_api, remote_api,
@@ -336,9 +338,13 @@ def main():
ca_file=cafile, ca_file=cafile,
pkcs12_info=dirsrv_pkcs12_info) pkcs12_info=dirsrv_pkcs12_info)
# pylint: disable=deprecated-method
ansible_log.debug("-- INSTALL DNS RECORDS --") ansible_log.debug("-- INSTALL DNS RECORDS --")
# pylint: enable=deprecated-method
# Always try to install DNS records # Always try to install DNS records
# pylint: disable=deprecated-method
argspec = inspect.getargspec(install_dns_records) argspec = inspect.getargspec(install_dns_records)
# pylint: enable=deprecated-method
if "fstore" not in argspec.args: if "fstore" not in argspec.args:
install_dns_records(config, options, remote_api) install_dns_records(config, options, remote_api)
else: else:

View File

@@ -202,7 +202,9 @@ def main():
create_ipa_conf(fstore, config, ca_enabled, create_ipa_conf(fstore, config, ca_enabled,
master=config.master_host_name) master=config.master_host_name)
# pylint: disable=deprecated-method
argspec = inspect.getargspec(install_http) argspec = inspect.getargspec(install_http)
# pylint: enable=deprecated-method
if "promote" in argspec.args: if "promote" in argspec.args:
install_http( install_http(
config, config,

View File

@@ -161,7 +161,9 @@ def main():
ansible_log.debug("-- INSTALL_KRB --") ansible_log.debug("-- INSTALL_KRB --")
with redirect_stdout(ansible_log): with redirect_stdout(ansible_log):
# pylint: disable=deprecated-method
argspec = inspect.getargspec(install_krb) argspec = inspect.getargspec(install_krb)
# pylint: enable=deprecated-method
if "promote" in argspec.args: if "promote" in argspec.args:
install_krb( install_krb(
config, config,

View File

@@ -286,7 +286,9 @@ def main():
# asks for HTTP certificate in newer ipa versions. In these versions # asks for HTTP certificate in newer ipa versions. In these versions
# create_ipa_conf has the additional master argument. # create_ipa_conf has the additional master argument.
change_master_for_certmonger = False change_master_for_certmonger = False
# pylint: disable=deprecated-method
argspec = inspect.getargspec(create_ipa_conf) argspec = inspect.getargspec(create_ipa_conf)
# pylint: enable=deprecated-method
if "master" in argspec.args: if "master" in argspec.args:
change_master_for_certmonger = True change_master_for_certmonger = True
@@ -418,7 +420,9 @@ def main():
# check selinux status, http and DS ports, NTP conflicting services # check selinux status, http and DS ports, NTP conflicting services
try: try:
with redirect_stdout(ansible_log): with redirect_stdout(ansible_log):
# pylint: disable=deprecated-method
argspec = inspect.getargspec(common_check) argspec = inspect.getargspec(common_check)
# pylint: enable=deprecated-method
if "skip_mem_check" in argspec.args: if "skip_mem_check" in argspec.args:
common_check(options.no_ntp, options.skip_mem_check, common_check(options.no_ntp, options.skip_mem_check,
options.setup_ca) options.setup_ca)

View File

@@ -138,15 +138,15 @@ else:
try: try:
from ipaclient.install import timeconf from ipaclient.install import timeconf
time_service = "chronyd" time_service = "chronyd" # pylint: disable=invalid-name
ntpinstance = None ntpinstance = None # pylint: disable=invalid-name
except ImportError: except ImportError:
try: try:
from ipaclient.install import ntpconf as timeconf from ipaclient.install import ntpconf as timeconf
except ImportError: except ImportError:
from ipaclient import ntpconf as timeconf from ipaclient import ntpconf as timeconf
from ipaserver.install import ntpinstance from ipaserver.install import ntpinstance
time_service = "ntpd" time_service = "ntpd" # pylint: disable=invalid-name
else: else:
# IPA version < 4.6 # IPA version < 4.6
@@ -162,10 +162,10 @@ else:
filemode='a', console_format='%(message)s') filemode='a', console_format='%(message)s')
@contextlib_contextmanager @contextlib_contextmanager
def redirect_stdout(f): def redirect_stdout(stream):
sys.stdout = f sys.stdout = stream
try: try:
yield f yield stream
finally: finally:
sys.stdout = sys.__stdout__ sys.stdout = sys.__stdout__
@@ -202,7 +202,8 @@ else:
self.module.debug(msg) self.module.debug(msg)
# self.module.warn(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): def __init__(self):
# CompatServerReplicaInstall # CompatServerReplicaInstall
self.ca_cert_files = None self.ca_cert_files = None
@@ -244,10 +245,10 @@ else:
# (attr, repr(value))) # (attr, repr(value)))
# return value # return value
def __getattr__(self, attr): def __getattr__(self, attrname):
logger.info(" --> ADDING missing installer.%s", attr) logger.info(" --> ADDING missing installer.%s", attrname)
setattr(self, attr, None) setattr(self, attrname, None)
return getattr(self, attr) return getattr(self, attrname)
# def __setattr__(self, attr, value): # def __setattr__(self, attr, value):
# logger.debug(" --> Setting installer.%s to %s" % # logger.debug(" --> Setting installer.%s to %s" %
@@ -258,6 +259,9 @@ else:
for name in self.__dict__: for name in self.__dict__:
yield self, name yield self, name
# pylint: enable=too-many-instance-attributes, useless-object-inheritance
# pylint: disable=attribute-defined-outside-init
installer = installer_obj() installer = installer_obj()
options = installer options = installer
@@ -274,6 +278,7 @@ else:
# ServerReplicaInstall # ServerReplicaInstall
options.subject_base = None options.subject_base = None
options.ca_subject = None options.ca_subject = None
# pylint: enable=attribute-defined-outside-init
def gen_env_boostrap_finalize_core(etc_ipa, default_config): def gen_env_boostrap_finalize_core(etc_ipa, default_config):
env = Env() env = Env()
@@ -295,9 +300,12 @@ else:
# pylint: enable=no-member # pylint: enable=no-member
api.finalize() api.finalize()
def gen_ReplicaConfig(): def gen_ReplicaConfig(): # pylint: disable=invalid-name
# pylint: disable=too-many-instance-attributes
class ExtendedReplicaConfig(ReplicaConfig): class ExtendedReplicaConfig(ReplicaConfig):
# pylint: disable=useless-super-delegation
def __init__(self, top_dir=None): def __init__(self, top_dir=None):
# pylint: disable=super-with-arguments
super(ExtendedReplicaConfig, self).__init__(top_dir) super(ExtendedReplicaConfig, self).__init__(top_dir)
# def __getattribute__(self, attr): # def __getattribute__(self, attr):
@@ -306,12 +314,13 @@ else:
# if attr not in ["__dict__", "knobs"]: # if attr not in ["__dict__", "knobs"]:
# logger.debug(" <== Accessing config.%s (%s)" % # logger.debug(" <== Accessing config.%s (%s)" %
# (attr, repr(value))) # (attr, repr(value)))
# return value # return value\
# pylint: enable=useless-super-delegation
def __getattr__(self, attr): def __getattr__(self, attrname):
logger.info(" ==> ADDING missing config.%s", attr) logger.info(" ==> ADDING missing config.%s", attrname)
setattr(self, attr, None) setattr(self, attrname, None)
return getattr(self, attr) return getattr(self, attrname)
# def __setattr__(self, attr, value): # def __setattr__(self, attr, value):
# logger.debug(" ==> Setting config.%s to %s" % # logger.debug(" ==> Setting config.%s to %s" %
@@ -322,7 +331,9 @@ else:
def knobs(self): def knobs(self):
for name in self.__dict__: for name in self.__dict__:
yield self, name yield self, name
# pylint: enable=too-many-instance-attributes
# pylint: disable=attribute-defined-outside-init
# config = ReplicaConfig() # config = ReplicaConfig()
config = ExtendedReplicaConfig() config = ExtendedReplicaConfig()
config.realm_name = api.env.realm config.realm_name = api.env.realm
@@ -338,10 +349,12 @@ else:
config.basedn = api.env.basedn config.basedn = api.env.basedn
# config.subject_base = options.subject_base # config.subject_base = options.subject_base
# pylint: enable=attribute-defined-outside-init
return config return config
def replica_ds_init_info(ansible_log, 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, ds_ca_subject, ca_file,
promote=False, pkcs12_info=None): promote=False, pkcs12_info=None):
@@ -364,7 +377,7 @@ else:
ca_subject = ds_ca_subject ca_subject = ds_ca_subject
ds = dsinstance.DsInstance( ds = dsinstance.DsInstance(
config_ldif=options.dirsrv_config_file) config_ldif=options_.dirsrv_config_file)
ds.set_output(ansible_log) ds.set_output(ansible_log)
# Source: ipaserver/install/dsinstance.py # Source: ipaserver/install/dsinstance.py

View File

@@ -312,6 +312,7 @@ def main():
# Create the management framework config file and finalize api # Create the management framework config file and finalize api
target_fname = paths.IPA_DEFAULT_CONF target_fname = paths.IPA_DEFAULT_CONF
# pylint: disable=invalid-name, consider-using-with
fd = open(target_fname, "w") fd = open(target_fname, "w")
fd.write("[global]\n") fd.write("[global]\n")
fd.write("host=%s\n" % options.host_name) fd.write("host=%s\n" % options.host_name)
@@ -331,6 +332,7 @@ def main():
fd.write("ra_plugin=none\n") fd.write("ra_plugin=none\n")
fd.write("mode=production\n") fd.write("mode=production\n")
fd.close() fd.close()
# pylint: enable=invalid-name, consider-using-with
# Must be readable for everyone # Must be readable for everyone
os.chmod(target_fname, 0o644) os.chmod(target_fname, 0o644)

View File

@@ -93,7 +93,9 @@ def main():
# the ipa-server-install --uninstall # the ipa-server-install --uninstall
ansible_module.log("Synchronizing time") ansible_module.log("Synchronizing time")
# pylint: disable=deprecated-method
argspec = inspect.getargspec(sync_time) argspec = inspect.getargspec(sync_time)
# pylint: enable=deprecated-method
if "options" not in argspec.args: if "options" not in argspec.args:
synced_ntp = sync_time(options.ntp_servers, options.ntp_pool, synced_ntp = sync_time(options.ntp_servers, options.ntp_pool,
fstore, sstore) fstore, sstore)

View File

@@ -742,7 +742,7 @@ def main():
validate_admin_password(options.admin_password) validate_admin_password(options.admin_password)
# pkinit is not supported on DL0, don't allow related options # pkinit is not supported on DL0, don't allow related options
# pylint: disable=pointless-string-statement
""" """
# replica install: if not options.replica_file is None: # replica install: if not options.replica_file is None:
if (not options._replica_install and \ if (not options._replica_install and \
@@ -755,6 +755,7 @@ def main():
"don't use any pkinit-related options.") "don't use any pkinit-related options.")
options.no_pkinit = True options.no_pkinit = True
""" """
# pylint: enable=pointless-string-statement
if options.setup_dns: if options.setup_dns:
if len(options.forwarders) < 1 and not options.no_forwarders and \ if len(options.forwarders) < 1 and not options.no_forwarders and \
@@ -942,7 +943,9 @@ def main():
else: else:
realm_name = options.realm_name.upper() realm_name = options.realm_name.upper()
# pylint: disable=deprecated-method
argspec = inspect.getargspec(validate_domain_name) argspec = inspect.getargspec(validate_domain_name)
# pylint: enable=deprecated-method
if "entity" in argspec.args: if "entity" in argspec.args:
# NUM_VERSION >= 40690: # NUM_VERSION >= 40690:
try: try:

View File

@@ -105,23 +105,23 @@ else:
try: try:
from ipaclient.install import timeconf from ipaclient.install import timeconf
from ipaclient.install.client import sync_time from ipaclient.install.client import sync_time
time_service = "chronyd" time_service = "chronyd" # pylint: disable=invalid-name
ntpinstance = None ntpinstance = None # pylint: disable=invalid-name
except ImportError: except ImportError:
try: try:
from ipaclient.install import ntpconf as timeconf from ipaclient.install import ntpconf as timeconf
except ImportError: except ImportError:
from ipaclient import ntpconf as timeconf from ipaclient import ntpconf as timeconf
from ipaserver.install import ntpinstance from ipaserver.install import ntpinstance
time_service = "ntpd" time_service = "ntpd" # pylint: disable=invalid-name
sync_time = None sync_time = None # pylint: disable=invalid-name
from ipaserver.install import ( from ipaserver.install import (
adtrust, bindinstance, ca, dns, dsinstance, adtrust, bindinstance, ca, dns, dsinstance,
httpinstance, installutils, kra, krbinstance, httpinstance, installutils, kra, krbinstance,
otpdinstance, custodiainstance, replication, service, otpdinstance, custodiainstance, replication, service,
sysupgrade) sysupgrade)
adtrust_imported = True adtrust_imported = True # pylint: disable=invalid-name
kra_imported = True kra_imported = True # pylint: disable=invalid-name
from ipaserver.install.installutils import ( from ipaserver.install.installutils import (
BadHostError, get_fqdn, get_server_ip_address, BadHostError, get_fqdn, get_server_ip_address,
load_pkcs12, read_password, verify_fqdn, load_pkcs12, read_password, verify_fqdn,
@@ -158,9 +158,9 @@ else:
try: try:
from ipaserver.install import adtrustinstance from ipaserver.install import adtrustinstance
_server_trust_ad_installed = True _server_trust_ad_installed = True # pylint: disable=invalid-name
except ImportError: except ImportError:
_server_trust_ad_installed = False _server_trust_ad_installed = False # pylint: disable=invalid-name
try: try:
from ipaclient.install.client import check_ldap_conf from ipaclient.install.client import check_ldap_conf
@@ -192,10 +192,10 @@ else:
filemode='a', console_format='%(message)s') filemode='a', console_format='%(message)s')
@contextlib_contextmanager @contextlib_contextmanager
def redirect_stdout(f): def redirect_stdout(stream):
sys.stdout = f sys.stdout = stream
try: try:
yield f yield stream
finally: finally:
sys.stdout = sys.__stdout__ sys.stdout = sys.__stdout__
@@ -232,7 +232,9 @@ else:
self.module.debug(msg) self.module.debug(msg)
# self.module.warn(msg) # self.module.warn(msg)
class options_obj(object): # pylint: disable=too-few-public-methods, useless-object-inheritance
# pylint: disable=too-many-instance-attributes
class options_obj(object): # pylint: disable=invalid-name
def __init__(self): def __init__(self):
self._replica_install = False self._replica_install = False
self.dnssec_master = False # future unknown self.dnssec_master = False # future unknown
@@ -255,9 +257,14 @@ else:
for name in self.__dict__: for name in self.__dict__:
yield self, name yield self, name
# pylint: enable=too-few-public-methods, useless-object-inheritance
# pylint: enable=too-many-instance-attributes
options = options_obj() options = options_obj()
installer = options installer = options
# pylint: disable=attribute-defined-outside-init
# ServerMasterInstall # ServerMasterInstall
options.add_sids = True options.add_sids = True
options.add_agents = False options.add_agents = False
@@ -299,6 +306,9 @@ else:
options.ignore_topology_disconnect = False options.ignore_topology_disconnect = False
options.ignore_last_of_role = False options.ignore_last_of_role = False
# pylint: enable=attribute-defined-outside-init
# pylint: disable=invalid-name
def api_Backend_ldap2(host_name, setup_ca, connect=False): def api_Backend_ldap2(host_name, setup_ca, connect=False):
# we are sure we have the configuration file ready. # we are sure we have the configuration file ready.
cfg = dict(context='installer', confdir=paths.ETC_IPA, in_server=True, cfg = dict(context='installer', confdir=paths.ETC_IPA, in_server=True,
@@ -312,10 +322,12 @@ else:
if connect: if connect:
api.Backend.ldap2.connect() api.Backend.ldap2.connect()
# pylint: enable=invalid-name
def ds_init_info(ansible_log, fstore, domainlevel, dirsrv_config_file, def ds_init_info(ansible_log, fstore, domainlevel, dirsrv_config_file,
realm_name, host_name, domain_name, dm_password, realm_name, host_name, domain_name, dm_password,
idstart, idmax, subject_base, ca_subject, idstart, idmax, subject_base, ca_subject,
no_hbac_allow, dirsrv_pkcs12_info, no_pkinit): _no_hbac_allow, dirsrv_pkcs12_info, no_pkinit):
if not options.external_cert_files: if not options.external_cert_files:
ds = dsinstance.DsInstance(fstore=fstore, domainlevel=domainlevel, ds = dsinstance.DsInstance(fstore=fstore, domainlevel=domainlevel,

View File

@@ -57,14 +57,20 @@ disable =
fixme fixme
[pylint.BASIC] [pylint.BASIC]
good-names = ex, i, j, k, Run, _, e, x, dn, cn, ip, os, unicode, __metaclass__ good-names =
ex, i, j, k, Run, _, e, x, dn, cn, ip, os, unicode, __metaclass__, ds
[pylint.IMPORTS] [pylint.IMPORTS]
ignored-modules = ignored-modules =
ansible.module_utils.ansible_freeipa_module, ansible.errors, ansible.plugins.action,
ansible.module_utils, ansible.module_utils.ansible_freeipa_module,
ipalib, ipalib.config, ipalib.constants, ipalib.krb_utils, ipalib.errors, ipalib, ipalib.config, ipalib.constants, ipalib.krb_utils, ipalib.errors,
ipapython.ipautil, ipapython.dn, ipapython.version, ipapython.dnsutil, ipapython.ipautil, ipapython.dn, ipapython.version, ipapython.dnsutil,
ipaplatform.paths ipapython.ipa_log_manager, ipapython,
ipaplatform, ipaplatform.paths, ipaplatform.tasks, ipapython.admintool,
ipaserver.install.installutils, ipaserver.install.server.install,
ipaserver.install,
ipaclient.install.ipachangeconf, ipaclient.install.client
[pylint.REFACTORING] [pylint.REFACTORING]
max-nested-blocks = 9 max-nested-blocks = 9

View File

@@ -13,7 +13,7 @@ flake8 plugins utils roles setup.py
echo -e "${INFO}Running 'pydocstyle'...${RST}" echo -e "${INFO}Running 'pydocstyle'...${RST}"
pydocstyle plugins utils roles setup.py pydocstyle plugins utils roles setup.py
echo -e "${INFO}Running 'pylint'...${RST}" echo -e "${INFO}Running 'pylint'...${RST}"
pylint plugins setup.py pylint plugins roles setup.py
ANSIBLE_LIBRARY="${ANSIBLE_LIBRARY:-plugins/modules}" ANSIBLE_LIBRARY="${ANSIBLE_LIBRARY:-plugins/modules}"
ANSIBLE_MODULE_UTILS="${ANSIBLE_MODULE_UTILS:-plugins/module_utils}" ANSIBLE_MODULE_UTILS="${ANSIBLE_MODULE_UTILS:-plugins/module_utils}"