← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~allenap/maas/reconcile-arch into lp:maas

 

Gavin Panella has proposed merging lp:~allenap/maas/reconcile-arch into lp:maas.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~allenap/maas/reconcile-arch/+merge/99768
-- 
https://code.launchpad.net/~allenap/maas/reconcile-arch/+merge/99768
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~allenap/maas/reconcile-arch into lp:maas.
=== modified file 'src/maastesting/management/commands/reconcile.py'
--- src/maastesting/management/commands/reconcile.py	2012-03-22 15:27:57 +0000
+++ src/maastesting/management/commands/reconcile.py	2012-03-28 15:54:23 +0000
@@ -34,13 +34,20 @@
     )
 
 
+ARCHITECTURE_GUESSES = {
+    "i386": models.ARCHITECTURE.i386,
+    "amd64": models.ARCHITECTURE.amd64,
+    "x86_64": models.ARCHITECTURE.amd64,
+    }
+
+
 def guess_architecture_from_profile(profile_name):
     """
     This attempts to obtain the architecture from a Cobbler profile name. The
     naming convention for profile names is "maas-${series}-${arch}".
     """
-    for architecture, _ in models.ARCHITECTURE_CHOICES:
-        if architecture in profile_name:
+    for guess, architecture in ARCHITECTURE_GUESSES.items():
+        if guess in profile_name:
             return architecture
     else:
         return None
@@ -52,6 +59,7 @@
     nodes_remote = papi.get_nodes()
 
     missing_local = set(nodes_remote).difference(nodes_local)
+    missing_local.discard("default")
     for name in missing_local:
         print("remote:", name)
         remote_node = nodes_remote[name]

=== added directory 'src/maastesting/management/commands/tests'
=== added file 'src/maastesting/management/commands/tests/__init__.py'
=== added file 'src/maastesting/management/commands/tests/test_reconcile.py'
--- src/maastesting/management/commands/tests/test_reconcile.py	1970-01-01 00:00:00 +0000
+++ src/maastesting/management/commands/tests/test_reconcile.py	2012-03-28 15:54:23 +0000
@@ -0,0 +1,27 @@
+# Copyright 2012 Canonical Ltd.  This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Tests for `maastesting.management.commands.reconcile`."""
+
+from __future__ import (
+    print_function,
+    unicode_literals,
+    )
+
+__metaclass__ = type
+__all__ = []
+
+from maastesting.testcase import TestCase
+from maastesting.management.commands.reconcile import (
+    guess_architecture_from_profile,
+    )
+
+
+class TestFunctions(TestCase):
+
+    def test_guess_architecture_from_profile(self):
+        guess = guess_architecture_from_profile
+        self.assertEqual("i386", guess("a-i386-profile"))
+        self.assertEqual("amd64", guess("amd64-profile"))
+        self.assertEqual("amd64", guess("profile-for-x86_64"))
+        self.assertEqual(None, guess("profile-for-arm"))


Follow ups