Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(524)

Side by Side Diff: server/hosts/remote.py

Issue 3541002: Revert "Merge remote branch 'cros/upstream' into tempbranch2" (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git
Patch Set: Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « server/git_kernel.py ('k') | server/hosts/serial.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
29 28
30 VAR_LOG_MESSAGES_COPY_PATH = "/var/log/messages.autotest_start" 29 VAR_LOG_MESSAGES_COPY_PATH = "/var/log/messages.autotest_start"
31 30
32 def _initialize(self, hostname, autodir=None, *args, **dargs): 31 def _initialize(self, hostname, autodir=None, *args, **dargs):
33 super(RemoteHost, self)._initialize(*args, **dargs) 32 super(RemoteHost, self)._initialize(*args, **dargs)
34 33
35 self.hostname = hostname 34 self.hostname = hostname
36 self.autodir = autodir 35 self.autodir = autodir
37 self.tmp_dirs = [] 36 self.tmp_dirs = []
38 37
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 where autotest is installed. Called in server/autotest.py 81 where autotest is installed. Called in server/autotest.py
83 after a successful install 82 after a successful install
84 """ 83 """
85 self.autodir = autodir 84 self.autodir = autodir
86 85
87 86
88 def sysrq_reboot(self): 87 def sysrq_reboot(self):
89 self.run('echo b > /proc/sysrq-trigger &') 88 self.run('echo b > /proc/sysrq-trigger &')
90 89
91 90
92 def halt(self, timeout=DEFAULT_HALT_TIMEOUT, wait=True):
93 self.run('/sbin/halt')
94 if wait:
95 self.wait_down(timeout=timeout)
96
97
98 def reboot(self, timeout=DEFAULT_REBOOT_TIMEOUT, label=LAST_BOOT_TAG, 91 def reboot(self, timeout=DEFAULT_REBOOT_TIMEOUT, label=LAST_BOOT_TAG,
99 kernel_args=None, wait=True, fastsync=False, 92 kernel_args=None, wait=True, fastsync=False,
100 reboot_cmd=None, **dargs): 93 reboot_cmd=None, **dargs):
101 """ 94 """
102 Reboot the remote host. 95 Reboot the remote host.
103 96
104 Args: 97 Args:
105 timeout - How long to wait for the reboot. 98 timeout - How long to wait for the reboot.
106 label - The label we should boot into. If None, we will 99 label - The label we should boot into. If None, we will
107 boot into the default kernel. If it's LAST_BOOT_TAG, 100 boot into the default kernel. If it's LAST_BOOT_TAG,
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 206
214 if self.job: 207 if self.job:
215 keyval_path = os.path.join(self.job.resultdir, 'host_keyvals', 208 keyval_path = os.path.join(self.job.resultdir, 'host_keyvals',
216 self.hostname) 209 self.hostname)
217 keyvals = utils.read_keyval(keyval_path) 210 keyvals = utils.read_keyval(keyval_path)
218 return keyvals.get('platform', None) 211 return keyvals.get('platform', None)
219 else: 212 else:
220 return None 213 return None
221 214
222 215
223 def get_all_labels(self):
224 """
225 Return all labels, or empty list if label is not set.
226 """
227 if self.job:
228 keyval_path = os.path.join(self.job.resultdir, 'host_keyvals',
229 self.hostname)
230 keyvals = utils.read_keyval(keyval_path)
231 all_labels = keyvals.get('labels', '')
232 if all_labels:
233 all_labels = all_labels.split(',')
234 return [urllib.unquote(label) for label in all_labels]
235 return []
236
237
238 def delete_tmp_dir(self, tmpdir): 216 def delete_tmp_dir(self, tmpdir):
239 """ 217 """
240 Delete the given temporary directory on the remote machine. 218 Delete the given temporary directory on the remote machine.
241 """ 219 """
242 self.run('rm -rf "%s"' % utils.sh_escape(tmpdir), ignore_status=True) 220 self.run('rm -rf "%s"' % utils.sh_escape(tmpdir), ignore_status=True)
243 self.tmp_dirs.remove(tmpdir) 221 self.tmp_dirs.remove(tmpdir)
244 222
245 223
246 def check_uptime(self): 224 def check_uptime(self):
247 """ 225 """
(...skipping 15 matching lines...) Expand all
263 """ 241 """
264 processes = self.get_wait_up_processes() 242 processes = self.get_wait_up_processes()
265 if len(processes) == 0: 243 if len(processes) == 0:
266 return True # wait up processes aren't being used 244 return True # wait up processes aren't being used
267 for procname in processes: 245 for procname in processes:
268 exit_status = self.run("{ ps -e || ps; } | grep '%s'" % procname, 246 exit_status = self.run("{ ps -e || ps; } | grep '%s'" % procname,
269 ignore_status=True).exit_status 247 ignore_status=True).exit_status
270 if exit_status == 0: 248 if exit_status == 0:
271 return True 249 return True
272 return False 250 return False
OLDNEW
« no previous file with comments | « server/git_kernel.py ('k') | server/hosts/serial.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698