mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-09-01 19:02:31 +01:00
Fixing reboot on Linux devices [part 2]
- connect() to device before issuing the initial reboot, as soft reset requires a device connection. - boot() has been implemented to wait properly for the device to reboot after reset. - port now defaults to 22 rather than being left unset, as need something to connect to when polling for device after reboot. - Only use -P option for scp when port is *not* 22; as that option appears to cause intermittent issues with default scp on Ubuntu 12.04
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
# pylint: disable=E1101
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
import socket
|
||||
from collections import namedtuple
|
||||
from subprocess import CalledProcessError
|
||||
|
||||
@@ -743,12 +745,14 @@ class LinuxDevice(BaseLinuxDevice):
|
||||
Parameter('username', mandatory=True, description='User name for the account on the device.'),
|
||||
Parameter('password', description='Password for the account on the device (for password-based auth).'),
|
||||
Parameter('keyfile', description='Keyfile to be used for key-based authentication.'),
|
||||
Parameter('port', kind=int, description='SSH port number on the device.'),
|
||||
Parameter('port', kind=int, default=22, description='SSH port number on the device.'),
|
||||
Parameter('password_prompt', default='[sudo] password',
|
||||
description='Prompt presented by sudo when requesting the password.'),
|
||||
|
||||
Parameter('use_telnet', kind=boolean, default=False,
|
||||
description='Optionally, telnet may be used instead of ssh, though this is discouraged.'),
|
||||
Parameter('boot_timeout', kind=int, default=120,
|
||||
description='How long to try to connect to the device after a reboot.'),
|
||||
|
||||
Parameter('working_directory', default=None,
|
||||
description='''
|
||||
@@ -823,6 +827,19 @@ class LinuxDevice(BaseLinuxDevice):
|
||||
|
||||
def boot(self, **kwargs):
|
||||
self.reset()
|
||||
self.logger.debug('Waiting for device...')
|
||||
start_time = time.time()
|
||||
while (time.time() - start_time) < self.boot_timeout:
|
||||
try:
|
||||
s = socket.create_connection((self.host, self.port), timeout=5)
|
||||
s.close()
|
||||
break
|
||||
except socket.timeout:
|
||||
pass
|
||||
except socket.error:
|
||||
time.sleep(5)
|
||||
else:
|
||||
raise DeviceError('Could not connect to {} after reboot'.format(self.host))
|
||||
|
||||
def connect(self): # NOQA pylint: disable=R0912
|
||||
self.shell = SshShell(password_prompt=self.password_prompt, timeout=self.default_timeout)
|
||||
|
Reference in New Issue
Block a user