Merge lp:~andreserl/maas/use_squashfs_filesystem_2 into lp:maas/trunk

Proposed by Andres Rodriguez on 2012-10-02
Status: Merged
Approved by: Andres Rodriguez on 2012-10-03
Approved revision: 1136
Merged at revision: 1152
Proposed branch: lp:~andreserl/maas/use_squashfs_filesystem_2
Merge into: lp:maas/trunk
Diff against target: 201 lines (+76/-5)
7 files modified
contrib/maas-http.conf (+6/-0)
contrib/preseeds_v2/generic (+11/-1)
contrib/preseeds_v2/preseed_master (+3/-0)
scripts/maas-import-pxe-files (+13/-0)
scripts/maas-import-squashfs (+2/-2)
src/maasserver/preseed.py (+12/-1)
src/maasserver/tests/test_preseed.py (+29/-1)
To merge this branch: bzr merge lp:~andreserl/maas/use_squashfs_filesystem_2
Reviewer Review Type Date Requested Status
Gavin Panella (community) 2012-10-02 Approve on 2012-10-02
Review via email: mp+127577@code.launchpad.net

Commit Message

Make use of squashfs when install quantal or up

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

So Fixed the issue raised by allenap in the code.

The issues about the preseeds evaluating arch... it was discussed with him that symlinking preseeds on arch bases or inheriting would be too much complexity. For now leaving as is.

Gavin Panella (allenap) wrote :

Looks good :)

As discussed on IRC, there aren't any tests for the templates, but
then there aren't any for the other templates, only general "does
templating work" tests. Because of the confusion with Tempita's
inheritance mechanism, I think we need to revisit this area after
12.10 anyway.

[1]

+    return BootImage.objects.have_image(
+        arch, subarch, node.get_distro_series(), "filesystem")

My one suggestion would be to change "filesystem" to "squashfs" or
something more descriptive.

review: Approve
Andres Rodriguez (andreserl) wrote :
Download full text (6.7 KiB)

Hi Gavin,

The squashfs image is the root filesystem image, hence the name. I think it
is appropriate to categorize it that way (as it is now - filesystem).

Cheers
On Oct 2, 2012 3:19 PM, "Andres Rodriguez" <email address hidden> wrote:

> Andres Rodriguez has proposed merging
> lp:~andreserl/maas/use_squashfs_filesystem_2 into lp:maas.
>
> Requested reviews:
> Launchpad code reviewers (launchpad-reviewers)
>
> For more details, see:
>
> https://code.launchpad.net/~andreserl/maas/use_squashfs_filesystem_2/+merge/127577
> --
>
> https://code.launchpad.net/~andreserl/maas/use_squashfs_filesystem_2/+merge/127577
> You are the owner of lp:~andreserl/maas/use_squashfs_filesystem_2.
>
> === modified file 'contrib/maas-http.conf'
> --- contrib/maas-http.conf 2012-09-25 09:48:17 +0000
> +++ contrib/maas-http.conf 2012-10-02 19:13:28 +0000
> @@ -45,6 +45,12 @@
> SetHandler None
> </Directory>
>
> +# Serve squashfs images
> +Alias /MAAS/static/images/ /var/lib/maas/tftp/
> +<Directory /var/lib/maas/tftp/>
> + SetHandler None
> +</Directory>
> +
> # Serve files from staticfiles.
> Alias /MAAS/static/ /usr/share/maas/web/static/
> <Directory /usr/share/maas/web/static/>
>
> === modified file 'contrib/preseeds_v2/generic'
> --- contrib/preseeds_v2/generic 2012-09-21 16:42:19 +0000
> +++ contrib/preseeds_v2/generic 2012-10-02 19:13:28 +0000
> @@ -1,7 +1,17 @@
> {{inherit "preseed_master"}}
> +
> +{{def squashfs_image}}
> +{{if node.distro_series in {'quantal'} and node.architecture in
> {'i386/generic', 'amd64/generic'} and use_squashfs is True }}
> +d-i preseed/early_command string anna-install live-installer
> +d-i live-installer/enable boolean true
> +d-i live-installer/mode select normal
> +d-i live-installer/net-image string http://
> {{server_host}}/MAAS/static/images/{{node.architecture}}/{{node.distro_series}}/filesystem/filesystem.squashfs
> +{{endif}}
> +{{enddef}}
> +
> {{def proxy}}
> d-i mirror/country string manual
> -{{if node.architecture in {'i386', 'amd64'} }}
> +{{if node.architecture in {'i386/generic', 'amd64/generic'} }}
> d-i mirror/http/hostname string archive.ubuntu.com
> d-i mirror/http/directory string /ubuntu
> {{else}}
>
> === modified file 'contrib/preseeds_v2/preseed_master'
> --- contrib/preseeds_v2/preseed_master 2012-08-03 16:33:05 +0000
> +++ contrib/preseeds_v2/preseed_master 2012-10-02 19:13:28 +0000
> @@ -3,6 +3,9 @@
> # * Cloud-init for bare-metal
> # * Cloud-init preseed data
>
> +# Squashfs Installation
> +{{self.squashfs_image}}
> +
> # Locale
> d-i debian-installer/locale string en_US.UTF-8
>
>
> === modified file 'scripts/maas-import-pxe-files'
> --- scripts/maas-import-pxe-files 2012-09-29 03:12:23 +0000
> +++ scripts/maas-import-pxe-files 2012-10-02 19:13:28 +0000
> @@ -45,6 +45,10 @@
> # Default is yes.
> IMPORT_SQUASHFS=${IMPORT_SQUASHFS:-1}
>
> +# Whether to download squashfs images as well: "1" for yes, "0" for no.
> +# Default is yes.
> +IMPORT_SQUASHFS=${IMPORT_SQUASHFS:-1}
> +
> # Whether to download ephemeral images as well: "1" for yes, "0" for no.
> # Default is yes.
> IMPORT_EPHEMERALS=${IMPORT_EPHEMERALS:-1}
> @@ -1...

Read more...

Gavin Panella (allenap) wrote :

On 2 October 2012 23:26, Andres Rodriguez <email address hidden> wrote:
> The squashfs image is the root filesystem image, hence the name. I think it
> is appropriate to categorize it that way (as it is now - filesystem).

The problem is that the function is called is_squashfs_image_present,
but it looks for "filesystem" via BootImage. The boot image scanner
makes assumptions about the files within a leaf directory, and doesn't
record them in the database.

The squashfs code is piggybacking on top of the tftp code, so, unless
you change that boot image code, it ought to work with the scheme as
it is. Hence the idea for putting "squashfs" somewhere in the path
where the boot image scanner will find it.

It's not very important though, I just wanted to make you aware of it.

Andres Rodriguez (andreserl) wrote :

Would it make more sense to change it to is_filesystem_image_present or is is_root_filesystem_image_present? Because the layout of how the directories are stored under the tftproot are:

 - commissioning - > Is a hint to the purpose
 - install -> Is hint to the purpose

So, that's why I added the "filesystem", to give a hint of what it is, or the purpose of it. Ideally, however, I would have loved to have this under install/, but that would result in overwriting the directory

 - filesystem -> hint of the purpose

Other than that, I don't really mind having it change to "squashfs". If you prefer i can just change it to squashfs (which will require to change maas-import-squashfs)

Cheers

MAAS Lander (maas-lander) wrote :

No commit message specified.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'contrib/maas-http.conf'
2--- contrib/maas-http.conf 2012-09-25 09:48:17 +0000
3+++ contrib/maas-http.conf 2012-10-02 21:50:23 +0000
4@@ -45,6 +45,12 @@
5 SetHandler None
6 </Directory>
7
8+# Serve squashfs images
9+Alias /MAAS/static/images/ /var/lib/maas/tftp/
10+<Directory /var/lib/maas/tftp/>
11+ SetHandler None
12+</Directory>
13+
14 # Serve files from staticfiles.
15 Alias /MAAS/static/ /usr/share/maas/web/static/
16 <Directory /usr/share/maas/web/static/>
17
18=== modified file 'contrib/preseeds_v2/generic'
19--- contrib/preseeds_v2/generic 2012-09-21 16:42:19 +0000
20+++ contrib/preseeds_v2/generic 2012-10-02 21:50:23 +0000
21@@ -1,7 +1,17 @@
22 {{inherit "preseed_master"}}
23+
24+{{def squashfs_image}}
25+{{if node.distro_series in {'quantal'} and node.architecture in {'i386/generic', 'amd64/generic'} and use_squashfs is True }}
26+d-i preseed/early_command string anna-install live-installer
27+d-i live-installer/enable boolean true
28+d-i live-installer/mode select normal
29+d-i live-installer/net-image string http://{{server_host}}/MAAS/static/images/{{node.architecture}}/{{node.distro_series}}/filesystem/filesystem.squashfs
30+{{endif}}
31+{{enddef}}
32+
33 {{def proxy}}
34 d-i mirror/country string manual
35-{{if node.architecture in {'i386', 'amd64'} }}
36+{{if node.architecture in {'i386/generic', 'amd64/generic'} }}
37 d-i mirror/http/hostname string archive.ubuntu.com
38 d-i mirror/http/directory string /ubuntu
39 {{else}}
40
41=== modified file 'contrib/preseeds_v2/preseed_master'
42--- contrib/preseeds_v2/preseed_master 2012-08-03 16:33:05 +0000
43+++ contrib/preseeds_v2/preseed_master 2012-10-02 21:50:23 +0000
44@@ -3,6 +3,9 @@
45 # * Cloud-init for bare-metal
46 # * Cloud-init preseed data
47
48+# Squashfs Installation
49+{{self.squashfs_image}}
50+
51 # Locale
52 d-i debian-installer/locale string en_US.UTF-8
53
54
55=== modified file 'scripts/maas-import-pxe-files'
56--- scripts/maas-import-pxe-files 2012-10-02 17:00:19 +0000
57+++ scripts/maas-import-pxe-files 2012-10-02 21:50:23 +0000
58@@ -45,6 +45,10 @@
59 # Default is yes.
60 IMPORT_SQUASHFS=${IMPORT_SQUASHFS:-1}
61
62+# Whether to download squashfs images as well: "1" for yes, "0" for no.
63+# Default is yes.
64+IMPORT_SQUASHFS=${IMPORT_SQUASHFS:-1}
65+
66 # Whether to download ephemeral images as well: "1" for yes, "0" for no.
67 # Default is yes.
68 IMPORT_EPHEMERALS=${IMPORT_EPHEMERALS:-1}
69@@ -196,6 +200,15 @@
70 }
71
72
73+# Download and install the squashfs root images.
74+import_squashfs_images() {
75+ if test "$IMPORT_SQUASHFS" != "0"
76+ then
77+ maas-import-squashfs
78+ fi
79+}
80+
81+
82 # Download and install the ephemeral images.
83 import_ephemeral_images() {
84 if test "$IMPORT_EPHEMERALS" != "0"
85
86=== modified file 'scripts/maas-import-squashfs'
87--- scripts/maas-import-squashfs 2012-10-01 23:16:29 +0000
88+++ scripts/maas-import-squashfs 2012-10-02 21:50:23 +0000
89@@ -1,4 +1,4 @@
90-#!/bin/bash -x
91+#!/bin/bash
92 #
93 # maas-import-squashfs - sync and import squashfs images
94 #
95@@ -33,7 +33,7 @@
96 # Download locations for Ubuntu releases.
97 #http://cdimage.ubuntu.com/ubuntu-server/daily/current/
98 SQUASHFS_ARCHIVE=${ARCHIVE:-http://cdimage.ubuntu.com/}
99-RELEASES="quantal"
100+
101 # Ubuntu releases that are to be downloaded.
102 SUPPORTED_RELEASES=""
103 for supported in $(distro-info --supported)
104
105=== modified file 'src/maasserver/preseed.py'
106--- src/maasserver/preseed.py 2012-09-27 15:39:38 +0000
107+++ src/maasserver/preseed.py 2012-10-02 21:50:23 +0000
108@@ -28,7 +28,10 @@
109 NODE_STATUS,
110 PRESEED_TYPE,
111 )
112-from maasserver.models import Config
113+from maasserver.models import (
114+ BootImage,
115+ Config,
116+ )
117 from maasserver.server_address import get_maas_facing_server_host
118 from maasserver.utils import absolute_reverse
119 import tempita
120@@ -228,12 +231,20 @@
121 'preseed_data': compose_preseed(node),
122 'node_disable_pxe_url': node_disable_pxe_url,
123 'node_disable_pxe_data': node_disable_pxe_data,
124+ 'use_squashfs': is_squashfs_image_present(node),
125 }
126 context.update(node_context)
127
128 return context
129
130
131+def is_squashfs_image_present(node):
132+ """Whether or not the SquashFS image can be used during installation."""
133+ arch, subarch = node.architecture.split("/")
134+ return BootImage.objects.have_image(
135+ arch, subarch, node.get_distro_series(), "filesystem")
136+
137+
138 def render_preseed(node, prefix, release=''):
139 """Find and load a `PreseedTemplate` for the given node.
140
141
142=== modified file 'src/maasserver/tests/test_preseed.py'
143--- src/maasserver/tests/test_preseed.py 2012-09-27 15:39:39 +0000
144+++ src/maasserver/tests/test_preseed.py 2012-10-02 21:50:23 +0000
145@@ -21,6 +21,7 @@
146 NODE_STATUS,
147 PRESEED_TYPE,
148 )
149+from maasserver.models import BootImage
150 from maasserver.preseed import (
151 compose_enlistment_preseed_url,
152 compose_preseed_url,
153@@ -30,6 +31,7 @@
154 get_preseed_context,
155 get_preseed_filenames,
156 get_preseed_template,
157+ is_squashfs_image_present,
158 load_preseed_template,
159 PreseedTemplate,
160 render_preseed,
161@@ -295,7 +297,8 @@
162 self.assertItemsEqual(
163 ['node', 'release', 'metadata_enlist_url',
164 'server_host', 'server_url', 'preseed_data',
165- 'node_disable_pxe_url', 'node_disable_pxe_data'],
166+ 'node_disable_pxe_url', 'node_disable_pxe_data',
167+ 'use_squashfs'],
168 context)
169
170 def test_get_preseed_context_if_node_None(self):
171@@ -309,6 +312,31 @@
172 context)
173
174
175+class TestSquashFSAvailable(TestCase):
176+ """Tests for `is_squashfs_image_present`."""
177+
178+ # Scenario defaults.
179+ arch = "i386"
180+ subarch = "generic"
181+ series = "quantal"
182+ purpose = "filesystem"
183+
184+ scenarios = (
185+ ("mismatch-arch", dict(arch="amd64", present=False)),
186+ ("mismatch-subarch", dict(subarch="special", present=False)),
187+ ("mismatch-series", dict(series="precise", present=False)),
188+ ("mismatch-purpose", dict(purpose="moonraking", present=False)),
189+ ("match", dict(present=True)),
190+ )
191+
192+ def test_squashfs_available(self):
193+ BootImage.objects.register_image(
194+ self.arch, self.subarch, self.series, self.purpose)
195+ node = factory.make_node(
196+ architecture="i386/generic", distro_series="quantal")
197+ self.assertEqual(self.present, is_squashfs_image_present(node))
198+
199+
200 class TestPreseedTemplate(TestCase):
201 """Tests for class:`PreseedTemplate`."""
202