← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~julian-edwards/maas/netboot-change-write-tftp into lp:maas

 

Julian Edwards has proposed merging lp:~julian-edwards/maas/netboot-change-write-tftp into lp:maas.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~julian-edwards/maas/netboot-change-write-tftp/+merge/111786

Encapsulate setting the netboot flag on a node in a method on Node.

This will allow extra actions to be taken in the future (for example, writing out tftp configs).
-- 
https://code.launchpad.net/~julian-edwards/maas/netboot-change-write-tftp/+merge/111786
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~julian-edwards/maas/netboot-change-write-tftp into lp:maas.
=== modified file 'src/maasserver/models/node.py'
--- src/maasserver/models/node.py	2012-06-18 03:20:51 +0000
+++ src/maasserver/models/node.py	2012-06-25 07:09:22 +0000
@@ -579,3 +579,8 @@
         self.owner = None
         self.token = None
         self.save()
+
+    def set_netboot(self, on=True):
+        """Set netboot on or off."""
+        self.netboot = on
+        self.save()

=== modified file 'src/maasserver/tests/test_node.py'
--- src/maasserver/tests/test_node.py	2012-06-20 17:43:45 +0000
+++ src/maasserver/tests/test_node.py	2012-06-25 07:09:22 +0000
@@ -771,3 +771,13 @@
         Node.objects.start_nodes(
             [node.system_id], node.owner, user_data=user_data)
         self.assertEqual(user_data, NodeUserData.objects.get_user_data(node))
+
+    def test_netboot_on(self):
+        node = factory.make_node(netboot=False)
+        node.set_netboot(True)
+        self.assertTrue(node.netboot)
+
+    def test_netboot_off(self):
+        node = factory.make_node(netboot=True)
+        node.set_netboot(False)
+        self.assertFalse(node.netboot)

=== modified file 'src/metadataserver/api.py'
--- src/metadataserver/api.py	2012-06-22 13:22:57 +0000
+++ src/metadataserver/api.py	2012-06-25 07:09:22 +0000
@@ -241,16 +241,14 @@
         it finishes installing itself.
         """
         node = get_queried_node(request, for_mac=mac)
-        node.netboot = False
-        node.save()
+        node.set_netboot(False)
         return rc.ALL_OK
 
     @api_exported('POST')
     def netboot_on(self, request, version=None, mac=None):
         """Turn on netboot on the node."""
         node = get_queried_node(request, for_mac=mac)
-        node.netboot = True
-        node.save()
+        node.set_netboot(True)
         return rc.ALL_OK
 
 
@@ -353,6 +351,5 @@
         it finishes installing itself.
         """
         node = get_object_or_404(Node, system_id=system_id)
-        node.netboot = False
-        node.save()
+        node.set_netboot(False)
         return rc.ALL_OK