Merge remote branch 'cros/upstream' into tempbranch2
Merged to trunk@4816.
BUG=
TEST=we will build a new autotest server instance, and keep cautotest running and then later do a cname switch.
Review URL: http://codereview.chromium.org/3511003
Change-Id: Iee5f52f45f28f84927d6c6f9a74edc370d40288a
diff --git a/server/hosts/remote.py b/server/hosts/remote.py
index b692480..e46bc1b 100644
--- a/server/hosts/remote.py
+++ b/server/hosts/remote.py
@@ -1,7 +1,7 @@
"""This class defines the Remote host class, mixing in the SiteHost class
if it is available."""
-import os, logging
+import os, logging, urllib
from autotest_lib.client.common_lib import error
from autotest_lib.server import utils
from autotest_lib.server.hosts import base_classes, bootloader
@@ -25,6 +25,7 @@
DEFAULT_REBOOT_TIMEOUT = base_classes.Host.DEFAULT_REBOOT_TIMEOUT
LAST_BOOT_TAG = object()
+ DEFAULT_HALT_TIMEOUT = 2 * 60
VAR_LOG_MESSAGES_COPY_PATH = "/var/log/messages.autotest_start"
@@ -88,6 +89,12 @@
self.run('echo b > /proc/sysrq-trigger &')
+ def halt(self, timeout=DEFAULT_HALT_TIMEOUT, wait=True):
+ self.run('/sbin/halt')
+ if wait:
+ self.wait_down(timeout=timeout)
+
+
def reboot(self, timeout=DEFAULT_REBOOT_TIMEOUT, label=LAST_BOOT_TAG,
kernel_args=None, wait=True, fastsync=False,
reboot_cmd=None, **dargs):
@@ -213,6 +220,21 @@
return None
+ def get_all_labels(self):
+ """
+ Return all labels, or empty list if label is not set.
+ """
+ if self.job:
+ keyval_path = os.path.join(self.job.resultdir, 'host_keyvals',
+ self.hostname)
+ keyvals = utils.read_keyval(keyval_path)
+ all_labels = keyvals.get('labels', '')
+ if all_labels:
+ all_labels = all_labels.split(',')
+ return [urllib.unquote(label) for label in all_labels]
+ return []
+
+
def delete_tmp_dir(self, tmpdir):
"""
Delete the given temporary directory on the remote machine.