Merge lp:~allenap/maas/remove-maas into lp:~maas-committers/maas/trunk

Proposed by Gavin Panella
Status: Merged
Approved by: Gavin Panella
Approved revision: no longer in the source branch.
Merged at revision: 5587
Proposed branch: lp:~allenap/maas/remove-maas
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 397 lines (+81/-61)
17 files modified
HACKING.txt (+9/-5)
Makefile (+2/-1)
buildout.cfg (+2/-3)
docs/conf.py (+2/-1)
docs/troubleshooting.rst (+1/-1)
media/README (+4/-4)
services/reloader/run (+1/-1)
src/maascli/cli.py (+2/-2)
src/maasserver/__init__.py (+1/-1)
src/maasserver/djangosettings/demo.py (+1/-1)
src/maasserver/djangosettings/development.py (+1/-1)
src/maasserver/djangosettings/settings.py (+3/-3)
src/maasserver/djangosettings/tests/test_settings.py (+2/-2)
src/maasserver/management/commands/dbupgrade.py (+46/-3)
src/maasserver/management/commands/tests/test_dbupgrade.py (+4/-1)
utilities/check-imports (+0/-27)
utilities/remote-reinstall (+0/-4)
To merge this branch: bzr merge lp:~allenap/maas/remove-maas
Reviewer Review Type Date Requested Status
Blake Rouse (community) Approve
Andres Rodriguez (community) Needs Information
Review via email: mp+310634@code.launchpad.net

Commit message

Remove src/maas.

Description of the change

This fails in one test: http://paste.ubuntu.com/23460489/

I haven't been able to figure it out yet, but I wanted to put this up in case someone else <cough>Blake<cough> would have an idea.

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

I will have to dig into this to see why its failing. It has to be something in the tarball that is used for upgrading pre 2.0.

Revision history for this message
Andres Rodriguez (andreserl) wrote :

Why are we removing src/maas ?

review: Needs Information
Revision history for this message
Gavin Panella (allenap) wrote :

> Why are we removing src/maas ?

It's not needed as a standalone thing, and hasn't been for a long time now. It also gets in the way of using "maas" as a namespace package, a change Blake has kicked off with the client API.

Revision history for this message
Gavin Panella (allenap) wrote :

> I will have to dig into this to see why its failing. It has to be something in
> the tarball that is used for upgrading pre 2.0.

Thanks. I did make one change to the tarball: I added maas19settings.py. You'll get this when pulling this branch, but it won't show up in the diff, so I've pasted it too: http://paste.ubuntu.com/23480843/

Revision history for this message
Andres Rodriguez (andreserl) wrote :

This would need a lot of changes on the installation. src/maas gets up installed in /usr/share/maas and would break all installations....

Revision history for this message
Gavin Panella (allenap) wrote :

> This would need a lot of changes on the installation. src/maas gets up
> installed in /usr/share/maas and would break all installations....

A packaging change is needed, yes, but /usr/share/maas/maas can be removed. There's nothing in there that needs to be preserved so there isn't any migration needed; configuration has been in /etc/maas for a long time now. The only difficult bit is making it work with migrations from pre-2.0.

Revision history for this message
Gavin Panella (allenap) wrote :

Okay, this is working now: I had missed out SOUTH_MIGRATION_MODULES from the maas19settings.py file that's in the South migrations tarball. I'll prep a packaging change.

Revision history for this message
Gavin Panella (allenap) wrote :
Revision history for this message
Blake Rouse (blake-rouse) wrote :

This is good work. Glad to see that folder in the code removed.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'HACKING.txt'
2--- HACKING.txt 2016-03-28 13:54:47 +0000
3+++ HACKING.txt 2016-12-02 09:29:56 +0000
4@@ -138,8 +138,9 @@
5 regiond.log. To enable logging of all exceptions even exceptions where MAAS
6 will return the correct HTTP status code.::
7
8- $ sudo sed -i 's/DEBUG = False/DEBUG = True/g' /usr/share/maas/maas/settings.py
9- $ sudo service maas-regiond restart
10+ $ sudo sed -i 's/DEBUG = False/DEBUG = True/g' \
11+ > /usr/lib/python3/dist-packages/maasserver/djangosettings/settings.py
12+ $ sudo service maas-regiond restart
13
14 Run regiond in foreground
15 ^^^^^^^^^^^^^^^^^^^^^^^^^
16@@ -149,8 +150,10 @@
17 placed a breakpoint into the code you want to inspect you can start the regiond
18 process in the foreground.::
19
20- $ sudo service maas-regiond stop
21- $ sudo -u maas -H DJANGO_SETTINGS_MODULE=maas.settings PYTHONPATH=/usr/share/maas twistd3 --nodaemon --pidfile= maas-regiond
22+ $ sudo service maas-regiond stop
23+ $ sudo -u maas -H \
24+ > DJANGO_SETTINGS_MODULE=maasserver.djangosettings.settings \
25+ > twistd3 --nodaemon --pidfile= maas-regiond
26
27
28 .. Note::
29@@ -175,7 +178,8 @@
30 Development MAAS server setup
31 =============================
32
33-Access to the database is configured in ``src/maas/development.py``.
34+Access to the database is configured in
35+``src/maasserver/djangosettings/development.py``.
36
37 The ``Makefile`` or the test suite sets up a development database
38 cluster inside your branch. It lives in the ``db`` directory, which
39
40=== modified file 'Makefile'
41--- Makefile 2016-10-17 06:38:56 +0000
42+++ Makefile 2016-12-02 09:29:56 +0000
43@@ -427,7 +427,8 @@
44 $(warning 'distclean' is deprecated; use 'clean')
45
46 harness: bin/maas-region bin/database
47- $(dbrun) bin/maas-region shell --settings=maas.demo
48+ $(dbrun) bin/maas-region shell \
49+ --settings=maasserver.djangosettings.demo
50
51 dbharness: bin/database
52 bin/database --preserve shell
53
54=== modified file 'buildout.cfg'
55--- buildout.cfg 2016-10-12 15:26:17 +0000
56+++ buildout.cfg 2016-12-02 09:29:56 +0000
57@@ -104,7 +104,7 @@
58 twistd.region=twisted.scripts.twistd:run
59 initialization =
60 ${common:initialization}
61- environ.setdefault("DJANGO_SETTINGS_MODULE", "maas.development")
62+ environ.setdefault("DJANGO_SETTINGS_MODULE", "maasserver.djangosettings.development")
63 scripts =
64 maas-region
65 twistd.region
66@@ -129,7 +129,6 @@
67 # "--with-resources",
68 "--with-scenarios",
69 "--with-select",
70- "--select-dir=src/maas",
71 "--select-dir=src/maasserver",
72 "--select-dir=src/metadataserver",
73 "--cover-package=maas,maasserver,metadataserver",
74@@ -294,7 +293,7 @@
75 from os import environ
76 environ.setdefault("MAAS_RACK_DEVELOP", "TRUE")
77 environ.setdefault("MAAS_ROOT", "${buildout:directory}/run-e2e")
78- environ.setdefault("DJANGO_SETTINGS_MODULE", "maas.development")
79+ environ.setdefault("DJANGO_SETTINGS_MODULE", "maasserver.djangosettings.development")
80 environ.setdefault("DEV_DB_NAME", "test_maas_e2e")
81 environ.setdefault("MAAS_PREVENT_MIGRATIONS", "1")
82
83
84=== modified file 'docs/conf.py'
85--- docs/conf.py 2016-03-28 13:54:47 +0000
86+++ docs/conf.py 2016-12-02 09:29:56 +0000
87@@ -24,7 +24,8 @@
88 from pytz import UTC
89
90 # Configure MAAS's settings.
91-environ.setdefault("DJANGO_SETTINGS_MODULE", "maas.settings")
92+environ.setdefault(
93+ "DJANGO_SETTINGS_MODULE", "maasserver.djangosettings.settings")
94
95 # If extensions (or modules to document with autodoc) are in another directory,
96 # add these directories to sys.path here. If the directory is relative to the
97
98=== modified file 'docs/troubleshooting.rst'
99--- docs/troubleshooting.rst 2014-09-10 16:20:31 +0000
100+++ docs/troubleshooting.rst 2016-12-02 09:29:56 +0000
101@@ -111,7 +111,7 @@
102 always point at the local server.
103 #. If you are still getting "404 - Page not found" errors, check that the MAAS
104 web interface has been installed in the right place. There should be a file
105- present called /usr/share/maas/maas/urls.py
106+ called ``urls.py`` in ``/usr/lib/python3/dist-packages/maasserver/djangosettings/``.
107
108 Debugging ephemeral image
109 =========================
110
111=== modified file 'media/README'
112--- media/README 2012-03-11 21:13:22 +0000
113+++ media/README 2016-12-02 09:29:56 +0000
114@@ -1,5 +1,5 @@
115 This folder contains somewhat ephemeral things: subfolders serve as
116-MEDIA_ROOT for maas.demo and maas.development environments. The
117-media/demo directory should always exist and not be deleted, though
118-its contents can be. The media/development directory should be created
119-and destroyed by tests, as needed.
120+MEDIA_ROOT for maasserver.djangosettings.demo and .development
121+environments. The media/demo directory should always exist and not be
122+deleted, though its contents can be. The media/development directory
123+should be created and destroyed by tests, as needed.
124
125=== modified file 'services/reloader/run'
126--- services/reloader/run 2016-05-11 19:01:48 +0000
127+++ services/reloader/run 2016-12-02 09:29:56 +0000
128@@ -128,7 +128,7 @@
129 exclude_filter=lambda path: (
130 "/test/" in path or "/testing/" in path or "/." in path))
131 wm.add_watch(
132- ["src/maas*", "src/meta*"], TRIGGER_EVENTS,
133+ ["src/maasserver", "src/metadataserver"], TRIGGER_EVENTS,
134 proc_fun=handle_maas_change, rec=True, auto_add=True, do_glob=True)
135 wm.add_watch(
136 ["src/prov*"], TRIGGER_EVENTS, proc_fun=handle_pserv_change,
137
138=== modified file 'src/maascli/cli.py'
139--- src/maascli/cli.py 2016-07-30 01:17:54 +0000
140+++ src/maascli/cli.py 2016-12-02 09:29:56 +0000
141@@ -189,8 +189,8 @@
142 # Setup and the allowed django commands into the maascli.
143 management = get_django_management()
144 if management is not None and is_maasserver_available():
145- os.environ.setdefault("DJANGO_SETTINGS_MODULE", "maas.settings")
146- sys.path.append('/usr/share/maas')
147+ os.environ.setdefault(
148+ "DJANGO_SETTINGS_MODULE", "maasserver.djangosettings.settings")
149 load_regiond_commands(management, parser)
150
151
152
153=== modified file 'src/maasserver/__init__.py'
154--- src/maasserver/__init__.py 2016-10-20 14:45:06 +0000
155+++ src/maasserver/__init__.py 2016-12-02 09:29:56 +0000
156@@ -8,7 +8,7 @@
157 'DefaultViewMeta',
158 'is_master_process',
159 'logger',
160- ]
161+]
162
163 import logging
164 from os import environ
165
166=== renamed directory 'src/maas' => 'src/maasserver/djangosettings'
167=== modified file 'src/maasserver/djangosettings/demo.py'
168--- src/maas/demo.py 2016-06-07 19:59:49 +0000
169+++ src/maasserver/djangosettings/demo.py 2016-12-02 09:29:56 +0000
170@@ -5,7 +5,7 @@
171
172 from os.path import abspath
173
174-from maas import (
175+from maasserver.djangosettings import (
176 development,
177 import_settings,
178 settings,
179
180=== modified file 'src/maasserver/djangosettings/development.py'
181--- src/maas/development.py 2016-10-18 11:21:26 +0000
182+++ src/maasserver/djangosettings/development.py 2016-12-02 09:29:56 +0000
183@@ -7,7 +7,7 @@
184 from os.path import abspath
185
186 from formencode.validators import StringBool
187-from maas import (
188+from maasserver.djangosettings import (
189 fix_up_databases,
190 import_settings,
191 settings,
192
193=== modified file 'src/maasserver/djangosettings/settings.py'
194--- src/maas/settings.py 2016-11-17 11:46:08 +0000
195+++ src/maasserver/djangosettings/settings.py 2016-12-02 09:29:56 +0000
196@@ -6,9 +6,9 @@
197 import os
198
199 import django.template.base
200-from maas import fix_up_databases
201-from maas.monkey import patch_get_script_prefix
202 from maasserver.config import RegionConfiguration
203+from maasserver.djangosettings import fix_up_databases
204+from maasserver.djangosettings.monkey import patch_get_script_prefix
205
206
207 def _read_timezone(tzfilename='/etc/timezone'):
208@@ -265,7 +265,7 @@
209
210 )
211
212-ROOT_URLCONF = 'maas.urls'
213+ROOT_URLCONF = 'maasserver.djangosettings.urls'
214
215 TEMPLATE_DIRS = (
216 # Put strings here, like "/home/html/django_templates"
217
218=== renamed file 'src/maas/tests/test_maas.py' => 'src/maasserver/djangosettings/tests/test_settings.py'
219--- src/maas/tests/test_maas.py 2016-06-21 10:29:11 +0000
220+++ src/maasserver/djangosettings/tests/test_settings.py 2016-12-02 09:29:56 +0000
221@@ -10,11 +10,11 @@
222
223 from django.conf import settings
224 from django.db import connections
225-from maas import (
226+from maasserver.djangosettings import (
227 find_settings,
228 import_settings,
229 )
230-from maas.settings import (
231+from maasserver.djangosettings.settings import (
232 _get_local_timezone,
233 _read_timezone,
234 )
235
236=== modified file 'src/maasserver/management/commands/dbupgrade.py'
237--- src/maasserver/management/commands/dbupgrade.py 2016-09-04 19:57:50 +0000
238+++ src/maasserver/management/commands/dbupgrade.py 2016-12-02 09:29:56 +0000
239@@ -9,6 +9,7 @@
240 __all__ = []
241
242 from importlib import import_module
243+import json
244 import optparse
245 import os
246 import shutil
247@@ -34,7 +35,7 @@
248 # Script that performs the south migrations for MAAS under django 1.6 and
249 # python2.7.
250 MAAS_UPGRADE_SCRIPT = """\
251-# Copyright 2015 Canonical Ltd. This software is licensed under the
252+# Copyright 2015-2016 Canonical Ltd. This software is licensed under the
253 # GNU Affero General Public License version 3 (see the file LICENSE).
254
255 from __future__ import (
256@@ -46,12 +47,49 @@
257 str = None
258
259 __metaclass__ = type
260-__all__ = [
261- ]
262+__all__ = []
263
264 import os
265 import sys
266
267+import django.conf
268+
269+
270+class LazySettings(django.conf.LazySettings):
271+ '''Prevent Django from mangling warnings settings.
272+
273+ At present, Django adds a single filter that surfaces all deprecation
274+ warnings, but MAAS handles them differently. Django doesn't appear to give
275+ a way to prevent it from doing its thing, so we must undo its changes.
276+
277+ Deprecation warnings in production environments are not desirable as they
278+ are a developer tool, and not something an end user can reasonably do
279+ something about. This brings control of warnings back into MAAS's control.
280+ '''
281+
282+ def _configure_logging(self):
283+ # This is a copy of *half* of Django's `_configure_logging`, omitting
284+ # the problematic bits.
285+ if self.LOGGING_CONFIG:
286+ from django.utils.log import DEFAULT_LOGGING
287+ from django.utils.module_loading import import_by_path
288+ # First find the logging configuration function ...
289+ logging_config_func = import_by_path(self.LOGGING_CONFIG)
290+ logging_config_func(DEFAULT_LOGGING)
291+ # ... then invoke it with the logging settings
292+ if self.LOGGING:
293+ logging_config_func(self.LOGGING)
294+
295+
296+# Install our `LazySettings` as the Django-global settings class. First,
297+# ensure that Django hasn't yet loaded its settings.
298+assert not django.conf.settings.configured
299+# This is needed because Django's `LazySettings` overrides `__setattr__`.
300+object.__setattr__(django.conf.settings, "__class__", LazySettings)
301+
302+# Force Django configuration.
303+os.environ["DJANGO_SETTINGS_MODULE"] = "maas19settings"
304+
305 # Inject the sys.path from the parent process so that the python path is
306 # is similar, except that the directory that this script is running from is
307 # already the first path in sys.path.
308@@ -132,6 +170,11 @@
309 tempdir = tempfile.mkdtemp(prefix='maas-upgrade-')
310 subprocess.check_call([
311 "tar", "zxf", path_to_tarball, "-C", tempdir])
312+
313+ settings_json = os.path.join(tempdir, "maas19settings.json")
314+ with open(settings_json, "w", encoding="utf-8") as fd:
315+ fd.write(json.dumps({"DATABASES": settings.DATABASES}))
316+
317 script_path = os.path.join(tempdir, "migrate.py")
318 with open(script_path, "wb") as fp:
319 fp.write(MAAS_UPGRADE_SCRIPT.encode("utf-8"))
320
321=== modified file 'src/maasserver/management/commands/tests/test_dbupgrade.py'
322--- src/maasserver/management/commands/tests/test_dbupgrade.py 2016-03-28 13:54:47 +0000
323+++ src/maasserver/management/commands/tests/test_dbupgrade.py 2016-12-02 09:29:56 +0000
324@@ -64,7 +64,10 @@
325 env = os.environ.copy()
326 env["MAAS_PREVENT_MIGRATIONS"] = "0"
327 mra = os.path.join(root, "bin", "maas-region")
328- cmd = [mra, "dbupgrade", "--settings", "maas.settings"]
329+ cmd = [
330+ mra, "dbupgrade", "--settings",
331+ "maasserver.djangosettings.settings",
332+ ]
333 if always_south:
334 cmd.append("--always-south")
335 self.execute(cmd, env=env)
336
337=== modified file 'src/maasserver/migrations/south/django16_south_maas19.tar.gz'
338Binary files src/maasserver/migrations/south/django16_south_maas19.tar.gz 2016-11-17 11:46:08 +0000 and src/maasserver/migrations/south/django16_south_maas19.tar.gz 2016-12-02 09:29:56 +0000 differ
339=== modified file 'utilities/check-imports'
340--- utilities/check-imports 2016-10-19 17:14:02 +0000
341+++ utilities/check-imports 2016-12-02 09:29:56 +0000
342@@ -263,19 +263,6 @@
343 )
344
345
346-RegionControllerConfig = files("src/maas/**/*.py")
347-RegionControllerConfigRule = Rule(
348- Allow("django|django.**"),
349- Allow("formencode.validators.*"),
350- Allow("maasserver.config.*"),
351- Allow("maasserver.testing.testcase.*"),
352- Allow("maas|maas.**"),
353- Allow("provisioningserver|provisioningserver.**"),
354- Allow("psycopg2|psycopg2.**"),
355- Allow(StandardLibraries),
356-)
357-
358-
359 Tests = files(
360 "src/**/test_*.py",
361 "src/**/testing/**/*.py",
362@@ -424,20 +411,6 @@
363 Allow(TestingLibraries),
364 ),
365 ),
366-
367- #
368- # REGION CONTROLLER CONFIGURATION
369- #
370- (
371- RegionControllerConfig - Tests,
372- RegionControllerConfigRule,
373- ),
374- (
375- RegionControllerConfig & Tests,
376- RegionControllerConfigRule | Rule(
377- Allow(TestingLibraries),
378- ),
379- ),
380 #
381 # TESTING HELPERS
382 #
383
384=== modified file 'utilities/remote-reinstall'
385--- utilities/remote-reinstall 2016-10-27 00:01:01 +0000
386+++ utilities/remote-reinstall 2016-12-02 09:29:56 +0000
387@@ -159,10 +159,6 @@
388 root@${hostname}:/etc/maas
389 ssh_run "chown -R maas:maas /etc/maas"
390
391-echo " - src/maas --> /usr/share/maas/maas"
392-try rsync -${rsync_options} src/maas/ \
393- root@${hostname}:/usr/share/maas/maas
394-
395 echo ""
396 echo "Synchronizing static web content..."
397 echo " - Removing /usr/share/maas/web/static/*..."