[autotest] Restart servod in `deploy servo`.
This changes `deploy servo` to unconditionally restart `servod` on
the target servo. This guarnatees that the cached GS URL in
`servod` gets cleared so that the USB stick can be re-imaged. It
also makes `deploy servo` into an easy UI to force restarting a
`servod` job for an arbitrary DUT.
BUG=chromium:879295
TEST=run `deploy servo` locally
Change-Id: If3143b12ec5713db649ba0268459fb44262606d0
Reviewed-on: https://chromium-review.googlesource.com/1236784
Tested-by: Richard Barnette <jrbarnette@chromium.org>
Reviewed-by: Congbin Guo <guocb@chromium.org>
diff --git a/server/hosts/cros_host.py b/server/hosts/cros_host.py
index a3581df..f7a248f 100644
--- a/server/hosts/cros_host.py
+++ b/server/hosts/cros_host.py
@@ -281,14 +281,11 @@
self.env['LIBC_FATAL_STDERR_'] = '1'
self._ssh_verbosity_flag = ssh_verbosity_flag
self._ssh_options = ssh_options
- self._servo_host = servo_host.create_servo_host(
+ self.set_servo_host(
+ servo_host.create_servo_host(
dut=self, servo_args=servo_args,
try_lab_servo=try_lab_servo,
- try_servo_repair=try_servo_repair)
- if self._servo_host is not None:
- self.servo = self._servo_host.get_servo()
- else:
- self.servo = None
+ try_servo_repair=try_servo_repair))
# TODO(waihong): Do the simplication on Chameleon too.
self._chameleon_host = chameleon_host.create_chameleon_host(
@@ -703,6 +700,18 @@
self.BOOT_TIMEOUT)
+ def set_servo_host(self, host):
+ """Set our servo host member, and associated servo.
+
+ @param host Our new `ServoHost`.
+ """
+ self._servo_host = host
+ if self._servo_host is not None:
+ self.servo = self._servo_host.get_servo()
+ else:
+ self.servo = None
+
+
def repair_servo(self):
"""
Confirm that servo is initialized and verified.
diff --git a/site_utils/deployment/install.py b/site_utils/deployment/install.py
index 497f64f..29d92c3 100644
--- a/site_utils/deployment/install.py
+++ b/site_utils/deployment/install.py
@@ -264,8 +264,22 @@
'afe_host': afe_host,
'host_info_store': afe_store.AfeStore(hostname, afe),
}
- servo_args = hosts.CrosHost.get_servo_arguments({})
- return hosts.create_host(machine_dict, servo_args=servo_args)
+ host = hosts.create_host(machine_dict)
+ # Stopping `servod` on the servo host will force `repair()` to
+ # restart it. We want that restart for a few reasons:
+ # + `servod` caches knowledge about the image on the USB stick.
+ # We want to clear the cache to force the USB stick to be
+ # re-imaged unconditionally.
+ # + If there's a problem with servod that verify and repair
+ # can't find, this provides a UI through which `servod` can
+ # be restarted.
+ servo = servo_host.ServoHost(
+ **servo_host.get_servo_args_for_host(host))
+ servo.run('stop servod PORT=%d' % servo.servo_port,
+ ignore_status=True)
+ servo.repair()
+ host.set_servo_host(servo)
+ return host
def _try_lock_host(afe_host):