Hi Lucas,

Thanks for help us on this issue.

We found the previous patch only fixed a part of our problem. We just found
there are occurrences inside server test control files which called
hosts.create_host(hostname) without properly passed in ssh options. And I do
not want to touch the test control files at all.

So here is a solution, my previous changes to SSHHost is reverted in this
patch, since it is not necessary any more.
I tested this change with both client and server side sleeptest against a
remote VM ( on port other than 22).


Index: server/hosts/factory.py
diff --git a/server/hosts/factory.py b/server/hosts/factory.py
index 
8e5ba66350c4d948d1927e66a41d68e4d4e3822b..f1a054f590823f1831e7336e1413ea0b92e2380d
100644
--- a/server/hosts/factory.py
+++ b/server/hosts/factory.py
@@ -68,6 +68,10 @@ def create_host(
     site_factory.postprocess_classes(classes, hostname,
                                      auto_monitor=auto_monitor, **args)

+    args['user'] = ssh_user
+    args['port'] = ssh_port
+    args['password'] = ssh_pass
+
     # create a custom host class for this machine and return an instance of it
     host_class = type("%s_host" % hostname, tuple(classes), {})
     host_instance = host_class(hostname, **args)
Index: server/hosts/ssh_host.py
diff --git a/server/hosts/ssh_host.py b/server/hosts/ssh_host.py
index 
fdf6a8c9014b49c58f41cc7b3eb18bdd01042d2a..2f5a08093e75c31f72984c1f83999d9a2d816288
100644
--- a/server/hosts/ssh_host.py
+++ b/server/hosts/ssh_host.py
@@ -38,17 +38,14 @@ class SSHHost(abstract_ssh.AbstractSSHHost):
     implement the unimplemented methods in parent classes.
     """

-    def _initialize(self, hostname, user="root", port=22, password="",
-                    *args, **dargs):
+    def _initialize(self, hostname, *args, **dargs):
         """
         Construct a SSHHost object

         Args:
                 hostname: network hostname or address of remote machine
         """
-        super(SSHHost, self)._initialize(hostname=hostname, user=user,
-                                         port=port, password=password,
-                                         *args, **dargs)
+        super(SSHHost, self)._initialize(hostname=hostname, *args, **dargs)
         self.setup_ssh()


Index: server/server_job.py
diff --git a/server/server_job.py b/server/server_job.py
index 
6ef59debc57b8b2d9d2abc662c54711cc5b9fa38..efc88d619816cb2f8e62ab0c4def92842e682771
100644
--- a/server/server_job.py
+++ b/server/server_job.py
@@ -985,6 +985,9 @@ class base_server_job(base_job.base_job):
         namespace['autotest'].Autotest.job = self
         # server.hosts.base_classes.Host uses .job.
         namespace['hosts'].Host.job = self
+        namespace['hosts'].factory.ssh_user = self._ssh_user
+        namespace['hosts'].factory.ssh_port = self._ssh_port
+        namespace['hosts'].factory.ssh_pass = self._ssh_pass


     def _execute_code(self, code_file, namespace, protect=True):





On Thu, Nov 18, 2010 at 10:33 AM, Eric Li(李咏竹) <[email protected]> wrote:

> When we started using autotest to run test against a VM based chromium os,
> we found autotest was not able to handle ssh port other than 22, autoserv
> --ssh-port did not work as it suppose to.
>
> It turned our the ssh options were not properly passed into SSHHost class.
>
> Index: server/hosts/ssh_host.py
> diff --git a/server/hosts/ssh_host.py b/server/hosts/ssh_host.py
> index 
> 2f5a08093e75c31f72984c1f83999d9a2d816288..fdf6a8c9014b49c58f41cc7b3eb18bdd01042d2a
>  100644
> --- a/server/hosts/ssh_host.py
> +++ b/server/hosts/ssh_host.py
> @@ -38,14 +38,17 @@ class SSHHost(abstract_ssh.AbstractSSHHost):
>      implement the unimplemented methods in parent classes.
>      """
>
> -    def _initialize(self, hostname, *args, **dargs):
> +    def _initialize(self, hostname, user="root", port=22, password="",
> +                    *args, **dargs):
>          """
>          Construct a SSHHost object
>
>          Args:
>                  hostname: network hostname or address of remote machine
>          """
> -        super(SSHHost, self)._initialize(hostname=hostname, *args, **dargs)
> +        super(SSHHost, self)._initialize(hostname=hostname, user=user,
> +                                         port=port, password=password,
> +                                         *args, **dargs)
>          self.setup_ssh()
>
>
>
> --
> Eric Li
> 李咏竹
> Google Kirkland
>
>
>


-- 
Eric Li
李咏竹
Google Kirkland
Index: server/hosts/factory.py
diff --git a/server/hosts/factory.py b/server/hosts/factory.py
index 8e5ba66350c4d948d1927e66a41d68e4d4e3822b..f1a054f590823f1831e7336e1413ea0b92e2380d 100644
--- a/server/hosts/factory.py
+++ b/server/hosts/factory.py
@@ -68,6 +68,10 @@ def create_host(
     site_factory.postprocess_classes(classes, hostname,
                                      auto_monitor=auto_monitor, **args)
 
+    args['user'] = ssh_user
+    args['port'] = ssh_port
+    args['password'] = ssh_pass
+
     # create a custom host class for this machine and return an instance of it
     host_class = type("%s_host" % hostname, tuple(classes), {})
     host_instance = host_class(hostname, **args)
Index: server/hosts/ssh_host.py
diff --git a/server/hosts/ssh_host.py b/server/hosts/ssh_host.py
index fdf6a8c9014b49c58f41cc7b3eb18bdd01042d2a..2f5a08093e75c31f72984c1f83999d9a2d816288 100644
--- a/server/hosts/ssh_host.py
+++ b/server/hosts/ssh_host.py
@@ -38,17 +38,14 @@ class SSHHost(abstract_ssh.AbstractSSHHost):
     implement the unimplemented methods in parent classes.
     """
 
-    def _initialize(self, hostname, user="root", port=22, password="",
-                    *args, **dargs):
+    def _initialize(self, hostname, *args, **dargs):
         """
         Construct a SSHHost object
 
         Args:
                 hostname: network hostname or address of remote machine
         """
-        super(SSHHost, self)._initialize(hostname=hostname, user=user,
-                                         port=port, password=password,
-                                         *args, **dargs)
+        super(SSHHost, self)._initialize(hostname=hostname, *args, **dargs)
         self.setup_ssh()
 
 
Index: server/server_job.py
diff --git a/server/server_job.py b/server/server_job.py
index 6ef59debc57b8b2d9d2abc662c54711cc5b9fa38..efc88d619816cb2f8e62ab0c4def92842e682771 100644
--- a/server/server_job.py
+++ b/server/server_job.py
@@ -985,6 +985,9 @@ class base_server_job(base_job.base_job):
         namespace['autotest'].Autotest.job = self
         # server.hosts.base_classes.Host uses .job.
         namespace['hosts'].Host.job = self
+        namespace['hosts'].factory.ssh_user = self._ssh_user
+        namespace['hosts'].factory.ssh_port = self._ssh_port
+        namespace['hosts'].factory.ssh_pass = self._ssh_pass
 
 
     def _execute_code(self, code_file, namespace, protect=True):
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to