1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-02-20 20:09:11 +00:00

LinuxDevice: fixed reboot.

- Deal with the dropped connection on issuing "reboot"
- Introduced a fixed initial delay before polling for connection to
  avoid re-connecting to adevice that is still in the process of
  shutting down.
This commit is contained in:
Sergei Trofimov 2016-02-22 09:33:35 +00:00
parent de133cddb4
commit 203a3f7d07
2 changed files with 14 additions and 4 deletions

View File

@ -632,7 +632,11 @@ class LinuxDevice(BaseLinuxDevice):
# Power control
def reset(self):
self.execute('reboot', as_root=True)
try:
self.execute('reboot', as_root=True)
except DeviceError as e:
if 'Connection dropped' not in e.message:
raise e
self._is_ready = False
def hard_reset(self):
@ -644,8 +648,15 @@ class LinuxDevice(BaseLinuxDevice):
else:
self.reset()
self.logger.debug('Waiting for device...')
# Wait a fixed delay before starting polling to give the device time to
# shut down, otherwise, might create the connection while it's still shutting
# down resulting in subsequenct connection failing.
initial_delay = 20
time.sleep(initial_delay)
boot_timeout = max(self.boot_timeout - initial_delay, 10)
start_time = time.time()
while (time.time() - start_time) < self.boot_timeout:
while (time.time() - start_time) < boot_timeout:
try:
s = socket.create_connection((self.host, self.port), timeout=5)
s.close()

View File

@ -172,9 +172,8 @@ class SshShell(object):
logger.warning('Could not get exit code for "{}",\ngot: "{}"'.format(command, exit_code_text))
return output
except EOF:
logger.error('Dropped connection detected.')
self.connection_lost = True
raise
raise DeviceError('Connection dropped.')
def logout(self):
logger.debug('Logging out {}@{}'.format(self.username, self.host))