Merge ~newell-jensen/maas:lp1828493 into maas:master

Proposed by Newell Jensen
Status: Merged
Approved by: Newell Jensen
Approved revision: 112b1ad6a65bf3329322d6551d992c0fb11f6ca7
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~newell-jensen/maas:lp1828493
Merge into: maas:master
Diff against target: 100 lines (+28/-33)
4 files modified
src/maasserver/models/signals/scriptresult.py (+4/-0)
src/maasserver/models/signals/tests/test_scriptresult.py (+24/-0)
src/metadataserver/api.py (+0/-2)
src/metadataserver/tests/test_api.py (+0/-31)
Reviewer Review Type Date Requested Status
Blake Rouse (community) Approve
Review via email: mp+367436@code.launchpad.net

Commit message

LP: #1828493 -- Improve when status message for Rebooting takes place. This creates the event when the install.log completes and the node's netboot is already set to False.

To post a comment you must log in.
Revision history for this message
Blake Rouse (blake-rouse) wrote :

Looks good!

review: Approve
~newell-jensen/maas:lp1828493 updated
112b1ad... by Newell Jensen

Rename unit test.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/maasserver/models/signals/scriptresult.py b/src/maasserver/models/signals/scriptresult.py
index 49be5d7..68e88da 100644
--- a/src/maasserver/models/signals/scriptresult.py
+++ b/src/maasserver/models/signals/scriptresult.py
@@ -54,6 +54,10 @@ def emit_script_result_status_transition_event(instance, old_values, **kwargs):
54 EVENT_TYPES.SCRIPT_RESULT_CHANGED_STATUS,54 EVENT_TYPES.SCRIPT_RESULT_CHANGED_STATUS,
55 event_description="%s changed status from '%s' to '%s'" % (55 event_description="%s changed status from '%s' to '%s'" % (
56 script_result.name, old_status_name, new_status_name))56 script_result.name, old_status_name, new_status_name))
57 if ('install.log' in script_result.name and not
58 script_result.script_set.node.netboot):
59 Event.objects.create_node_event(
60 script_result.script_set.node, EVENT_TYPES.REBOOTING)
5761
5862
59signals.watch_fields(63signals.watch_fields(
diff --git a/src/maasserver/models/signals/tests/test_scriptresult.py b/src/maasserver/models/signals/tests/test_scriptresult.py
index 7ca8d1e..4be637d 100644
--- a/src/maasserver/models/signals/tests/test_scriptresult.py
+++ b/src/maasserver/models/signals/tests/test_scriptresult.py
@@ -98,3 +98,27 @@ class TestStatusTransitionEvent(MAASServerTestCase):
98 latest_event.type.description,98 latest_event.type.description,
99 latest_event.description,99 latest_event.description,
100 ))100 ))
101
102 def test__install_log_emits_event(self):
103
104 old_status = SCRIPT_STATUS.RUNNING
105 script_result = factory.make_ScriptResult(
106 status=old_status, script_set=factory.make_ScriptSet(
107 result_type=RESULT_TYPE.COMMISSIONING),
108 script=factory.make_Script(name="/tmp/install.log"))
109 script_result.status = SCRIPT_STATUS.PASSED
110 script_result.script_set.node.netboot = False
111 script_result.save()
112
113 latest_event = Event.objects.last()
114 self.assertEqual(
115 (
116 EVENT_TYPES.REBOOTING,
117 EVENT_DETAILS[EVENT_TYPES.REBOOTING].description,
118 "",
119 ),
120 (
121 latest_event.type.name,
122 latest_event.type.description,
123 latest_event.description,
124 ))
diff --git a/src/metadataserver/api.py b/src/metadataserver/api.py
index 791e290..ff79192 100644
--- a/src/metadataserver/api.py
+++ b/src/metadataserver/api.py
@@ -1238,6 +1238,4 @@ class AnonMetaDataHandler(VersionIndexHandler):
1238 Event.objects.create_node_event(1238 Event.objects.create_node_event(
1239 node, EVENT_TYPES.NODE_INSTALLATION_FINISHED,1239 node, EVENT_TYPES.NODE_INSTALLATION_FINISHED,
1240 event_description="Node disabled netboot")1240 event_description="Node disabled netboot")
1241 # Create status message event for rebooting the machine.
1242 Event.objects.create_node_event(node, EVENT_TYPES.REBOOTING)
1243 return rc.ALL_OK1241 return rc.ALL_OK
diff --git a/src/metadataserver/tests/test_api.py b/src/metadataserver/tests/test_api.py
index 1a36c9e..f93f02b 100644
--- a/src/metadataserver/tests/test_api.py
+++ b/src/metadataserver/tests/test_api.py
@@ -2904,37 +2904,6 @@ class TestAnonymousAPI(MAASServerTestCase):
2904 response = self.client.get(anon_node_url, {'op': 'get_preseed'})2904 response = self.client.get(anon_node_url, {'op': 'get_preseed'})
2905 self.assertThat(response, HasStatusCode(http.client.OK))2905 self.assertThat(response, HasStatusCode(http.client.OK))
29062906
2907 def test_anonymous_netboot_off_adds_install_and_reboot_events(self):
2908 node = factory.make_Node(netboot=True)
2909 anon_netboot_off_url = reverse(
2910 'metadata-node-by-id', args=['latest', node.system_id])
2911 self.client.post(
2912 anon_netboot_off_url, {'op': 'netboot_off'})
2913 events = Event.objects.filter(node=node)
2914 self.assertEqual(
2915 (
2916 EVENT_TYPES.NODE_INSTALLATION_FINISHED,
2917 EVENT_DETAILS[
2918 EVENT_TYPES.NODE_INSTALLATION_FINISHED].description,
2919 "Node disabled netboot",
2920 ),
2921 (
2922 events[0].type.name,
2923 events[0].type.description,
2924 events[0].description,
2925 ))
2926 self.assertEqual(
2927 (
2928 EVENT_TYPES.REBOOTING,
2929 EVENT_DETAILS[EVENT_TYPES.REBOOTING].description,
2930 "",
2931 ),
2932 (
2933 events[1].type.name,
2934 events[1].type.description,
2935 events[1].description,
2936 ))
2937
29382907
2939class TestEnlistViews(MAASServerTestCase):2908class TestEnlistViews(MAASServerTestCase):
2940 """Tests for the enlistment metadata views."""2909 """Tests for the enlistment metadata views."""

Subscribers

People subscribed via source and target branches