← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rvb/maas/bug-979457-node-message into lp:maas

 

Raphaël Badin has proposed merging lp:~rvb/maas/bug-979457-node-message into lp:maas.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #979457 in MAAS: "Tell users about the required USB images when the nodes get into READY"
  https://bugs.launchpad.net/maas/+bug/979457

For more details, see:
https://code.launchpad.net/~rvb/maas/bug-979457-node-message/+merge/101734

This branch adds an info message on the node page if a node is READY or COMMISSIONING.  The message features a link to a page explaining how to boot over Avahi.
-- 
https://code.launchpad.net/~rvb/maas/bug-979457-node-message/+merge/101734
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/maas/bug-979457-node-message into lp:maas.
=== modified file 'src/maasserver/tests/test_views.py'
--- src/maasserver/tests/test_views.py	2012-04-12 05:40:40 +0000
+++ src/maasserver/tests/test_views.py	2012-04-12 13:18:19 +0000
@@ -575,6 +575,19 @@
         response = self.client.get(node_delete_link)
         self.assertEqual(httplib.FORBIDDEN, response.status_code)
 
+    def xxxtest_view_node_shows_message_for_commissioning_node(self):
+        statuses_with_message = [
+            NODE_STATUS.READY, NODE_STATUS.COMMISSIONING]
+        for status in map_enum(NODE_STATUS):
+            node = factory.make_node(status=status)
+            node_link = reverse('node-view', args=[node.system_id])
+            response = self.client.get(node_link)
+            help_link = "https://wiki.ubuntu.com/ServerTeam/MAAS/AvahiBoot";
+            if status in statuses_with_message:
+                self.assertIn(help_link, get_content_links(response))
+            else:
+                self.assertNotIn(help_link, get_content_links(response))
+
     def test_view_node_shows_link_to_delete_node_for_admin(self):
         self.become_admin()
         node = factory.make_node()
@@ -716,8 +729,8 @@
         node = factory.make_node(status=NODE_STATUS.DECLARED)
         response = self.perform_action_and_get_node_page(
             node, "Accept & commission")
-        self.assertEqual(
-            ["Node commissioning started."],
+        self.assertIn(
+            "Node commissioning started.",
             [message.message for message in response.context['messages']])
 
     def test_start_node_from_ready_displays_message(self):
@@ -725,8 +738,8 @@
             status=NODE_STATUS.READY, owner=self.logged_in_user)
         response = self.perform_action_and_get_node_page(
             node, "Start node")
-        self.assertEqual(
-            ["Node started."],
+        self.assertIn(
+            "Node started.",
             [message.message for message in response.context['messages']])
 
     def test_start_node_from_allocated_displays_message(self):

=== modified file 'src/maasserver/views.py'
--- src/maasserver/views.py	2012-04-11 15:45:35 +0000
+++ src/maasserver/views.py	2012-04-12 13:18:19 +0000
@@ -31,6 +31,7 @@
 import mimetypes
 import os
 import urllib2
+from django.utils.safestring import mark_safe
 
 from convoy.combo import (
     combine_files,
@@ -110,6 +111,17 @@
     return dj_logout(request, next_page=reverse('login'))
 
 
+# Info message displayed on the node page for COMMISSIONING
+# or READY nodes.
+NODE_BOOT_INFO = mark_safe("""
+You can boot this node using Avahi enabled boot media or an
+adequately configured dhcp server, see
+<a href="https://wiki.ubuntu.com/ServerTeam/MAAS/AvahiBoot";>
+https://wiki.ubuntu.com/ServerTeam/MAAS/AvahiBoot</a> for
+details.
+""")
+
+
 class NodeView(UpdateView):
 
     template_name = 'maasserver/node_view.html'
@@ -133,6 +145,8 @@
             NODE_PERMISSION.EDIT, node)
         context['can_delete'] = self.request.user.has_perm(
             NODE_PERMISSION.ADMIN, node)
+        if node.status in (NODE_STATUS.COMMISSIONING, NODE_STATUS.READY):
+            messages.info(self.request, NODE_BOOT_INFO)
         return context
 
     def get_success_url(self):