← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~andreserl/maas/use_squashfs_filesystem_2 into lp:maas

 

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
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~andreserl/maas/use_squashfs_filesystem_2 into lp:maas.
=== 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}
@@ -191,6 +195,15 @@
 }
 
 
+# Download and install the squashfs root images.
+import_squashfs_images() {
+    if test "$IMPORT_SQUASHFS" != "0"
+    then
+        maas-import-squashfs
+    fi
+}
+
+
 # Download and install the ephemeral images.
 import_ephemeral_images() {
     if test "$IMPORT_EPHEMERALS" != "0"

=== modified file 'scripts/maas-import-squashfs'
--- scripts/maas-import-squashfs	2012-10-01 23:16:29 +0000
+++ scripts/maas-import-squashfs	2012-10-02 19:13:28 +0000
@@ -1,4 +1,4 @@
-#!/bin/bash -x
+#!/bin/bash
 #
 # maas-import-squashfs - sync and import squashfs images
 #
@@ -33,7 +33,7 @@
 # Download locations for Ubuntu releases.
 #http://cdimage.ubuntu.com/ubuntu-server/daily/current/
 SQUASHFS_ARCHIVE=${ARCHIVE:-http://cdimage.ubuntu.com/}
-RELEASES="quantal"
+
 # Ubuntu releases that are to be downloaded.
 SUPPORTED_RELEASES=""
 for supported in $(distro-info --supported)

=== modified file 'src/maasserver/preseed.py'
--- src/maasserver/preseed.py	2012-09-27 15:39:38 +0000
+++ src/maasserver/preseed.py	2012-10-02 19:13:28 +0000
@@ -31,7 +31,13 @@
 from maasserver.models import Config
 from maasserver.server_address import get_maas_facing_server_host
 from maasserver.utils import absolute_reverse
+from provisioningserver.config import Config as PConfig
+from provisioningserver.pxe.tftppath import (
+    compose_image_path,
+    locate_tftp_path,
+)
 import tempita
+import os
 
 
 GENERIC_FILENAME = 'generic'
@@ -228,12 +234,22 @@
             'preseed_data': compose_preseed(node),
             'node_disable_pxe_url': node_disable_pxe_url,
             'node_disable_pxe_data': node_disable_pxe_data,
+            'use_squashfs': is_squashfs_image_present(node),
         }
         context.update(node_context)
 
     return context
 
 
+def is_squashfs_image_present(node):
+    tftproot = PConfig.load_from_cache()['tftp']['root']
+    arch, subarch = node.architecture.split("/")
+    path = compose_image_path(arch, subarch, node.get_distro_series(), "filesystem")
+    path = locate_tftp_path(path, tftproot)
+    path = os.path.join(path, "filesystem.squashfs")
+    return os.path.exists(path)
+
+
 def render_preseed(node, prefix, release=''):
     """Find and load a `PreseedTemplate` for the given node.
 

=== modified file 'src/maasserver/tests/test_preseed.py'
--- src/maasserver/tests/test_preseed.py	2012-09-27 15:39:39 +0000
+++ src/maasserver/tests/test_preseed.py	2012-10-02 19:13:28 +0000
@@ -30,6 +30,7 @@
     get_preseed_context,
     get_preseed_filenames,
     get_preseed_template,
+    is_squashfs_image_present,
     load_preseed_template,
     PreseedTemplate,
     render_preseed,
@@ -295,7 +296,8 @@
         self.assertItemsEqual(
             ['node', 'release', 'metadata_enlist_url',
              'server_host', 'server_url', 'preseed_data',
-             'node_disable_pxe_url', 'node_disable_pxe_data'],
+             'node_disable_pxe_url', 'node_disable_pxe_data',
+             'use_squashfs'],
             context)
 
     def test_get_preseed_context_if_node_None(self):
@@ -309,6 +311,14 @@
             context)
 
 
+class TestSquashfsAvailable(TestCase):
+
+    def test_is_squashfs_image_present_false(self):
+        node = factory.make_node(distro_series="quantal")
+        exists = is_squashfs_image_present(node)
+        self.assertFalse(exists)
+
+
 class TestPreseedTemplate(TestCase):
     """Tests for class:`PreseedTemplate`."""
 


Follow ups