| OLD | NEW |
| 1 """This class defines the Remote host class, mixing in the SiteHost class | 1 """This class defines the Remote host class, mixing in the SiteHost class |
| 2 if it is available.""" | 2 if it is available.""" |
| 3 | 3 |
| 4 import os, logging, urllib | 4 import os, logging, urllib |
| 5 from autotest_lib.client.common_lib import error | 5 from autotest_lib.client.common_lib import error |
| 6 from autotest_lib.server import utils | 6 from autotest_lib.server import utils |
| 7 from autotest_lib.server.hosts import base_classes, bootloader | 7 from autotest_lib.server.hosts import base_classes, bootloader |
| 8 | 8 |
| 9 | 9 |
| 10 class RemoteHost(base_classes.Host): | 10 class RemoteHost(base_classes.Host): |
| 11 """ | 11 """ |
| 12 This class represents a remote machine on which you can run | 12 This class represents a remote machine on which you can run |
| 13 programs. | 13 programs. |
| 14 | 14 |
| 15 It may be accessed through a network, a serial line, ... | 15 It may be accessed through a network, a serial line, ... |
| 16 It is not the machine autoserv is running on. | 16 It is not the machine autoserv is running on. |
| 17 | 17 |
| 18 Implementation details: | 18 Implementation details: |
| 19 This is an abstract class, leaf subclasses must implement the methods | 19 This is an abstract class, leaf subclasses must implement the methods |
| 20 listed here and in parent classes which have no implementation. They | 20 listed here and in parent classes which have no implementation. They |
| 21 may reimplement methods which already have an implementation. You | 21 may reimplement methods which already have an implementation. You |
| 22 must not instantiate this class but should instantiate one of those | 22 must not instantiate this class but should instantiate one of those |
| 23 leaf subclasses. | 23 leaf subclasses. |
| 24 """ | 24 """ |
| 25 | 25 |
| 26 DEFAULT_REBOOT_TIMEOUT = base_classes.Host.DEFAULT_REBOOT_TIMEOUT | 26 DEFAULT_REBOOT_TIMEOUT = base_classes.Host.DEFAULT_REBOOT_TIMEOUT |
| 27 LAST_BOOT_TAG = object() | 27 LAST_BOOT_TAG = object() |
| 28 DEFAULT_HALT_TIMEOUT = 2 * 60 | 28 DEFAULT_HALT_TIMEOUT = 2 * 60 |
| 29 | 29 |
| 30 VAR_LOG_MESSAGES_COPY_PATH = "/var/log/messages.autotest_start" | 30 VAR_LOG_MESSAGES_COPY_PATH = "/var/tmp/messages.autotest_start" |
| 31 | 31 |
| 32 def _initialize(self, hostname, autodir=None, *args, **dargs): | 32 def _initialize(self, hostname, autodir=None, *args, **dargs): |
| 33 super(RemoteHost, self)._initialize(*args, **dargs) | 33 super(RemoteHost, self)._initialize(*args, **dargs) |
| 34 | 34 |
| 35 self.hostname = hostname | 35 self.hostname = hostname |
| 36 self.autodir = autodir | 36 self.autodir = autodir |
| 37 self.tmp_dirs = [] | 37 self.tmp_dirs = [] |
| 38 | 38 |
| 39 | 39 |
| 40 def __repr__(self): | 40 def __repr__(self): |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 def get_all_labels(self): | 223 def get_all_labels(self): |
| 224 """ | 224 """ |
| 225 Return all labels, or empty list if label is not set. | 225 Return all labels, or empty list if label is not set. |
| 226 """ | 226 """ |
| 227 if self.job: | 227 if self.job: |
| 228 keyval_path = os.path.join(self.job.resultdir, 'host_keyvals', | 228 keyval_path = os.path.join(self.job.resultdir, 'host_keyvals', |
| 229 self.hostname) | 229 self.hostname) |
| 230 keyvals = utils.read_keyval(keyval_path) | 230 keyvals = utils.read_keyval(keyval_path) |
| 231 all_labels = keyvals.get('labels', '') | 231 all_labels = keyvals.get('labels', '') |
| 232 if all_labels: | 232 if all_labels: |
| 233 all_labels = all_labels.split(',') | 233 all_labels = all_labels.split(',') |
| 234 return [urllib.unquote(label) for label in all_labels] | 234 return [urllib.unquote(label) for label in all_labels] |
| 235 return [] | 235 return [] |
| 236 | 236 |
| 237 | 237 |
| 238 def delete_tmp_dir(self, tmpdir): | 238 def delete_tmp_dir(self, tmpdir): |
| 239 """ | 239 """ |
| 240 Delete the given temporary directory on the remote machine. | 240 Delete the given temporary directory on the remote machine. |
| 241 """ | 241 """ |
| 242 self.run('rm -rf "%s"' % utils.sh_escape(tmpdir), ignore_status=True) | 242 self.run('rm -rf "%s"' % utils.sh_escape(tmpdir), ignore_status=True) |
| 243 self.tmp_dirs.remove(tmpdir) | 243 self.tmp_dirs.remove(tmpdir) |
| 244 | 244 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 263 """ | 263 """ |
| 264 processes = self.get_wait_up_processes() | 264 processes = self.get_wait_up_processes() |
| 265 if len(processes) == 0: | 265 if len(processes) == 0: |
| 266 return True # wait up processes aren't being used | 266 return True # wait up processes aren't being used |
| 267 for procname in processes: | 267 for procname in processes: |
| 268 exit_status = self.run("{ ps -e || ps; } | grep '%s'" % procname, | 268 exit_status = self.run("{ ps -e || ps; } | grep '%s'" % procname, |
| 269 ignore_status=True).exit_status | 269 ignore_status=True).exit_status |
| 270 if exit_status == 0: | 270 if exit_status == 0: |
| 271 return True | 271 return True |
| 272 return False | 272 return False |
| OLD | NEW |