On Thu, Jan 14, 2010 at 4:30 PM, Steve Howard <[email protected]> wrote:

> Fix bug introduced into paramiko_host by recent changes to selectively
> disable rsync support (SVN rev 4077).  The new code makes SSH calls within
> _initialize(), but paramiko_host wasn't sufficiently initialized when the
> call was being made.  In general, executing remote commands within
> _initialize() is dangerous.  This change removes the new code from
> _initialize() and instead makes AbstractSSHHost compute the new information
> lazily.
>

Lazy init is definitely better in this case. Sorry about the breakage.

Darin


>
> Signed-off-by: Steve Howard <[email protected]>
>
> --- autotest/server/hosts/abstract_ssh.py       2010-01-11
> 15:32:34.000000000 -0800
> +++ autotest/server/hosts/abstract_ssh.py       2010-01-11
> 16:37:28.000000000 -0800
> @@ -35,20 +35,26 @@
>         self.user = user
>         self.port = port
>         self.password = password
> +        self._use_rsync = None
>
>         """
>         Master SSH connection background job, socket temp directory and
> socket
>         control path option. If master-SSH is enabled, these fields will be
>         initialized by start_master_ssh when a new SSH connection is
> initiated.
>         """
>         self.master_ssh_job = None
>         self.master_ssh_tempdir = None
>         self.master_ssh_option = ''
>
> +
> +    def use_rsync(self):
> +        if self._use_rsync is not None:
> +            return self._use_rsync
> +
>         # Check if rsync is available on the remote host. If it's not,
>         # don't try to use it for any future file transfers.
> -        self.use_rsync = self._check_rsync()
> -        if not self.use_rsync:
> +        self._use_rsync = self._check_rsync()
> +        if not self._use_rsync:
>             logging.warn("rsync not available on remote host %s --
> disabled",
>                          self.hostname)
>
> @@ -223,17 +229,17 @@
>         dest = os.path.abspath(dest)
>
>         # If rsync is disabled or fails, try scp.
> -        try_scp = not self.use_rsync
> -        if self.use_rsync:
> +        try_scp = True
> +        if self.use_rsync():
>             try:
>                 remote_source = self._encode_remote_paths(source)
>                 local_dest = utils.sh_escape(dest)
>                 rsync = self._make_rsync_cmd([remote_source], local_dest,
>                                              delete_dest,
> preserve_symlinks)
>                 utils.run(rsync)
> +                try_scp = False
>             except error.CmdError, e:
>                 logging.warn("trying scp, rsync failed: %s" % e)
> -                try_scp = True
>
>         if try_scp:
>             # scp has no equivalent to --delete, just drop the entire dest
> dir
> @@ -295,16 +301,16 @@
>         remote_dest = self._encode_remote_paths([dest])
>
>         # If rsync is disabled or fails, try scp.
> -        try_scp = not self.use_rsync
> -        if self.use_rsync:
> +        try_scp = True
> +        if self.use_rsync():
>             try:
>                 local_sources = [utils.sh_escape(path) for path in source]
>                 rsync = self._make_rsync_cmd(local_sources, remote_dest,
>                                              delete_dest,
> preserve_symlinks)
>                 utils.run(rsync)
> +                try_scp = False
>             except error.CmdError, e:
>                 logging.warn("trying scp, rsync failed: %s" % e)
> -                try_scp = True
>
>         if try_scp:
>             # scp has no equivalent to --delete, just drop the entire dest
> dir
> _______________________________________________
> Autotest mailing list
> [email protected]
> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
>
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to