'Install autotest.
:param host A Host instance on which autotest will be installed
:param autodir Location on the remote host to install to
:param use_autoserv Enable install modes that depend on the client
running with the autoserv harness
:param use_packaging Enable install modes that use the packaging system
@exception AutoservError If it wasn\'t possible to install the client
after trying all available methods'

def _install(self, host=None, autodir=None, use_autoserv=True, use_packaging=True):

    if (not host):
        host = self.host
    if (not self.got):
        self.get()
    host.wait_up(timeout=30)
    host.setup()
    logging.info('Installing    autotest    on    %s', host.hostname)
    if self.server_system_wide_install:
        msg_install = 'Autotest    seems    to    be    installed    in    the    client    on    a    system    wide    location,    proceeding...'
        logging.info('Verifying    client    package    install')
        if _client_system_wide_install(host):
            logging.info(msg_install)
            self.installed = True
            return
        install_cmd = INSTALL_CLIENT_CMD_MAPPING.get(self.os_vendor, None)
        if (install_cmd is not None):
            logging.info(msg_install)
            host.run(install_cmd)
            if _client_system_wide_install(host):
                logging.info('Autotest    seems    to    be    installed    in    the    client    on    a    system    wide    location,    proceeding...')
                self.installed = True
                return
        raise error.AutoservError(('The    autotest    client    package    does    not    seem    to    be    installed    on    %s' % host.hostname))
    if (not autodir):
        autodir = self.get_install_dir(host)
    logging.info('Using    installation    dir    %s', autodir)
    host.set_autodir(autodir)
    host.run(('mkdir    -p    %s' % utils.sh_escape(autodir)))
    results_path = os.path.join(autodir, 'results')
    host.run(('rm    -rf    %s/*' % utils.sh_escape(results_path)), ignore_status=True)
    if use_packaging:
        try:
            self._install_using_packaging(host, autodir)
            self._create_test_output_dir(host, autodir)
            logging.info('Installation    of    autotest    completed')
            self.installed = True
            return
        except (error.PackageInstallError, error.AutoservRunError, SettingsError) as e:
            logging.info('Could    not    install    autotest    using    the    packaging    system:    %s.    Trying    other    methods', e)
    if self.source_material:
        supports_autoserv_packaging = settings.get_value('PACKAGES', 'serve_packages_from_autoserv', type=bool)
        if (supports_autoserv_packaging and use_autoserv):
            self._install_using_send_file(host, autodir)
        else:
            host.send_file(self.source_material, autodir, delete_dest=True)
        self._create_test_output_dir(host, autodir)
        logging.info('Installation    of    autotest    completed')
        self.installed = True
        return
    raise error.AutoservError(('Could    not    install    autotest    on    target    machine:    %s' % host.name))
