diff options
| author | Jan Cholasta <jcholast@redhat.com> | 2016-11-08 08:30:08 +0100 |
|---|---|---|
| committer | Jan Cholasta <jcholast@redhat.com> | 2016-11-11 12:17:25 +0100 |
| commit | 09423acb6574a3773d7783f9ddec022bed3539c8 (patch) | |
| tree | 630ba943961e1cd8232341b510d1c9aeafb4b6e7 /ipaclient | |
| parent | 714699a81fa377e6033cbc7564f0f0fd10cd9f1a (diff) | |
| download | freeipa-09423acb6574a3773d7783f9ddec022bed3539c8.tar.gz freeipa-09423acb6574a3773d7783f9ddec022bed3539c8.tar.xz freeipa-09423acb6574a3773d7783f9ddec022bed3539c8.zip | |
install: migrate client install to the new class hierarchy
Migrate ipa-client-install from the custom script to the new installer
class hierarchy classes.
https://fedorahosted.org/freeipa/ticket/6392
Reviewed-By: Martin Basti <mbasti@redhat.com>
Diffstat (limited to 'ipaclient')
| -rw-r--r-- | ipaclient/install/client.py | 127 | ||||
| -rw-r--r-- | ipaclient/install/ipa_client_install.py | 66 |
2 files changed, 192 insertions, 1 deletions
diff --git a/ipaclient/install/client.py b/ipaclient/install/client.py index 3f124a61e..b24a98916 100644 --- a/ipaclient/install/client.py +++ b/ipaclient/install/client.py @@ -50,6 +50,7 @@ from ipalib.rpc import delete_persistent_client_session_data from ipalib.util import ( broadcast_ip_address_warning, network_ip_address_warning, + normalize_hostname, verify_host_resolvable, ) from ipaplatform import services @@ -67,7 +68,8 @@ from ipapython.admintool import ScriptError from ipapython.dn import DN from ipapython.install import typing from ipapython.install.core import knob -from ipapython.ipa_log_manager import root_logger +from ipapython.install.common import step +from ipapython.ipa_log_manager import log_mgr, root_logger from ipapython.ipautil import ( CalledProcessError, dir_exists, @@ -3309,6 +3311,41 @@ def uninstall(options): raise ScriptError(rval=rv) +def init(installer): + try: + installer.debug = log_mgr.get_handler('console').level == 'debug' + except KeyError: + installer.debug = True + installer.unattended = not installer.interactive + + if installer.domain_name: + installer.domain = normalize_hostname(installer.domain_name) + else: + installer.domain = None + installer.server = installer.servers + installer.realm = installer.realm_name + installer.primary = installer.fixed_primary + if installer.principal: + installer.password = installer.admin_password + else: + installer.password = installer.host_password + installer.hostname = installer.host_name + installer.conf_ntp = not installer.no_ntp + installer.trust_sshfp = installer.ssh_trust_dns + installer.conf_ssh = not installer.no_ssh + installer.conf_sshd = not installer.no_sshd + installer.conf_sudo = not installer.no_sudo + installer.create_sshfp = not installer.no_dns_sshfp + if installer.ca_cert_files: + installer.ca_cert_file = installer.ca_cert_files[-1] + else: + installer.ca_cert_file = None + installer.location = installer.automount_location + installer.dns_updates = installer.enable_dns_updates + installer.krb5_offline_passwords = not installer.no_krb5_offline_passwords + installer.sssd = not installer.no_sssd + + class ClientInstallInterface(hostname_.HostNameInstallInterface, service.ServiceAdminInstallInterface): """ @@ -3492,3 +3529,91 @@ class ClientInstallInterface(hostname_.HostNameInstallInterface, raise RuntimeError( "--ip-address cannot be used together with" "--all-ip-addresses") + + +class ClientInstall(ClientInstallInterface, + automount.AutomountInstallInterface): + """ + Client installer + """ + + ca_cert_files = knob( + bases=ClientInstallInterface.ca_cert_files, + ) + + @ca_cert_files.validator + def ca_cert_files(self, value): + if not os.path.exists(value): + raise ValueError("'%s' does not exist" % value) + if not os.path.isfile(value): + raise ValueError("'%s' is not a file" % value) + if not os.path.isabs(value): + raise ValueError("'%s' is not an absolute file path" % value) + + try: + x509.load_certificate_from_file(value) + except Exception: + raise ValueError("'%s' is not a valid certificate file" % value) + + @property + def prompt_password(self): + return self.interactive + + automount_location = knob( + bases=automount.AutomountInstallInterface.automount_location, + default=None, + ) + + no_ac = knob( + None, + description="do not modify the nsswitch.conf and PAM configuration", + cli_names='--noac', + ) + + force = knob( + None, + description="force setting of LDAP/Kerberos conf", + cli_names=[None, '-f'], + ) + + on_master = False + + configure_firefox = knob( + None, + description="configure Firefox to use IPA domain credentials", + ) + + firefox_dir = knob( + str, None, + description="specify directory where Firefox is installed (for " + "example: '/usr/lib/firefox')", + ) + + no_sssd = knob( + None, + description="Do not configure the client to use SSSD for " + "authentication", + cli_names=[None, '-S'], + ) + + def __init__(self, **kwargs): + super(ClientInstall, self).__init__(**kwargs) + + if self.firefox_dir and not self.configure_firefox: + raise RuntimeError( + "--firefox-dir cannot be used without --configure-firefox " + "option") + + @step() + def main(self): + init(self) + install_check(self) + yield + install(self) + + @main.uninstaller + def main(self): + init(self) + uninstall_check(self) + yield + uninstall(self) diff --git a/ipaclient/install/ipa_client_install.py b/ipaclient/install/ipa_client_install.py new file mode 100644 index 000000000..4ac7cf51f --- /dev/null +++ b/ipaclient/install/ipa_client_install.py @@ -0,0 +1,66 @@ +# +# Copyright (C) 2016 FreeIPA Contributors see COPYING for license +# + +from ipaclient.install import client +from ipaplatform.paths import paths +from ipapython.install import cli +from ipapython.install.core import knob + + +class StandaloneClientInstall(client.ClientInstall): + no_host_dns = False + no_wait_for_dns = False + + principal = knob( + bases=client.ClientInstall.principal, + cli_names=list(client.ClientInstall.principal.cli_names) + ['-p'], + ) + + password = knob( + str, None, + sensitive=True, + description="password to join the IPA realm (assumes bulk password " + "unless principal is also set)", + cli_names=[None, '-w'], + ) + + @property + def admin_password(self): + if self.principal: + return self.password + + return super(StandaloneClientInstall, self).admin_password + + @property + def host_password(self): + if not self.principal: + return self.password + + return super(StandaloneClientInstall, self).host_password + + prompt_password = knob( + None, + description="Prompt for a password to join the IPA realm", + cli_names='-W', + ) + + on_master = knob( + None, + deprecated=True, + ) + + +ClientInstall = cli.install_tool( + StandaloneClientInstall, + command_name='ipa-client-install', + log_file_name=paths.IPACLIENT_INSTALL_LOG, + debug_option=True, + verbose=True, + console_format='%(message)s', + uninstall_log_file_name=paths.IPACLIENT_UNINSTALL_LOG, +) + + +def run(): + ClientInstall.run_cli() |
