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

Side by Side Diff: server/hosts/serial.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/hosts/remote.py ('k') | server/server_job.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 import os, sys, subprocess, logging 1 import os, sys, subprocess, logging
2 2
3 from autotest_lib.client.common_lib import utils, error 3 from autotest_lib.client.common_lib import utils, error
4 from autotest_lib.server import utils as server_utils 4 from autotest_lib.server import utils as server_utils
5 from autotest_lib.server.hosts import remote 5 from autotest_lib.server.hosts import remote
6 6
7 7
8 SiteHost = utils.import_site_class( 8 SiteHost = utils.import_site_class(
9 __file__, "autotest_lib.server.hosts.site_host", "SiteHost", 9 __file__, "autotest_lib.server.hosts.site_host", "SiteHost",
10 remote.RemoteHost) 10 remote.RemoteHost)
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 if not self.conmux_attach or not os.path.exists(self.conmux_attach): 107 if not self.conmux_attach or not os.path.exists(self.conmux_attach):
108 return False 108 return False
109 cmd = '%s %s echo %s 2> /dev/null' % (self.conmux_attach, 109 cmd = '%s %s echo %s 2> /dev/null' % (self.conmux_attach,
110 self.get_conmux_hostname(), 110 self.get_conmux_hostname(),
111 cmd) 111 cmd)
112 result = utils.system(cmd, ignore_status=True) 112 result = utils.system(cmd, ignore_status=True)
113 return result == 0 113 return result == 0
114 114
115 115
116 def hardreset(self, timeout=DEFAULT_REBOOT_TIMEOUT, wait=True, 116 def hardreset(self, timeout=DEFAULT_REBOOT_TIMEOUT, wait=True,
117 conmux_command='hardreset', num_attempts=1, halt=False, 117 conmux_command='hardreset', num_attempts=1,
118 **wait_for_restart_kwargs): 118 **wait_for_restart_kwargs):
119 """ 119 """
120 Reach out and slap the box in the power switch. 120 Reach out and slap the box in the power switch.
121 @params conmux_command: The command to run via the conmux interface 121 @params conmux_command: The command to run via the conmux interface
122 @params timeout: timelimit in seconds before the machine is 122 @params timeout: timelimit in seconds before the machine is
123 considered unreachable 123 considered unreachable
124 @params wait: Whether or not to wait for the machine to reboot 124 @params wait: Whether or not to wait for the machine to reboot
125 @params num_attempts: Number of times to attempt hard reset erroring 125 @params num_attempts: Number of times to attempt hard reset erroring
126 on the last attempt. 126 on the last attempt.
127 @params halt: Halts the machine before hardresetting.
128 @params **wait_for_restart_kwargs: keyword arguments passed to 127 @params **wait_for_restart_kwargs: keyword arguments passed to
129 wait_for_restart() 128 wait_for_restart()
130 """ 129 """
131 conmux_command = "'~$%s'" % conmux_command 130 conmux_command = "'~$%s'" % conmux_command
132 131
133 # if the machine is up, grab the old boot id, otherwise use a dummy 132 # if the machine is up, grab the old boot id, otherwise use a dummy
134 # string and NOT None to ensure that wait_down always returns True, 133 # string and NOT None to ensure that wait_down always returns True,
135 # even if the machine comes back up before it's called 134 # even if the machine comes back up before it's called
136 try: 135 try:
137 old_boot_id = self.get_boot_id() 136 old_boot_id = self.get_boot_id()
138 except error.AutoservSSHTimeout: 137 except error.AutoservSSHTimeout:
139 old_boot_id = 'unknown boot_id prior to SerialHost.hardreset' 138 old_boot_id = 'unknown boot_id prior to SerialHost.hardreset'
140 139
141 def reboot(): 140 def reboot():
142 if halt:
143 self.halt()
144 if not self.run_conmux(conmux_command): 141 if not self.run_conmux(conmux_command):
145 self.record("ABORT", None, "reboot.start", 142 self.record("ABORT", None, "reboot.start",
146 "hard reset unavailable") 143 "hard reset unavailable")
147 raise error.AutoservUnsupportedError( 144 raise error.AutoservUnsupportedError(
148 'Hard reset unavailable') 145 'Hard reset unavailable')
149 self.record("GOOD", None, "reboot.start", "hard reset") 146 self.record("GOOD", None, "reboot.start", "hard reset")
150 if wait: 147 if wait:
151 warning_msg = ('Serial console failed to respond to hard reset ' 148 warning_msg = ('Serial console failed to respond to hard reset '
152 'attempt (%s/%s)') 149 'attempt (%s/%s)')
153 for attempt in xrange(num_attempts-1): 150 for attempt in xrange(num_attempts-1):
(...skipping 20 matching lines...) Expand all
174 if self.job: 171 if self.job:
175 self.job.disable_warnings("POWER_FAILURE") 172 self.job.disable_warnings("POWER_FAILURE")
176 try: 173 try:
177 if wait: 174 if wait:
178 self.log_reboot(reboot) 175 self.log_reboot(reboot)
179 else: 176 else:
180 reboot() 177 reboot()
181 finally: 178 finally:
182 if self.job: 179 if self.job:
183 self.job.enable_warnings("POWER_FAILURE") 180 self.job.enable_warnings("POWER_FAILURE")
OLDNEW
« no previous file with comments | « server/hosts/remote.py ('k') | server/server_job.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698