=== modified file 'lava_dispatcher/device/fastmodel.py'
@@ -179,7 +179,7 @@
"-C motherboard.hostbridge.userNetPorts='5555=5555' %s") % (
self._sim_binary, self._axf, self._sd_image, options)
- def power_off(self, proc):
+ def _power_off(self, proc):
if proc is not None:
proc.close()
if self._sim_proc is not None:
=== modified file 'lava_dispatcher/device/master.py'
@@ -77,7 +77,7 @@
self._boot_linaro_image()
return self.proc
- def power_off(self, proc):
+ def _power_off(self, proc):
# we always leave master image devices powered on
pass
=== modified file 'lava_dispatcher/device/qemu.py'
@@ -59,7 +59,7 @@
ensure_directory(path)
yield path
- def power_off(self, proc):
+ def _power_off(self, proc):
if proc is not None:
proc.close()
=== modified file 'lava_dispatcher/device/target.py'
@@ -73,10 +73,10 @@
"""
raise NotImplementedError('power_on')
- def power_off(self, proc):
- """ responsible for powering off the target device
+ def _power_off(self, proc):
+ """ responsible for powering off the target device.
"""
- raise NotImplementedError('power_off')
+ raise NotImplementedError('_power_off')
def deploy_linaro(self, hwpack, rfs):
raise NotImplementedError('deploy_image')
@@ -87,6 +87,22 @@
def deploy_linaro_prebuilt(self, image):
raise NotImplementedError('deploy_linaro_prebuilt')
+ def power_off(self, proc):
+ """ tries to safely power off the device by running a sync
+ operation first
+ """
+ from lava_dispatcher.client.base import CommandRunner
+ runner = CommandRunner(
+ proc,
+ self.deployment_data['TESTER_PS1_PATTERN'],
+ self.deployment_data['TESTER_PS1_INCLUDES_RC'])
+ try:
+ logging.info('attempting a filesystem sync before power_off')
+ runner.run('sync', timeout=20)
+ except:
+ logging.exception('calling sync failed')
+ self._power_off(proc)
+
@contextlib.contextmanager
def file_system(self, partition, directory):
""" Allows the caller to interact directly with a directory on
@@ -121,8 +137,6 @@
yield runner
finally:
if proc and runner:
- logging.info('attempting a filesystem sync before power_off')
- runner.run('sync', timeout=20)
self.power_off(proc)
def get_test_data_attachments(self):