OLD | NEW |
1 import os, time, types, socket, shutil, glob, logging, traceback | 1 import os, time, types, socket, shutil, glob, logging, traceback |
2 from autotest_lib.client.common_lib import autotemp, error, logging_manager | 2 from autotest_lib.client.common_lib import autotemp, error, logging_manager |
3 from autotest_lib.server import utils, autotest | 3 from autotest_lib.server import utils, autotest |
4 from autotest_lib.server.hosts import remote | 4 from autotest_lib.server.hosts import remote |
5 from autotest_lib.client.common_lib.global_config import global_config | 5 from autotest_lib.client.common_lib.global_config import global_config |
6 | 6 |
7 | 7 |
8 get_value = global_config.get_config_value | 8 get_value = global_config.get_config_value |
9 enable_master_ssh = get_value('AUTOSERV', 'enable_master_ssh', type=bool, | 9 enable_master_ssh = get_value('AUTOSERV', 'enable_master_ssh', type=bool, |
10 default=False) | 10 default=False) |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 delete_flag = "" | 108 delete_flag = "" |
109 if preserve_symlinks: | 109 if preserve_symlinks: |
110 symlink_flag = "" | 110 symlink_flag = "" |
111 else: | 111 else: |
112 symlink_flag = "-L" | 112 symlink_flag = "-L" |
113 command = "rsync %s %s --timeout=1800 --rsh='%s' -az %s %s" | 113 command = "rsync %s %s --timeout=1800 --rsh='%s' -az %s %s" |
114 return command % (symlink_flag, delete_flag, ssh_cmd, | 114 return command % (symlink_flag, delete_flag, ssh_cmd, |
115 " ".join(sources), dest) | 115 " ".join(sources), dest) |
116 | 116 |
117 | 117 |
| 118 def _make_ssh_cmd(self, cmd): |
| 119 """ |
| 120 Create a base ssh command string for the host which can be used |
| 121 to run commands directly on the machine |
| 122 """ |
| 123 base_cmd = make_ssh_command(user=self.user, port=self.port, |
| 124 opts=self.master_ssh_option, |
| 125 hosts_file=self.known_hosts_fd) |
| 126 |
| 127 return '%s %s "%s"' % (base_cmd, self.hostname, utils.sh_escape(cmd)) |
| 128 |
118 def _make_scp_cmd(self, sources, dest): | 129 def _make_scp_cmd(self, sources, dest): |
119 """ | 130 """ |
120 Given a list of source paths and a destination path, produces the | 131 Given a list of source paths and a destination path, produces the |
121 appropriate scp command for encoding it. Remote paths must be | 132 appropriate scp command for encoding it. Remote paths must be |
122 pre-encoded. | 133 pre-encoded. |
123 """ | 134 """ |
124 command = ("scp -rq %s -o StrictHostKeyChecking=no " | 135 command = ("scp -rq %s -o StrictHostKeyChecking=no " |
125 "-o UserKnownHostsFile=%s -P %d %s '%s'") | 136 "-o UserKnownHostsFile=%s -P %d %s '%s'") |
126 return command % (self.master_ssh_option, self.known_hosts_fd, | 137 return command % (self.master_ssh_option, self.known_hosts_fd, |
127 self.port, " ".join(sources), dest) | 138 self.port, " ".join(sources), dest) |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 | 594 |
584 This is useful if the test SSHes to the machine, then reinstalls it, | 595 This is useful if the test SSHes to the machine, then reinstalls it, |
585 then SSHes to it again. It can be called after the reinstall to | 596 then SSHes to it again. It can be called after the reinstall to |
586 reduce the spam in the logs. | 597 reduce the spam in the logs. |
587 """ | 598 """ |
588 logging.info("Clearing known hosts for host '%s', file '%s'.", | 599 logging.info("Clearing known hosts for host '%s', file '%s'.", |
589 self.hostname, self.known_hosts_fd) | 600 self.hostname, self.known_hosts_fd) |
590 # Clear out the file by opening it for writing and then closing. | 601 # Clear out the file by opening it for writing and then closing. |
591 fh = open(self.known_hosts_fd, "w") | 602 fh = open(self.known_hosts_fd, "w") |
592 fh.close() | 603 fh.close() |
OLD | NEW |