Merge lp:~jtv/maas/bug-1302772 into lp:maas/trunk

Proposed by Jeroen T. Vermeulen on 2014-04-07
Status: Merged
Approved by: Jeroen T. Vermeulen on 2014-04-07
Approved revision: 2234
Merged at revision: 2235
Proposed branch: lp:~jtv/maas/bug-1302772
Merge into: lp:maas/trunk
Diff against target: 94 lines (+59/-0)
2 files modified
src/provisioningserver/config.py (+23/-0)
src/provisioningserver/tests/test_config.py (+36/-0)
To merge this branch: bzr merge lp:~jtv/maas/bug-1302772
Reviewer Review Type Date Requested Status
Graham Binns (community) 2014-04-07 Approve on 2014-04-07
Review via email: mp+214490@code.launchpad.net

Commit message

Continue to accept (but do not use) the old “boot” section in pserv.yaml. Otherwise, upgrade breaks while parsing this file.

Description of the change

Meant for backport to 1.5, but I think it makes sense to land on trunk as well. It would be nice to warn users about the legacy entries at some point as well, but fixing the crash is the most urgent part.

Jeroen

To post a comment you must log in.
Graham Binns (gmb) wrote :

Looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/provisioningserver/config.py'
2--- src/provisioningserver/config.py 2014-03-28 06:51:59 +0000
3+++ src/provisioningserver/config.py 2014-04-07 09:17:07 +0000
4@@ -128,6 +128,28 @@
5 generator = String(if_missing=b"http://localhost/MAAS/api/1.0/pxeconfig/")
6
7
8+class ConfigLegacyEphemeral(Schema):
9+ """Legacy `eephemeral` section in `pserv.yaml` prior to MAAS 1.5.
10+
11+ This has been replaced with boot-source selection in `bootresources.yaml`.
12+ It is still accepted in `pserv.yaml`, but not used.
13+ """
14+ if_key_missing = None
15+ images_directory = String(if_missing=None)
16+ releases = Set(if_missing=None)
17+
18+
19+class ConfigLegacyBoot(Schema):
20+ """Legacy `boot` section in `pserv.yaml` prior to MAAS 1.5.
21+
22+ The new version of this config section lives in `bootresources.yaml`. It
23+ is still accepted in `pserv.yaml`, but not used.
24+ """
25+ if_key_missing = None
26+ architectures = Set(if_missing=None)
27+ ephemeral = ConfigLegacyEphemeral
28+
29+
30 class ConfigRPC(Schema):
31 """Configuration validator for the RPC service."""
32
33@@ -307,6 +329,7 @@
34 broker = ConfigBroker
35 tftp = ConfigTFTP
36 rpc = ConfigRPC
37+ boot = ConfigLegacyBoot
38
39
40 class BootConfig(ConfigBase):
41
42=== modified file 'src/provisioningserver/tests/test_config.py'
43--- src/provisioningserver/tests/test_config.py 2014-03-28 16:47:54 +0000
44+++ src/provisioningserver/tests/test_config.py 2014-04-07 09:17:07 +0000
45@@ -354,6 +354,14 @@
46 'root': "/var/lib/maas/tftp",
47 'resource_root': "/var/lib/maas/boot-resources/current/",
48 },
49+ # Legacy section. Became unused in MAAS 1.5.
50+ 'boot': {
51+ 'architectures': None,
52+ 'ephemeral': {
53+ 'images_directory': None,
54+ 'releases': None,
55+ },
56+ },
57 }
58
59 default_development_config = deepcopy(default_production_config)
60@@ -387,6 +395,34 @@
61 partial(Config.parse, config),
62 Raises(expected))
63
64+ def test_accepts_1_4_config_file(self):
65+ # A config file that was valid with MAAS 1.4 still loads, even though
66+ # its "boot" section is no longer used.
67+ broker_password = factory.make_name('pass')
68+ config = Config.parse(dedent("""\
69+ logfile: "/dev/null"
70+ oops:
71+ directory: "logs/oops"
72+ reporter: "maas-pserv"
73+ broker:
74+ host: "localhost"
75+ port: 5673
76+ username: brokeruser
77+ password: "%s"
78+ vhost: "/"
79+ tftp:
80+ root: /var/lib/maas/tftp
81+ port: 5244
82+ generator: http://localhost:5243/api/1.0/pxeconfig/
83+ boot:
84+ architectures: ['i386', 'armhf']
85+ ephemeral:
86+ images_directory: /var/lib/maas/ephemeral
87+ releases: ['precise', 'saucy']
88+ """) % broker_password)
89+ # This does not fail.
90+ self.assertEqual(broker_password, config['broker']['password'])
91+
92
93 class TestBootConfig(MAASTestCase):
94 """Tests for `provisioningserver.config.BootConfig`."""