Ejemplo n.º 1
0
                    "-o ConnectTimeout=%d -o ServerAliveInterval=%d "
                    "-l %s -p %d")
    assert isinstance(connect_timeout, (int, long))
    assert connect_timeout > 0  # can't disable the timeout
    return base_command % (opts, hosts_file, connect_timeout,
                           alive_interval, user, port)


make_ssh_command = utils.import_site_function(
    __file__, "autotest.server.hosts.site_host", "make_ssh_command",
    _make_ssh_cmd_default)


# import site specific Host class
SiteHost = utils.import_site_class(
    __file__, "autotest.server.hosts.site_host", "SiteHost",
    remote.RemoteHost)


class AbstractSSHHost(SiteHost):

    """
    This class represents a generic implementation of most of the
    framework necessary for controlling a host via ssh. It implements
    almost all of the abstract Host methods, except for the core
    Host.run method.
    """

    def _initialize(self, hostname, user="******", port=22, password="",
                    *args, **dargs):
        super(AbstractSSHHost, self)._initialize(hostname=hostname,
Ejemplo n.º 2
0
    base_command = ("/usr/bin/ssh -a -x %s -o StrictHostKeyChecking=no "
                    "-o UserKnownHostsFile=%s -o BatchMode=yes "
                    "-o ConnectTimeout=%d -o ServerAliveInterval=%d "
                    "-l %s -p %d")
    assert isinstance(connect_timeout, (int, long))
    assert connect_timeout > 0  # can't disable the timeout
    return base_command % (opts, hosts_file, connect_timeout, alive_interval,
                           user, port)


make_ssh_command = utils.import_site_function(
    __file__, "autotest.server.hosts.site_host", "make_ssh_command",
    _make_ssh_cmd_default)

# import site specific Host class
SiteHost = utils.import_site_class(__file__, "autotest.server.hosts.site_host",
                                   "SiteHost", remote.RemoteHost)


class AbstractSSHHost(SiteHost):
    """
    This class represents a generic implementation of most of the
    framework necessary for controlling a host via ssh. It implements
    almost all of the abstract Host methods, except for the core
    Host.run method.
    """
    def _initialize(self,
                    hostname,
                    user="******",
                    port=22,
                    password="",
                    *args,