Merge lp:~blake-rouse/maas/osystem-preseed-cleanup into lp:~maas-committers/maas/trunk
- osystem-preseed-cleanup
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Blake Rouse | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 2385 | ||||
Proposed branch: | lp:~blake-rouse/maas/osystem-preseed-cleanup | ||||
Merge into: | lp:~maas-committers/maas/trunk | ||||
Diff against target: |
295 lines (+60/-53) 8 files modified
src/maasserver/compose_preseed.py (+8/-0) src/maasserver/enum.py (+0/-33) src/maasserver/models/bootsourceselection.py (+10/-6) src/maasserver/testing/factory.py (+3/-2) src/maasserver/tests/test_api_boot_source_selections.py (+7/-7) src/maasserver/tests/test_compose_preseed.py (+15/-0) src/maasserver/tests/test_forms.py (+5/-5) src/provisioningserver/driver/__init__.py (+12/-0) |
||||
To merge this branch: | bzr merge lp:~blake-rouse/maas/osystem-preseed-cleanup | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Blake Rouse (community) | Approve | ||
Review via email: mp+221440@code.launchpad.net |
This proposal supersedes a proposal from 2014-04-24.
Commit message
Removed DISTRO_SERIES enums. Added the ability for an operating system to compose its own preseed.
Description of the change
This is the final change in the series of changes to allow MAAS to deploy other operating systems. As we have Windows and CentOS support coming soon this is needed to easily add new operating systems.
Removed the DISTRO_SERIES enums as they are no longer needed, all information comes from the OperatingSystem
Added the ability for an operating system to compose its own preseed. This will be used for Windows, CentOS and other operating systems.
Jeroen T. Vermeulen (jtv) wrote : Posted in a previous version of this proposal | # |
Blake Rouse (blake-rouse) wrote : Posted in a previous version of this proposal | # |
Removed the hasattr check to use a NotImplemented exception. Can you give this another review?
Jeroen T. Vermeulen (jtv) wrote : Posted in a previous version of this proposal | # |
Thanks, this branch looks a lot simpler than I remember it! Could you add a note in the docstring for compose_preseed about the NotImplementedError and what it means? Similar to “:param …:” and “:return:” the format also supports “:raise …:”.
Blake Rouse (blake-rouse) wrote : | # |
Already approved by jtv. Had to re-submit to fix the invalid prequisite branch. Self approving.
MAAS Lander (maas-lander) wrote : | # |
The attempt to merge lp:~blake-rouse/maas/osystem-preseed-cleanup into lp:maas failed. Below is the output from the failed tests.
Ign http://
Hit http://
Ign http://
Hit http://
Ign http://
Hit http://
Get:1 http://
Hit http://
Get:2 http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Ign http://
Hit http://
Ign http://
Get:3 http://
Get:4 http://
Get:5 http://
Get:6 http://
Hit http://
Hit http://
Ign http://
Ign http://
Ign http://
Ign http://
Fetched 318 kB in 0s (975 kB/s)
Reading package lists...
sudo DEBIAN_
--
Preview Diff
1 | === modified file 'src/maasserver/compose_preseed.py' | |||
2 | --- src/maasserver/compose_preseed.py 2013-10-18 09:54:17 +0000 | |||
3 | +++ src/maasserver/compose_preseed.py 2014-05-29 18:37:02 +0000 | |||
4 | @@ -20,6 +20,7 @@ | |||
5 | 20 | 20 | ||
6 | 21 | from maasserver.enum import NODE_STATUS | 21 | from maasserver.enum import NODE_STATUS |
7 | 22 | from maasserver.utils import absolute_reverse | 22 | from maasserver.utils import absolute_reverse |
8 | 23 | from provisioningserver.driver import OperatingSystemRegistry | ||
9 | 23 | import yaml | 24 | import yaml |
10 | 24 | 25 | ||
11 | 25 | 26 | ||
12 | @@ -104,6 +105,13 @@ | |||
13 | 104 | if node.status == NODE_STATUS.COMMISSIONING: | 105 | if node.status == NODE_STATUS.COMMISSIONING: |
14 | 105 | return compose_commissioning_preseed(token, base_url) | 106 | return compose_commissioning_preseed(token, base_url) |
15 | 106 | else: | 107 | else: |
16 | 108 | osystem = OperatingSystemRegistry[node.get_osystem()] | ||
17 | 109 | metadata_url = absolute_reverse('metadata', base_url=base_url) | ||
18 | 110 | try: | ||
19 | 111 | return osystem.compose_preseed(node, token, metadata_url) | ||
20 | 112 | except NotImplementedError: | ||
21 | 113 | pass | ||
22 | 114 | |||
23 | 107 | if node.should_use_traditional_installer(): | 115 | if node.should_use_traditional_installer(): |
24 | 108 | return compose_cloud_init_preseed(token, base_url) | 116 | return compose_cloud_init_preseed(token, base_url) |
25 | 109 | else: | 117 | else: |
26 | 110 | 118 | ||
27 | === modified file 'src/maasserver/enum.py' | |||
28 | --- src/maasserver/enum.py 2014-03-28 16:36:32 +0000 | |||
29 | +++ src/maasserver/enum.py 2014-05-29 18:37:02 +0000 | |||
30 | @@ -13,7 +13,6 @@ | |||
31 | 13 | 13 | ||
32 | 14 | __metaclass__ = type | 14 | __metaclass__ = type |
33 | 15 | __all__ = [ | 15 | __all__ = [ |
34 | 16 | 'COMMISSIONING_DISTRO_SERIES_CHOICES', | ||
35 | 17 | 'COMPONENT', | 16 | 'COMPONENT', |
36 | 18 | 'NODEGROUP_STATUS', | 17 | 'NODEGROUP_STATUS', |
37 | 19 | 'NODEGROUP_STATUS_CHOICES', | 18 | 'NODEGROUP_STATUS_CHOICES', |
38 | @@ -25,8 +24,6 @@ | |||
39 | 25 | 'NODE_STATUS_CHOICES', | 24 | 'NODE_STATUS_CHOICES', |
40 | 26 | 'NODE_STATUS_CHOICES_DICT', | 25 | 'NODE_STATUS_CHOICES_DICT', |
41 | 27 | 'PRESEED_TYPE', | 26 | 'PRESEED_TYPE', |
42 | 28 | 'DISTRO_SERIES', | ||
43 | 29 | 'DISTRO_SERIES_CHOICES', | ||
44 | 30 | 'USERDATA_TYPE', | 27 | 'USERDATA_TYPE', |
45 | 31 | ] | 28 | ] |
46 | 32 | 29 | ||
47 | @@ -86,36 +83,6 @@ | |||
48 | 86 | NODE_STATUS_CHOICES_DICT = OrderedDict(NODE_STATUS_CHOICES) | 83 | NODE_STATUS_CHOICES_DICT = OrderedDict(NODE_STATUS_CHOICES) |
49 | 87 | 84 | ||
50 | 88 | 85 | ||
51 | 89 | class DISTRO_SERIES: | ||
52 | 90 | """List of supported ubuntu releases.""" | ||
53 | 91 | #: | ||
54 | 92 | default = '' | ||
55 | 93 | #: | ||
56 | 94 | precise = 'precise' | ||
57 | 95 | #: | ||
58 | 96 | quantal = 'quantal' | ||
59 | 97 | #: | ||
60 | 98 | raring = 'raring' | ||
61 | 99 | #: | ||
62 | 100 | saucy = 'saucy' | ||
63 | 101 | #: | ||
64 | 102 | trusty = 'trusty' | ||
65 | 103 | |||
66 | 104 | DISTRO_SERIES_CHOICES = ( | ||
67 | 105 | (DISTRO_SERIES.default, 'Default Ubuntu Release'), | ||
68 | 106 | (DISTRO_SERIES.precise, 'Ubuntu 12.04 LTS "Precise Pangolin"'), | ||
69 | 107 | (DISTRO_SERIES.quantal, 'Ubuntu 12.10 "Quantal Quetzal"'), | ||
70 | 108 | (DISTRO_SERIES.raring, 'Ubuntu 13.04 "Raring Ringtail"'), | ||
71 | 109 | (DISTRO_SERIES.saucy, 'Ubuntu 13.10 "Saucy Salamander"'), | ||
72 | 110 | (DISTRO_SERIES.trusty, 'Ubuntu 14.04 LTS "Trusty Tahr"'), | ||
73 | 111 | ) | ||
74 | 112 | |||
75 | 113 | |||
76 | 114 | COMMISSIONING_DISTRO_SERIES_CHOICES = ( | ||
77 | 115 | (DISTRO_SERIES.trusty, dict(DISTRO_SERIES_CHOICES)[DISTRO_SERIES.trusty]), | ||
78 | 116 | ) | ||
79 | 117 | |||
80 | 118 | |||
81 | 119 | class NODE_PERMISSION: | 86 | class NODE_PERMISSION: |
82 | 120 | """Permissions relating to nodes.""" | 87 | """Permissions relating to nodes.""" |
83 | 121 | VIEW = 'view_node' | 88 | VIEW = 'view_node' |
84 | 122 | 89 | ||
85 | === modified file 'src/maasserver/models/bootsourceselection.py' | |||
86 | --- src/maasserver/models/bootsourceselection.py 2014-05-16 11:41:18 +0000 | |||
87 | +++ src/maasserver/models/bootsourceselection.py 2014-05-29 18:37:02 +0000 | |||
88 | @@ -24,12 +24,16 @@ | |||
89 | 24 | ) | 24 | ) |
90 | 25 | import djorm_pgarray.fields | 25 | import djorm_pgarray.fields |
91 | 26 | from maasserver import DefaultMeta | 26 | from maasserver import DefaultMeta |
92 | 27 | from maasserver.enum import ( | ||
93 | 28 | DISTRO_SERIES, | ||
94 | 29 | DISTRO_SERIES_CHOICES, | ||
95 | 30 | ) | ||
96 | 31 | from maasserver.models.cleansave import CleanSave | 27 | from maasserver.models.cleansave import CleanSave |
97 | 32 | from maasserver.models.timestampedmodel import TimestampedModel | 28 | from maasserver.models.timestampedmodel import TimestampedModel |
98 | 29 | from provisioningserver.driver.os_ubuntu import UbuntuOS | ||
99 | 30 | |||
100 | 31 | |||
101 | 32 | def list_release_choices(): | ||
102 | 33 | """Return Django "choices" list for Ubuntu releases.""" | ||
103 | 34 | osystem = UbuntuOS() | ||
104 | 35 | releases = osystem.get_supported_releases() | ||
105 | 36 | return osystem.format_release_choices(releases) | ||
106 | 33 | 37 | ||
107 | 34 | 38 | ||
108 | 35 | class BootSourceSelectionManager(Manager): | 39 | class BootSourceSelectionManager(Manager): |
109 | @@ -47,8 +51,8 @@ | |||
110 | 47 | boot_source = ForeignKey('maasserver.BootSource', blank=False) | 51 | boot_source = ForeignKey('maasserver.BootSource', blank=False) |
111 | 48 | 52 | ||
112 | 49 | release = CharField( | 53 | release = CharField( |
115 | 50 | max_length=20, choices=DISTRO_SERIES_CHOICES, blank=True, | 54 | max_length=20, choices=list_release_choices(), blank=True, |
116 | 51 | default=DISTRO_SERIES.default, | 55 | default='', |
117 | 52 | help_text="The Ubuntu release for which to import resources.") | 56 | help_text="The Ubuntu release for which to import resources.") |
118 | 53 | 57 | ||
119 | 54 | arches = djorm_pgarray.fields.ArrayField(dbtype="text") | 58 | arches = djorm_pgarray.fields.ArrayField(dbtype="text") |
120 | 55 | 59 | ||
121 | === modified file 'src/maasserver/testing/factory.py' | |||
122 | --- src/maasserver/testing/factory.py 2014-05-29 17:03:20 +0000 | |||
123 | +++ src/maasserver/testing/factory.py 2014-05-29 18:37:02 +0000 | |||
124 | @@ -23,7 +23,6 @@ | |||
125 | 23 | from django.contrib.auth.models import User | 23 | from django.contrib.auth.models import User |
126 | 24 | from maasserver.clusterrpc.power_parameters import get_power_types | 24 | from maasserver.clusterrpc.power_parameters import get_power_types |
127 | 25 | from maasserver.enum import ( | 25 | from maasserver.enum import ( |
128 | 26 | DISTRO_SERIES_CHOICES, | ||
129 | 27 | NODE_STATUS, | 26 | NODE_STATUS, |
130 | 28 | NODEGROUP_STATUS, | 27 | NODEGROUP_STATUS, |
131 | 29 | NODEGROUPINTERFACE_MANAGEMENT, | 28 | NODEGROUPINTERFACE_MANAGEMENT, |
132 | @@ -62,6 +61,7 @@ | |||
133 | 62 | # XXX 2014-05-13 blake-rouse bug=1319143 | 61 | # XXX 2014-05-13 blake-rouse bug=1319143 |
134 | 63 | # Need to not import directly, use RPC to info from cluster. | 62 | # Need to not import directly, use RPC to info from cluster. |
135 | 64 | from provisioningserver.driver import OperatingSystemRegistry | 63 | from provisioningserver.driver import OperatingSystemRegistry |
136 | 64 | from provisioningserver.driver.os_ubuntu import UbuntuOS | ||
137 | 65 | 65 | ||
138 | 66 | # We have a limited number of public keys: | 66 | # We have a limited number of public keys: |
139 | 67 | # src/maasserver/tests/data/test_rsa{0, 1, 2, 3, 4}.pub | 67 | # src/maasserver/tests/data/test_rsa{0, 1, 2, 3, 4}.pub |
140 | @@ -717,7 +717,8 @@ | |||
141 | 717 | if boot_source is None: | 717 | if boot_source is None: |
142 | 718 | boot_source = self.make_boot_source() | 718 | boot_source = self.make_boot_source() |
143 | 719 | if release is None: | 719 | if release is None: |
145 | 720 | release = self.getRandomChoice(DISTRO_SERIES_CHOICES) | 720 | ubuntu_os = UbuntuOS() |
146 | 721 | release = self.getRandomRelease(ubuntu_os) | ||
147 | 721 | if arches is None: | 722 | if arches is None: |
148 | 722 | arch_count = random.randint(1, 10) | 723 | arch_count = random.randint(1, 10) |
149 | 723 | arches = [self.make_name("arch") for i in range(arch_count)] | 724 | arches = [self.make_name("arch") for i in range(arch_count)] |
150 | 724 | 725 | ||
151 | === modified file 'src/maasserver/tests/test_api_boot_source_selections.py' | |||
152 | --- src/maasserver/tests/test_api_boot_source_selections.py 2014-05-27 13:53:21 +0000 | |||
153 | +++ src/maasserver/tests/test_api_boot_source_selections.py 2014-05-29 18:37:02 +0000 | |||
154 | @@ -19,11 +19,11 @@ | |||
155 | 19 | 19 | ||
156 | 20 | from django.core.urlresolvers import reverse | 20 | from django.core.urlresolvers import reverse |
157 | 21 | from maasserver.api import DISPLAYED_BOOTSOURCESELECTION_FIELDS | 21 | from maasserver.api import DISPLAYED_BOOTSOURCESELECTION_FIELDS |
158 | 22 | from maasserver.enum import DISTRO_SERIES_CHOICES | ||
159 | 23 | from maasserver.models import BootSourceSelection | 22 | from maasserver.models import BootSourceSelection |
160 | 24 | from maasserver.testing import reload_object | 23 | from maasserver.testing import reload_object |
161 | 25 | from maasserver.testing.api import APITestCase | 24 | from maasserver.testing.api import APITestCase |
162 | 26 | from maasserver.testing.factory import factory | 25 | from maasserver.testing.factory import factory |
163 | 26 | from provisioningserver.driver.os_ubuntu import UbuntuOS | ||
164 | 27 | from testtools.matchers import MatchesStructure | 27 | from testtools.matchers import MatchesStructure |
165 | 28 | 28 | ||
166 | 29 | 29 | ||
167 | @@ -98,8 +98,8 @@ | |||
168 | 98 | def test_PUT_updates_boot_source_selection(self): | 98 | def test_PUT_updates_boot_source_selection(self): |
169 | 99 | self.become_admin() | 99 | self.become_admin() |
170 | 100 | boot_source_selection = factory.make_boot_source_selection() | 100 | boot_source_selection = factory.make_boot_source_selection() |
173 | 101 | new_release = factory.getRandomChoice( | 101 | ubuntu_os = UbuntuOS() |
174 | 102 | DISTRO_SERIES_CHOICES) | 102 | new_release = factory.getRandomRelease(ubuntu_os) |
175 | 103 | new_values = { | 103 | new_values = { |
176 | 104 | 'release': new_release, | 104 | 'release': new_release, |
177 | 105 | 'arches': [factory.make_name('arch'), factory.make_name('arch')], | 105 | 'arches': [factory.make_name('arch'), factory.make_name('arch')], |
178 | @@ -160,8 +160,8 @@ | |||
179 | 160 | def test_POST_creates_boot_source_selection(self): | 160 | def test_POST_creates_boot_source_selection(self): |
180 | 161 | self.become_admin() | 161 | self.become_admin() |
181 | 162 | boot_source = factory.make_boot_source() | 162 | boot_source = factory.make_boot_source() |
184 | 163 | new_release = factory.getRandomChoice( | 163 | ubuntu_os = UbuntuOS() |
185 | 164 | DISTRO_SERIES_CHOICES) | 164 | new_release = factory.getRandomRelease(ubuntu_os) |
186 | 165 | params = { | 165 | params = { |
187 | 166 | 'release': new_release, | 166 | 'release': new_release, |
188 | 167 | 'arches': [factory.make_name('arch'), factory.make_name('arch')], | 167 | 'arches': [factory.make_name('arch'), factory.make_name('arch')], |
189 | @@ -182,8 +182,8 @@ | |||
190 | 182 | 182 | ||
191 | 183 | def test_POST_requires_admin(self): | 183 | def test_POST_requires_admin(self): |
192 | 184 | boot_source = factory.make_boot_source() | 184 | boot_source = factory.make_boot_source() |
195 | 185 | new_release = factory.getRandomChoice( | 185 | ubuntu_os = UbuntuOS() |
196 | 186 | DISTRO_SERIES_CHOICES) | 186 | new_release = factory.getRandomRelease(ubuntu_os) |
197 | 187 | params = { | 187 | params = { |
198 | 188 | 'release': new_release, | 188 | 'release': new_release, |
199 | 189 | 'arches': [factory.make_name('arch'), factory.make_name('arch')], | 189 | 'arches': [factory.make_name('arch'), factory.make_name('arch')], |
200 | 190 | 190 | ||
201 | === modified file 'src/maasserver/tests/test_compose_preseed.py' | |||
202 | --- src/maasserver/tests/test_compose_preseed.py 2013-10-07 09:12:40 +0000 | |||
203 | +++ src/maasserver/tests/test_compose_preseed.py 2014-05-29 18:37:02 +0000 | |||
204 | @@ -17,8 +17,10 @@ | |||
205 | 17 | from maasserver.compose_preseed import compose_preseed | 17 | from maasserver.compose_preseed import compose_preseed |
206 | 18 | from maasserver.enum import NODE_STATUS | 18 | from maasserver.enum import NODE_STATUS |
207 | 19 | from maasserver.testing.factory import factory | 19 | from maasserver.testing.factory import factory |
208 | 20 | from maasserver.testing.osystems import make_usable_osystem | ||
209 | 20 | from maasserver.testing.testcase import MAASServerTestCase | 21 | from maasserver.testing.testcase import MAASServerTestCase |
210 | 21 | from maasserver.utils import absolute_reverse | 22 | from maasserver.utils import absolute_reverse |
211 | 23 | from maastesting.matchers import MockCalledOnceWith | ||
212 | 22 | from metadataserver.models import NodeKey | 24 | from metadataserver.models import NodeKey |
213 | 23 | from testtools.matchers import ( | 25 | from testtools.matchers import ( |
214 | 24 | KeysEqual, | 26 | KeysEqual, |
215 | @@ -110,3 +112,16 @@ | |||
216 | 110 | self.assertEqual( | 112 | self.assertEqual( |
217 | 111 | absolute_reverse('curtin-metadata'), | 113 | absolute_reverse('curtin-metadata'), |
218 | 112 | preseed['datasource']['MAAS']['metadata_url']) | 114 | preseed['datasource']['MAAS']['metadata_url']) |
219 | 115 | |||
220 | 116 | def test_compose_preseed_with_osystem_compose_preseed(self): | ||
221 | 117 | osystem = make_usable_osystem(self) | ||
222 | 118 | mock_compose = self.patch(osystem, 'compose_preseed') | ||
223 | 119 | node = factory.make_node( | ||
224 | 120 | osystem=osystem.name, status=NODE_STATUS.READY) | ||
225 | 121 | |||
226 | 122 | token = NodeKey.objects.get_token_for_node(node) | ||
227 | 123 | url = absolute_reverse('metadata') | ||
228 | 124 | compose_preseed(node) | ||
229 | 125 | self.assertThat( | ||
230 | 126 | mock_compose, | ||
231 | 127 | MockCalledOnceWith(node, token, url)) | ||
232 | 113 | 128 | ||
233 | === modified file 'src/maasserver/tests/test_forms.py' | |||
234 | --- src/maasserver/tests/test_forms.py 2014-05-29 17:03:20 +0000 | |||
235 | +++ src/maasserver/tests/test_forms.py 2014-05-29 18:37:02 +0000 | |||
236 | @@ -29,7 +29,6 @@ | |||
237 | 29 | from django.http import QueryDict | 29 | from django.http import QueryDict |
238 | 30 | from maasserver.clusterrpc.power_parameters import get_power_type_choices | 30 | from maasserver.clusterrpc.power_parameters import get_power_type_choices |
239 | 31 | from maasserver.enum import ( | 31 | from maasserver.enum import ( |
240 | 32 | DISTRO_SERIES_CHOICES, | ||
241 | 33 | NODE_STATUS, | 32 | NODE_STATUS, |
242 | 34 | NODEGROUP_STATUS, | 33 | NODEGROUP_STATUS, |
243 | 35 | NODEGROUPINTERFACE_MANAGEMENT, | 34 | NODEGROUPINTERFACE_MANAGEMENT, |
244 | @@ -112,6 +111,7 @@ | |||
245 | 112 | from metadataserver.models import CommissioningScript | 111 | from metadataserver.models import CommissioningScript |
246 | 113 | from netaddr import IPNetwork | 112 | from netaddr import IPNetwork |
247 | 114 | from provisioningserver import tasks | 113 | from provisioningserver import tasks |
248 | 114 | from provisioningserver.driver.os_ubuntu import UbuntuOS | ||
249 | 115 | from testtools import TestCase | 115 | from testtools import TestCase |
250 | 116 | from testtools.matchers import ( | 116 | from testtools.matchers import ( |
251 | 117 | AllMatch, | 117 | AllMatch, |
252 | @@ -2062,8 +2062,8 @@ | |||
253 | 2062 | 2062 | ||
254 | 2063 | def test_edits_boot_source_selection_object(self): | 2063 | def test_edits_boot_source_selection_object(self): |
255 | 2064 | boot_source_selection = factory.make_boot_source_selection() | 2064 | boot_source_selection = factory.make_boot_source_selection() |
258 | 2065 | new_release = factory.getRandomChoice( | 2065 | ubuntu_os = UbuntuOS() |
259 | 2066 | DISTRO_SERIES_CHOICES) | 2066 | new_release = factory.getRandomRelease(ubuntu_os) |
260 | 2067 | params = { | 2067 | params = { |
261 | 2068 | 'release': new_release, | 2068 | 'release': new_release, |
262 | 2069 | 'arches': [factory.make_name('arch'), factory.make_name('arch')], | 2069 | 'arches': [factory.make_name('arch'), factory.make_name('arch')], |
263 | @@ -2080,8 +2080,8 @@ | |||
264 | 2080 | 2080 | ||
265 | 2081 | def test_creates_boot_source_selection_object(self): | 2081 | def test_creates_boot_source_selection_object(self): |
266 | 2082 | boot_source = factory.make_boot_source() | 2082 | boot_source = factory.make_boot_source() |
269 | 2083 | new_release = factory.getRandomChoice( | 2083 | ubuntu_os = UbuntuOS() |
270 | 2084 | DISTRO_SERIES_CHOICES) | 2084 | new_release = factory.getRandomRelease(ubuntu_os) |
271 | 2085 | params = { | 2085 | params = { |
272 | 2086 | 'release': new_release, | 2086 | 'release': new_release, |
273 | 2087 | 'arches': [factory.make_name('arch'), factory.make_name('arch')], | 2087 | 'arches': [factory.make_name('arch'), factory.make_name('arch')], |
274 | 2088 | 2088 | ||
275 | === modified file 'src/provisioningserver/driver/__init__.py' | |||
276 | --- src/provisioningserver/driver/__init__.py 2014-05-15 17:27:53 +0000 | |||
277 | +++ src/provisioningserver/driver/__init__.py 2014-05-29 18:37:02 +0000 | |||
278 | @@ -158,6 +158,18 @@ | |||
279 | 158 | :returns: list of supported purposes | 158 | :returns: list of supported purposes |
280 | 159 | """ | 159 | """ |
281 | 160 | 160 | ||
282 | 161 | def compose_preseed(self, node, token, metadata_url): | ||
283 | 162 | """Composes the preseed for the given node. | ||
284 | 163 | |||
285 | 164 | :param node: Node preseed needs generating. | ||
286 | 165 | :param token: OAuth token for url. | ||
287 | 166 | :param metadata_url: Metdata url for node. | ||
288 | 167 | :returns: Preseed for node. | ||
289 | 168 | :raise: | ||
290 | 169 | NotImplementedError: doesn't implement a custom preseed | ||
291 | 170 | """ | ||
292 | 171 | raise NotImplementedError() | ||
293 | 172 | |||
294 | 161 | 173 | ||
295 | 162 | class HardwareDiscoverContext: | 174 | class HardwareDiscoverContext: |
296 | 163 | 175 |
Thanks for doing this work. It's good to see those old hard-coded enums go at last. Unfortunately there's that pervasive problem of the registries living in a different process, possibly on a different machine. We should probably have been a lot clearer about that.
This branch answers a question I asked on one of your other merge proposals: does OperatingSystem really need to be a base class? If it's going to have a method for generating preseed data, and if it really can't be addressed with simple text templating, then it probably does.
An uncomfortable number of dimensional axes are coming together in compose_preseed: commissioning vs. deployment, operating systems with and without preseed code, conventional installer or fastpath (or whatever install options some other OS might have in their place). Gotta nip that sort of burgeoning complexity in the bud, or it will eventually stifle further development. Fight it with fire because by nature it will just keep growing.
So, assuming that we really do need OS-specific preseed-generating code, I would look for a way to move the Ubuntu-specific parts into the Ubuntu OperatingSystem. Or if most-but-not-all operating systems can generate their preseeds using templates, delegate most operating systems' implementations to a single template-based helper. (If templates can reasonably do the job for all operating systems we have in mind, of course, just use templating and stick with generic code.)
The hasattr check is best avoided, I think. If you're going to rely on dynamic dispatch for this, go all the way. You can accommodate some kind of sensible default in the dynamic method's definition, but an unconditional code path is going to be more manageable than special-casing in the code. Conditionals are our profession's equivalent of moving parts: they introduce complexity and risk.
There also seems to be a tacit rule in there that the commissioning OS must be, or work like, Ubuntu. That is worth being very explicit about. This isn't just a series of "if" statements to make things work, it's defining how a node can or cannot be installed. The details of of how these conditions interact are crucial, and yet I don't see any tests covering things like “we generate the customary Ubuntu preseed for a commissioning node, even if it's to be deployed with a different OS.”
By the way, I do appreciate how this branch is small and focused and not thrown in with a large bag of other changes!