Merge lp:~allenap/maas/default-to-production-config into lp:maas/trunk

Proposed by Gavin Panella on 2012-08-23
Status: Merged
Approved by: Andres Rodriguez on 2012-08-23
Approved revision: 918
Merged at revision: 917
Proposed branch: lp:~allenap/maas/default-to-production-config
Merge into: lp:maas/trunk
Diff against target: 148 lines (+46/-35)
4 files modified
etc/pserv.yaml (+4/-2)
required-packages/base (+1/-0)
src/provisioningserver/config.py (+2/-6)
src/provisioningserver/tests/test_config.py (+39/-27)
To merge this branch: bzr merge lp:~allenap/maas/default-to-production-config
Reviewer Review Type Date Requested Status
Andres Rodriguez 2012-08-23 Approve on 2012-08-23
Review via email: mp+121080@code.launchpad.net

Commit Message

Make the default pserv configuration (i.e. without overrides in etc/pserv.yaml) production-ready.

To post a comment you must log in.
Andres Rodriguez (andreserl) wrote :

Looks good to me +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'etc/pserv.yaml'
2--- etc/pserv.yaml 2012-08-21 17:03:50 +0000
3+++ etc/pserv.yaml 2012-08-23 20:05:40 +0000
4@@ -32,9 +32,11 @@
5 #
6 tftp:
7 # root: /var/lib/tftpboot
8- # port: 5244
9+ # port: 69
10+ port: 5244
11 ## The URL to be contacted to generate PXE configurations.
12- # generator: http://localhost:5243/api/1.0/pxeconfig/
13+ # generator: http://localhost/MAAS/api/1.0/pxeconfig/
14+ generator: http://localhost:5243/api/1.0/pxeconfig/
15
16 ## Boot configuration.
17 boot:
18
19=== modified file 'required-packages/base'
20--- required-packages/base 2012-08-16 02:37:01 +0000
21+++ required-packages/base 2012-08-23 20:05:40 +0000
22@@ -34,3 +34,4 @@
23 rabbitmq-server
24 syslinux-common
25 tgt
26+wget
27
28=== modified file 'src/provisioningserver/config.py'
29--- src/provisioningserver/config.py 2012-08-21 17:03:50 +0000
30+++ src/provisioningserver/config.py 2012-08-23 20:05:40 +0000
31@@ -25,7 +25,6 @@
32 Int,
33 RequireIfPresent,
34 String,
35- URL,
36 )
37 import yaml
38
39@@ -61,11 +60,8 @@
40 if_key_missing = None
41
42 root = String(if_missing="/var/lib/tftpboot")
43- port = Int(min=1, max=65535, if_missing=5244)
44- generator = URL(
45- add_http=True, require_tld=False,
46- if_missing=b"http://localhost:5243/api/1.0/pxeconfig/",
47- )
48+ port = Int(min=1, max=65535, if_missing=69)
49+ generator = String(if_missing=b"http://localhost/MAAS/api/1.0/pxeconfig/")
50
51
52 class ConfigBootEphemeral(Schema):
53
54=== modified file 'src/provisioningserver/tests/test_config.py'
55--- src/provisioningserver/tests/test_config.py 2012-08-21 17:03:50 +0000
56+++ src/provisioningserver/tests/test_config.py 2012-08-23 20:05:40 +0000
57@@ -12,6 +12,7 @@
58 __metaclass__ = type
59 __all__ = []
60
61+from copy import deepcopy
62 from functools import partial
63 from getpass import getuser
64 import os
65@@ -100,33 +101,42 @@
66 class TestConfig(TestCase):
67 """Tests for `provisioningserver.config.Config`."""
68
69+ default_production_config = {
70+ 'boot': {
71+ 'ephemeral': {
72+ 'directory': '/var/lib/maas/ephemeral',
73+ },
74+ },
75+ 'broker': {
76+ 'host': 'localhost',
77+ 'port': 5673,
78+ 'username': getuser(),
79+ 'password': 'test',
80+ 'vhost': '/',
81+ },
82+ 'logfile': 'pserv.log',
83+ 'oops': {
84+ 'directory': '',
85+ 'reporter': '',
86+ },
87+ 'tftp': {
88+ 'generator': 'http://localhost/MAAS/api/1.0/pxeconfig/',
89+ 'port': 69,
90+ 'root': "/var/lib/tftpboot",
91+ },
92+ }
93+
94+ default_development_config = deepcopy(default_production_config)
95+ default_development_config.update(logfile="/dev/null")
96+ default_development_config["oops"].update(
97+ directory="logs/oops", reporter="maas-pserv")
98+ default_development_config["tftp"].update(
99+ port=5244, generator="http://localhost:5243/api/1.0/pxeconfig/")
100+
101 def test_defaults(self):
102- expected = {
103- 'boot': {
104- 'ephemeral': {
105- 'directory': '/var/lib/maas/ephemeral',
106- },
107- },
108- 'broker': {
109- 'host': 'localhost',
110- 'port': 5673,
111- 'username': getuser(),
112- 'password': 'test',
113- 'vhost': '/',
114- },
115- 'logfile': 'pserv.log',
116- 'oops': {
117- 'directory': '',
118- 'reporter': '',
119- },
120- 'tftp': {
121- 'generator': 'http://localhost:5243/api/1.0/pxeconfig/',
122- 'port': 5244,
123- 'root': "/var/lib/tftpboot",
124- },
125- }
126+ # The default configuration is production-ready.
127 observed = Config.to_python({})
128- self.assertEqual(expected, observed)
129+ self.assertEqual(self.default_production_config, observed)
130
131 def test_parse(self):
132 # Configuration can be parsed from a snippet of YAML.
133@@ -143,11 +153,13 @@
134 self.assertEqual("/some/where.log", observed["logfile"])
135
136 def test_load_example(self):
137- # The example configuration can be loaded and validated.
138+ # The example configuration is designed for development.
139 filename = os.path.join(
140 os.path.dirname(__file__), os.pardir,
141 os.pardir, os.pardir, "etc", "pserv.yaml")
142- Config.load(filename)
143+ self.assertEqual(
144+ self.default_development_config,
145+ Config.load(filename))
146
147 def test_load_from_cache(self):
148 # A config loaded by Config.load_from_cache() is never reloaded.