ipa[server,replica,client]: pylint fixes

This commit is contained in:
Thomas Woerner
2019-07-17 18:54:20 +02:00
parent 3a4cb6a732
commit de9d8b50cf
14 changed files with 28 additions and 24 deletions

View File

@@ -45,7 +45,7 @@ def run_cmd(args, stdin=None):
p = subprocess.Popen(args, stdin=p_in, stdout=p_out, stderr=p_err, p = subprocess.Popen(args, stdin=p_in, stdout=p_out, stderr=p_err,
close_fds=True) close_fds=True)
stdout, stderr = p.communicate(stdin) __temp, stderr = p.communicate(stdin)
if p.returncode != 0: if p.returncode != 0:
raise RuntimeError(stderr) raise RuntimeError(stderr)

View File

@@ -99,7 +99,7 @@ def main():
os.environ['KRB5CCNAME'] = paths.IPA_DNS_CCACHE os.environ['KRB5CCNAME'] = paths.IPA_DNS_CCACHE
ca_certs = x509.load_certificate_list_from_file(paths.IPA_CA_CRT) ca_certs = x509.load_certificate_list_from_file(paths.IPA_CA_CRT)
if NUM_VERSION >= 40500 and NUM_VERSION < 40590: if 40500 <= NUM_VERSION < 40590:
ca_certs = [ cert.public_bytes(serialization.Encoding.DER) ca_certs = [ cert.public_bytes(serialization.Encoding.DER)
for cert in ca_certs ] for cert in ca_certs ]
elif NUM_VERSION < 40500: elif NUM_VERSION < 40500:

View File

@@ -8,6 +8,7 @@ from six.moves.configparser import RawConfigParser
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
# pylint: disable=unused-import
try: try:
from ipalib import api from ipalib import api
except ImportError: except ImportError:

View File

@@ -327,7 +327,7 @@ def main():
except errors.NotFound: except errors.NotFound:
host = None host = None
if state == 'present' or state == 'disabled': if state in ['present','disabled']:
changed = ensure_host_present(module, api, host) changed = ensure_host_present(module, api, host)
elif state == 'absent': elif state == 'absent':
changed = ensure_host_absent(module, api, host) changed = ensure_host_absent(module, api, host)

View File

@@ -77,5 +77,6 @@ def main():
module.exit_json(changed=True) module.exit_json(changed=True)
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View File

@@ -139,7 +139,7 @@ def main():
logger.info("Skipping chrony configuration") logger.info("Skipping chrony configuration")
else: else:
ntp_srv_servers = [ ] ntp_srv_servers = []
if not options.on_master and options.conf_ntp: if not options.on_master and options.conf_ntp:
# Attempt to sync time with IPA server. # Attempt to sync time with IPA server.
# If we're skipping NTP configuration, we also skip the time sync here. # If we're skipping NTP configuration, we also skip the time sync here.
@@ -176,5 +176,6 @@ def main():
# Done # Done
module.exit_json(changed=synced_ntp) module.exit_json(changed=synced_ntp)
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View File

@@ -461,7 +461,7 @@ def main():
### client.install_check ### ### client.install_check ###
logger.info("This program will set up FreeIPA client.") logger.info("This program will set up FreeIPA client.")
logger.info("Version {}".format(version.VERSION)) logger.info("Version %s", version.VERSION)
logger.info("") logger.info("")
cli_domain_source = 'Unknown source' cli_domain_source = 'Unknown source'
@@ -494,7 +494,7 @@ def main():
except timeconf.NTPConflictingService as e: except timeconf.NTPConflictingService as e:
logger.info( logger.info(
"WARNING: conflicting time&date synchronization service " "WARNING: conflicting time&date synchronization service "
"'%s' will be disabled in favor of chronyd" % \ "'%s' will be disabled in favor of chronyd",
e.conflicting_service) e.conflicting_service)
logger.info("") logger.info("")
except timeconf.NTPConfigurationError: except timeconf.NTPConfigurationError:
@@ -563,6 +563,7 @@ def main():
rval=CLIENT_INSTALL_ERROR) rval=CLIENT_INSTALL_ERROR)
(nssldap_installed, nosssd_files) = nssldap_exists() (nssldap_installed, nosssd_files) = nssldap_exists()
(nssldap_installed, __temp) = nssldap_exists()
if not nssldap_installed: if not nssldap_installed:
raise ScriptError( raise ScriptError(
"One of these packages must be installed: nss_ldap or " "One of these packages must be installed: nss_ldap or "

View File

@@ -159,7 +159,7 @@ def main():
ping_test_ok = True ping_test_ok = True
except OSError: except OSError:
pass pass
except GSSError as e: except GSSError:
pass pass
# Second try: Validate krb5 keytab with temporary krb5 # Second try: Validate krb5 keytab with temporary krb5
@@ -197,7 +197,7 @@ def main():
except OSError: except OSError:
pass pass
except GSSError as e: except GSSError:
pass pass
finally: finally:

View File

@@ -88,7 +88,7 @@ def main():
fstore = sysrestore.FileStore(paths.SYSRESTORE) fstore = sysrestore.FileStore(paths.SYSRESTORE)
if NUM_VERSION < 40600: if hasattr(tasks, "configure_tmpfiles"):
# Make sure the files we crated in /var/run are recreated at startup # Make sure the files we crated in /var/run are recreated at startup
tasks.configure_tmpfiles() tasks.configure_tmpfiles()

View File

@@ -71,7 +71,7 @@ def main():
if options.dm_password is None: if options.dm_password is None:
ansible_module.fail_json(msg="Directory Manager password required") ansible_module.fail_json(msg="Directory Manager password required")
try: try:
cache_vars = read_cache(dm_password) cache_vars = read_cache(options.dm_password)
options.__dict__.update(cache_vars) options.__dict__.update(cache_vars)
if cache_vars.get('external_ca', False): if cache_vars.get('external_ca', False):
options.external_ca = False options.external_ca = False
@@ -83,7 +83,7 @@ def main():
kwargs = { "changed": True } kwargs = { "changed": True }
for name in options.__dict__: for name in options.__dict__:
kwargs[name] = options.__dict__[name] kwargs[name] = options.__dict__[name]
ansible_module.exit_json(kwargs) ansible_module.exit_json(**kwargs)
# done ################################################################## # done ##################################################################

View File

@@ -127,7 +127,7 @@ def main():
# Make sure tmpfiles dir exist before installing components # Make sure tmpfiles dir exist before installing components
if NUM_VERSION == 40504: if NUM_VERSION == 40504:
tasks.create_tmpfiles_dirs(IPAAPI_USER) tasks.create_tmpfiles_dirs(IPAAPI_USER)
elif NUM_VERSION >= 40500 and NUM_VERSION <= 40503: elif 40500 <= NUM_VERSION <= 40503:
tasks.create_tmpfiles_dirs() tasks.create_tmpfiles_dirs()
# Create a directory server instance # Create a directory server instance
@@ -138,7 +138,7 @@ def main():
ds.set_output(ansible_log) ds.set_output(ansible_log)
if options.dirsrv_cert_files: if options.dirsrv_cert_files:
_dirsrv_pkcs12_info=options.dirsrv_pkcs12_info _dirsrv_pkcs12_info=options._dirsrv_pkcs12_info
else: else:
_dirsrv_pkcs12_info=None _dirsrv_pkcs12_info=None

View File

@@ -158,12 +158,12 @@ def main():
options.dirsrv_cert_files = ansible_module.params.get('dirsrv_cert_files') options.dirsrv_cert_files = ansible_module.params.get('dirsrv_cert_files')
options.http_cert_files = ansible_module.params.get('http_cert_files') options.http_cert_files = ansible_module.params.get('http_cert_files')
options.pkinit_cert_files = ansible_module.params.get('pkinit_cert_files') options.pkinit_cert_files = ansible_module.params.get('pkinit_cert_files')
options.dirsrv_pin = ansible_module.params.get('dirsrv_pin'), options.dirsrv_pin = ansible_module.params.get('dirsrv_pin')
options.http_pin = ansible_module.params.get('http_pin'), options.http_pin = ansible_module.params.get('http_pin')
options.pkinit_pin = ansible_module.params.get('pkinit_pin'), options.pkinit_pin = ansible_module.params.get('pkinit_pin')
options.dirsrv_cert_name = ansible_module.params.get('dirsrv_cert_name'), options.dirsrv_cert_name = ansible_module.params.get('dirsrv_cert_name')
options.http_cert_name = ansible_module.params.get('http_cert_name'), options.http_cert_name = ansible_module.params.get('http_cert_name')
options.pkinit_cert_name = ansible_module.params.get('pkinit_cert_name'), options.pkinit_cert_name = ansible_module.params.get('pkinit_cert_name')
### client ### ### client ###
# mkhomedir # mkhomedir
options.ntp_servers = ansible_module.params.get('ntp_servers') options.ntp_servers = ansible_module.params.get('ntp_servers')
@@ -562,7 +562,7 @@ def main():
try: try:
check_zone_overlap(options.domain_name, False) check_zone_overlap(options.domain_name, False)
except ValueError as e: except ValueError as e:
ansible_module.fail_json(str(e)) ansible_module.fail_json(msg=str(e))
# dm_password # dm_password
with redirect_stdout(ansible_log): with redirect_stdout(ansible_log):