launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #15155
[Merge] lp:~allenap/maas/fast-path-installer-tag into lp:maas
Gavin Panella has proposed merging lp:~allenap/maas/fast-path-installer-tag into lp:maas.
Commit message:
New method to request the use of the traditional installer on a node.
This merely records the state; as yet it does nothing in practice.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~allenap/maas/fast-path-installer-tag/+merge/148155
Adds a method to Node to select the use of the traditional—not Fast Path—installer, and another method to query this state. I may change the latter to be a property so that it is not accidentally misused in a template (i.e. `node.a_method` is always truthy; note the missing braces to actually call a_method). This can wait for a subsequent branch though.
--
https://code.launchpad.net/~allenap/maas/fast-path-installer-tag/+merge/148155
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~allenap/maas/fast-path-installer-tag into lp:maas.
=== modified file 'src/maasserver/models/node.py'
--- src/maasserver/models/node.py 2013-01-14 22:06:12 +0000
+++ src/maasserver/models/node.py 2013-02-13 11:40:35 +0000
@@ -812,3 +812,22 @@
def set_hardware_details(self, xmlbytes):
"""Set the `lshw -xml` output"""
update_hardware_details(self, xmlbytes, Tag.objects)
+
+ def should_use_traditional_installer(self):
+ """Should this node be installed with the traditional installer?
+
+ By default, nodes should be installed with the Fast Path installer.
+ """
+ return self.tags.filter(name="use-traditional-installer").exists()
+
+ def use_traditional_installer(self, enabled=True):
+ """Set this node to be installed with the traditional installer.
+
+ By default, nodes should be installed with the Fast Path installer.
+ """
+ if enabled:
+ self.tags.get_or_create(name="use-traditional-installer")
+ else:
+ tag = self.tags.get(name="use-traditional-installer")
+ if tag is not None:
+ self.tags.remove(tag)
=== modified file 'src/maasserver/tests/test_node.py'
--- src/maasserver/tests/test_node.py 2012-12-19 12:23:48 +0000
+++ src/maasserver/tests/test_node.py 2013-02-13 11:40:35 +0000
@@ -35,6 +35,7 @@
MACAddress,
Node,
node as node_module,
+ Tag,
)
from maasserver.models.node import (
generate_hostname,
@@ -662,6 +663,38 @@
expected_hostname = '%s.%s' % (hostname_without_domain, domain)
self.assertEqual(expected_hostname, node.fqdn)
+ def test_should_use_traditional_installer_not_by_default(self):
+ node = factory.make_node()
+ self.assertFalse(node.should_use_traditional_installer())
+
+ def test_should_use_traditional_installer_when_tag_applies(self):
+ node = factory.make_node()
+ tag = factory.make_tag(name="use-traditional-installer")
+ tag.save()
+ node.tags.add(tag)
+ self.assertTrue(node.should_use_traditional_installer())
+
+ def test_use_traditional_installer(self):
+ node = factory.make_node()
+ self.assertFalse(node.should_use_traditional_installer())
+ node.use_traditional_installer()
+ self.assertTrue(node.should_use_traditional_installer())
+ node.use_traditional_installer(False)
+ self.assertFalse(node.should_use_traditional_installer())
+
+ def test_use_traditional_installer_manages_tag(self):
+ # use_traditional_installer() creates the use-traditional-installer
+ # tag when it is first needed, but does not remove it when it is no
+ # longer used by any node.
+ find_tag = lambda: list(
+ Tag.objects.filter(name="use-traditional-installer"))
+ self.assertEqual([], find_tag())
+ node = factory.make_node()
+ node.use_traditional_installer()
+ self.assertNotEqual([], find_tag())
+ node.use_traditional_installer(False)
+ self.assertNotEqual([], find_tag())
+
class NodeTransitionsTests(TestCase):
"""Test the structure of NODE_TRANSITIONS."""
Follow ups