launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #07077
[Merge] lp:~jtv/maas/clear-commissioning-results into lp:maas
Jeroen T. Vermeulen has proposed merging lp:~jtv/maas/clear-commissioning-results into lp:maas.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~jtv/maas/clear-commissioning-results/+merge/101507
As agreed with Julian, and documented in the basic-commissioning file. If a node has previous commissioning results, they get cleared out when the node goes into commissioning (again, in this case).
--
https://code.launchpad.net/~jtv/maas/clear-commissioning-results/+merge/101507
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jtv/maas/clear-commissioning-results into lp:maas.
=== modified file 'src/maasserver/models.py'
--- src/maasserver/models.py 2012-04-06 10:00:23 +0000
+++ src/maasserver/models.py 2012-04-11 08:40:25 +0000
@@ -622,6 +622,10 @@
def start_commissioning(self, user):
"""Install OS and self-test a new node."""
+ # Avoid circular imports.
+ from metadataserver.models import NodeCommissionResult
+
+ NodeCommissionResult.objects.clear_results(self)
self.status = NODE_STATUS.COMMISSIONING
self.owner = user
self.save()
=== modified file 'src/maasserver/tests/test_models.py'
--- src/maasserver/tests/test_models.py 2012-04-10 07:21:07 +0000
+++ src/maasserver/tests/test_models.py 2012-04-11 08:40:25 +0000
@@ -60,7 +60,10 @@
from maasserver.testing.enum import map_enum
from maasserver.testing.factory import factory
from maasserver.testing.testcase import TestCase
-from metadataserver.models import NodeUserData
+from metadataserver.models import (
+ NodeCommissionResult,
+ NodeUserData,
+ )
from piston.models import (
Consumer,
KEY_SIZE,
@@ -285,6 +288,24 @@
commissioning_user_data,
NodeUserData.objects.get_user_data(node))
+ def test_start_commissioning_clears_node_commissioning_results(self):
+ node = factory.make_node(status=NODE_STATUS.DECLARED)
+ NodeCommissionResult.objects.store_data(
+ node, factory.getRandomString(), factory.getRandomString())
+ node.start_commissioning(factory.make_admin())
+ self.assertItemsEqual(
+ [], NodeCommissionResult.objects.filter(node=node))
+
+ def test_start_commissioning_ignores_other_commissioning_results(self):
+ node = factory.make_node()
+ filename = factory.getRandomString()
+ text = factory.getRandomString()
+ NodeCommissionResult.objects.store_data(node, filename, text)
+ other_node = factory.make_node(status=NODE_STATUS.DECLARED)
+ other_node.start_commissioning(factory.make_admin())
+ self.assertEqual(
+ text, NodeCommissionResult.objects.get_data(node, filename))
+
def test_full_clean_checks_status_transition_and_raises_if_invalid(self):
# RETIRED -> ALLOCATED is an invalid transition.
node = factory.make_node(