Merge lp:~julian-edwards/maas/remove-harmless-warning-bug-1386909 into lp:~maas-committers/maas/trunk

Proposed by Julian Edwards
Status: Merged
Approved by: Julian Edwards
Approved revision: no longer in the source branch.
Merged at revision: 3339
Proposed branch: lp:~julian-edwards/maas/remove-harmless-warning-bug-1386909
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 57 lines (+22/-1)
2 files modified
src/maasserver/api/pxeconfig.py (+7/-0)
src/maasserver/api/tests/test_pxeconfig.py (+15/-1)
To merge this branch: bzr merge lp:~julian-edwards/maas/remove-harmless-warning-bug-1386909
Reviewer Review Type Date Requested Status
Graham Binns (community) Approve
Newell Jensen (community) Approve
Review via email: mp+240809@code.launchpad.net

Commit message

Don't bother searching for a boot purpose of "local" when serving pxeconfig API requests. It saves a call to the cluster controller and prevents a spurious log message.

To post a comment you must log in.
Revision history for this message
Newell Jensen (newell-jensen) wrote :

Nicely done.

review: Approve
Revision history for this message
Graham Binns (gmb) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/maasserver/api/pxeconfig.py'
--- src/maasserver/api/pxeconfig.py 2014-10-20 20:32:00 +0000
+++ src/maasserver/api/pxeconfig.py 2014-11-06 06:13:51 +0000
@@ -84,6 +84,13 @@
84 nodegroup, osystem, architecture, subarchitecture, series, purpose):84 nodegroup, osystem, architecture, subarchitecture, series, purpose):
85 """Obtain the first available boot image for this cluster for the given85 """Obtain the first available boot image for this cluster for the given
86 osystem, architecture, subarchitecute, series, and purpose."""86 osystem, architecture, subarchitecute, series, and purpose."""
87 # When local booting a node we put it through a PXE cycle. In
88 # this case it requests a purpose of "local" when looking for
89 # boot images. To avoid unnecessary work, we can shortcut that
90 # here and just return None right away.
91 if purpose == "local":
92 return None
93
87 try:94 try:
88 images = get_boot_images_for(95 images = get_boot_images_for(
89 nodegroup, osystem, architecture, subarchitecture, series)96 nodegroup, osystem, architecture, subarchitecture, series)
9097
=== modified file 'src/maasserver/api/tests/test_pxeconfig.py'
--- src/maasserver/api/tests/test_pxeconfig.py 2014-10-20 20:32:00 +0000
+++ src/maasserver/api/tests/test_pxeconfig.py 2014-11-06 06:13:51 +0000
@@ -50,7 +50,10 @@
50from maasserver.testing.orm import reload_object50from maasserver.testing.orm import reload_object
51from maasserver.testing.testcase import MAASServerTestCase51from maasserver.testing.testcase import MAASServerTestCase
52from maastesting.fakemethod import FakeMethod52from maastesting.fakemethod import FakeMethod
53from maastesting.matchers import MockCalledOnceWith53from maastesting.matchers import (
54 MockCalledOnceWith,
55 MockNotCalled,
56 )
54from mock import sentinel57from mock import sentinel
55from netaddr import IPNetwork58from netaddr import IPNetwork
56from provisioningserver import kernel_opts59from provisioningserver import kernel_opts
@@ -60,6 +63,7 @@
60 Contains,63 Contains,
61 ContainsAll,64 ContainsAll,
62 Equals,65 Equals,
66 Is,
63 MatchesListwise,67 MatchesListwise,
64 StartsWith,68 StartsWith,
65 )69 )
@@ -119,6 +123,16 @@
119 sentinel.architecture, subarch,123 sentinel.architecture, subarch,
120 sentinel.series, purpose))124 sentinel.series, purpose))
121125
126 def test__returns_None_immediately_if_purpose_is_local(self):
127 self.patch(pxeconfig_module, 'get_boot_images_for')
128 self.expectThat(
129 get_boot_image(
130 sentinel.nodegroup, sentinel.osystem,
131 sentinel.architecture, sentinel.subarchitecture,
132 sentinel.series, "local"),
133 Is(None))
134 self.expectThat(pxeconfig_module.get_boot_images_for, MockNotCalled())
135
122136
123class TestPXEConfigAPI(MAASServerTestCase):137class TestPXEConfigAPI(MAASServerTestCase):
124138