[Branch,~linaro-validation/lava-test/trunk] Rev 124: Allow the user to pre-define analyzer_assigned_uuid

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

Commit Message

Zygmunt Krynicki March 6, 2012, 1:01 p.m.
------------------------------------------------------------
revno: 124
fixes bug: https://launchpad.net/bugs/934164
committer: Zygmunt Krynicki <zygmunt.krynicki@linaro.org>
branch nick: fix-934164
timestamp: Tue 2012-03-06 13:59:07 +0100
message:
  Allow the user to pre-define analyzer_assigned_uuid
modified:
  doc/changes.rst
  lava_test/commands.py
  lava_test/core/artifacts.py


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

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

Patch

=== modified file 'doc/changes.rst'
--- doc/changes.rst	2012-03-06 12:29:33 +0000
+++ doc/changes.rst	2012-03-06 12:59:07 +0000
@@ -6,6 +6,10 @@ 
 Version 0.5
 ===========
 
+ * Allow users to override ``analyzer_assigned_uuid`` by passing
+   ``--analyzer-assigned-uuid`` to the run command. This change fixes
+   https://bugs.launchpad.net/lava-dispatcher/+bug/934164
+
 .. _version_0_4:
 
 Version 0.4

=== modified file 'lava_test/commands.py'
--- lava_test/commands.py	2012-01-17 12:42:46 +0000
+++ lava_test/commands.py	2012-03-06 12:59:07 +0000
@@ -203,6 +203,17 @@ 
                                   " test results created on embedded devices"
                                   " that often have inaccurate real time"
                                   " clock settings."))
+        group.add_argument("--analyzer-assigned-uuid",
+                           default=None,
+                           metavar="UUID",
+                           help=("Set the analyzer_assigned_uuid to the specified value."
+                                 " This will prevent the test device from attempting"
+                                 " to generate an UUID by itself. This option may be"
+                                 " required if the test device has unreliable real"
+                                 " time clock (no battery backed, not ensure to be"
+                                 " up-to-date) and unreliable/random hardware ethernet "
+                                 " address."))
+
         group = parser.add_argument_group("complete bundle configuration")
         group.add_argument("-o", "--output",
                             default=None,
@@ -229,8 +240,14 @@ 
                                  "To provide multiple options, use quote character."
                                  "Example : lava-test run peacekeeper -t firefox.  "
                                  "Example of multiple options : lava-test run foo_test -t 'arg1 arg2'")
-
     def invoke_with_test(self, test):
+        # Validate analyzer_assigned_uuid
+        if self.args.analyzer_assigned_uuid:
+            import uuid
+            try:
+                self.analyzer_assigned_uuid=str(uuid.UUID(self.args.analyzer_assigned_uuid))
+            except ValueError as exc:
+                self.parser.error("--analyzer-assigned-uuid: %s" % exc)
         if not test.is_installed:
             raise LavaCommandError("The specified test is not installed")
         try:
@@ -246,7 +263,8 @@ 
         artifacts.create_initial_bundle(
             self.args.skip_software_context,
             self.args.skip_hardware_context,
-            self.args.trusted_time)
+            self.args.trusted_time,
+            self.args.analyzer_assigned_uuid)
         artifacts.save_bundle()
         if self.args.output:
             parse_results = test.parse(artifacts)

=== modified file 'lava_test/core/artifacts.py'
--- lava_test/core/artifacts.py	2011-09-12 09:19:10 +0000
+++ lava_test/core/artifacts.py	2012-03-06 12:59:07 +0000
@@ -137,7 +137,8 @@ 
     def create_initial_bundle(self,
                       skip_software_context=False,
                       skip_hardware_context=False,
-                      time_check_performed=False):
+                      time_check_performed=False,
+                      analyzer_assigned_uuid=None):
         """
         Create the bundle object.
 
@@ -150,7 +151,8 @@ 
         """
         TIMEFORMAT = '%Y-%m-%dT%H:%M:%SZ'
         # Generate UUID and analyzer_assigned_date for the test run
-        analyzer_assigned_uuid = str(uuid.uuid1())
+        if analyzer_assigned_uuid is None:
+            analyzer_assigned_uuid = str(uuid.uuid1())
         analyzer_assigned_date = datetime.datetime.utcnow()
         # Create basic test run structure
         test_run = {