diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 490: Device version support for master images

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

Commit Message

Antonio Terceiro Dec. 7, 2012, 8:06 p.m. UTC
Merge authors:
  Antonio Terceiro (terceiro)
Related merge proposals:
  https://code.launchpad.net/~terceiro/lava-dispatcher/master-device-version/+merge/138463
  proposed by: Antonio Terceiro (terceiro)
------------------------------------------------------------
revno: 490 [merge]
fixes bug: https://launchpad.net/bugs/1073842
committer: Antonio Terceiro <antonio.terceiro@linaro.org>
branch nick: trunk
timestamp: Fri 2012-12-07 17:05:03 -0300
message:
  Device version support for master images
modified:
  lava_dispatcher/device/master.py
  lava_dispatcher/job.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/master.py'
--- lava_dispatcher/device/master.py	2012-12-05 19:10:40 +0000
+++ lava_dispatcher/device/master.py	2012-12-06 14:14:14 +0000
@@ -81,6 +81,7 @@ 
             }
 
         self.master_ip = None
+        self.device_version = None
 
         if config.pre_connect_command:
             logging_system(config.pre_connect_command)
@@ -88,6 +89,9 @@ 
         self.proc = self._connect_carefully(config.connection_command)
         atexit.register(self._close_logging_spawn)
 
+    def get_device_version(self):
+        return self.device_version
+
     def power_on(self):
         self._boot_linaro_image()
         return self.proc
@@ -400,6 +404,7 @@ 
             runner = MasterCommandRunner(self)
             try:
                 self.master_ip = runner.get_master_ip()
+                self.device_version = runner.get_device_version()
             except NetworkError as e:
                 msg = "Failed to get network up: " % e
                 logging.warning(msg)
@@ -518,6 +523,27 @@ 
         logging.debug("Master image IP is %s" % ip)
         return ip
 
+    def get_device_version(self):
+        pattern = 'device_version=(\d+-\d+/\d+-\d+)'
+        self.run("echo \"device_version="
+                 "$(lava-master-image-info --master-image-hwpack "
+                 "| sed 's/[^0-9-]//g; s/^-\+//')"
+                 "/"
+                 "$(lava-master-image-info --master-image-rootfs "
+                 "| sed 's/[^0-9-]//g; s/^-\+//')"
+                 "\"",
+                 [pattern, pexpect.EOF, pexpect.TIMEOUT],
+                 timeout = 5)
+
+        device_version = None
+        if self.match_id == 0:
+            device_version = self.match.group(1)
+            logging.debug('Master image version (hwpack/rootfs) is %s' % device_version)
+        else:
+            logging.warning('Could not determine image version!')
+
+        return device_version
+
     def has_partition_with_label(self, label):
         if not label:
             return False

=== modified file 'lava_dispatcher/job.py'
--- lava_dispatcher/job.py	2012-11-24 20:58:07 +0000
+++ lava_dispatcher/job.py	2012-12-07 19:59:19 +0000
@@ -148,7 +148,6 @@ 
 
         metadata = {
             'target.hostname': self.target,
-            'target.device_version': self.context.get_device_version(),
         }
 
         if 'device_type' in self.job_data:
@@ -232,6 +231,10 @@ 
             self.context.test_data.job_status = 'fail'
             raise
         finally:
+            device_version = self.context.get_device_version() or 'error'
+            self.context.test_data.add_metadata({
+                'target.device_version': device_version
+            })
             if submit_results:
                 params = submit_results.get('parameters', {})
                 action = lava_commands[submit_results['command']](