diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 406: all power_off logic requires a sync

Message ID 20121017142313.5825.21669.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Andy Doan Oct. 17, 2012, 2:23 p.m. UTC
------------------------------------------------------------
revno: 406
committer: Andy Doan <andy.doan@linaro.org>
branch nick: trunk
timestamp: Tue 2012-10-16 22:45:38 -0500
message:
  all power_off logic requires a sync
  
  We missed a case where we weren't doing a sync before calling power_off.
  This was causing results for FastModels to not get flushed to disk.
modified:
  lava_dispatcher/device/fastmodel.py
  lava_dispatcher/device/master.py
  lava_dispatcher/device/qemu.py
  lava_dispatcher/device/target.py


--
lp:lava-dispatcher
https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk

You are subscribed to branch lp:lava-dispatcher.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'lava_dispatcher/device/fastmodel.py'
--- lava_dispatcher/device/fastmodel.py	2012-10-17 03:45:38 +0000
+++ lava_dispatcher/device/fastmodel.py	2012-10-17 03:45:38 +0000
@@ -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'
--- lava_dispatcher/device/master.py	2012-10-16 02:31:45 +0000
+++ lava_dispatcher/device/master.py	2012-10-17 03:45:38 +0000
@@ -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'
--- lava_dispatcher/device/qemu.py	2012-10-16 00:00:24 +0000
+++ lava_dispatcher/device/qemu.py	2012-10-17 03:45:38 +0000
@@ -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'
--- lava_dispatcher/device/target.py	2012-10-14 22:11:42 +0000
+++ lava_dispatcher/device/target.py	2012-10-17 03:45:38 +0000
@@ -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):