← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~jameinel/maas/1.2-node-get-effective-kernel-options into lp:maas/1.2

 

John A Meinel has proposed merging lp:~jameinel/maas/1.2-node-get-effective-kernel-options into lp:maas/1.2.

Commit message:
Add Node.get_effective_kernel_options.

The first implementation only reads the global setting. Ones handling tags will come later.

Requested reviews:
  MAAS Maintainers (maas-maintainers)

For more details, see:
https://code.launchpad.net/~jameinel/maas/1.2-node-get-effective-kernel-options/+merge/133205

This just provides the internal method, so that Dimiter can use it to continue forward on the UI level changes.

The next follow up will merge Martin's pending DB change, and expose values from tags.
-- 
https://code.launchpad.net/~jameinel/maas/1.2-node-get-effective-kernel-options/+merge/133205
Your team MAAS Maintainers is requested to review the proposed merge of lp:~jameinel/maas/1.2-node-get-effective-kernel-options into lp:maas/1.2.
=== modified file 'src/maasserver/models/node.py'
--- src/maasserver/models/node.py	2012-10-30 15:11:10 +0000
+++ src/maasserver/models/node.py	2012-11-07 10:24:21 +0000
@@ -694,6 +694,18 @@
         else:
             return None
 
+    def get_effective_kernel_options(self):
+        """Determine any special kernel parameters for this node.
+
+        :return: (tag, kernel_options)
+            tag is a Tag object or None. If None, the kernel_options came from
+            the global setting.
+            kernel_options, a string or None indicating extra kernel_options
+            that should be used when booting this node.
+        """
+        global_value = Config.objects.get_config('kernel_opts')
+        return None, global_value
+
     @property
     def work_queue(self):
         """The name of the queue for tasks specific to this node."""

=== modified file 'src/maasserver/tests/test_node.py'
--- src/maasserver/tests/test_node.py	2012-10-30 15:11:10 +0000
+++ src/maasserver/tests/test_node.py	2012-11-07 10:24:21 +0000
@@ -303,6 +303,17 @@
         successful_types = [node_power_types[node] for node in started_nodes]
         self.assertItemsEqual(configless_power_types, successful_types)
 
+    def test_get_effective_kernel_options_with_nothing_set(self):
+        node = factory.make_node()
+        self.assertEqual((None, None), node.get_effective_kernel_options())
+
+    def test_get_effective_kernel_options_sees_global_config(self):
+        node = factory.make_node()
+        kernel_opts = factory.getRandomString()
+        Config.objects.set_config('kernel_opts', kernel_opts)
+        self.assertEqual(
+            (None, kernel_opts), node.get_effective_kernel_options())
+
     def test_acquire(self):
         node = factory.make_node(status=NODE_STATUS.READY)
         user = factory.make_user()