launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #12688
[Merge] lp:~andreserl/maas/maas_import_squashfs into lp:maas
Andres Rodriguez has proposed merging lp:~andreserl/maas/maas_import_squashfs into lp:maas.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~andreserl/maas/maas_import_squashfs/+merge/127091
--
https://code.launchpad.net/~andreserl/maas/maas_import_squashfs/+merge/127091
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~andreserl/maas/maas_import_squashfs into lp:maas.
=== modified file 'etc/maas/import_pxe_files'
--- etc/maas/import_pxe_files 2012-09-18 10:49:01 +0000
+++ etc/maas/import_pxe_files 2012-09-29 03:32:21 +0000
@@ -17,3 +17,4 @@
#ARCHES="amd64/generic i386/generic"
#LOCALE="en_US"
#IMPORT_EPHEMERALS=1
+#IMPORT_SQUASHFS=1
=== added file 'etc/maas/import_squashfs'
--- etc/maas/import_squashfs 1970-01-01 00:00:00 +0000
+++ etc/maas/import_squashfs 2012-09-29 03:32:21 +0000
@@ -0,0 +1,6 @@
+## get default settings from import_pxe_files
+[ ! -f /etc/maas/import_pxe_files ] || . /etc/maas/import_pxe_files
+
+#SQUASHFS_ARCHIVE="https://cdimage.ubuntu.com"
+#RELEASES="quantal"
+#ARCHES="amd64 i386"
=== modified file 'scripts/maas-import-pxe-files'
--- scripts/maas-import-pxe-files 2012-09-21 14:53:42 +0000
+++ scripts/maas-import-pxe-files 2012-09-29 03:32:21 +0000
@@ -41,6 +41,10 @@
# directory. A wget command line will work here, but curl will do as well.
DOWNLOAD=${DOWNLOAD:-wget --no-verbose}
+# 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}
@@ -178,6 +182,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"
@@ -194,6 +207,7 @@
update_pre_boot_loader
import_install_images
+ import_squashfs_images
import_ephemeral_images
}
=== added file 'scripts/maas-import-squashfs'
--- scripts/maas-import-squashfs 1970-01-01 00:00:00 +0000
+++ scripts/maas-import-squashfs 2012-09-29 03:32:21 +0000
@@ -0,0 +1,172 @@
+#!/bin/bash
+#
+# maas-import-squashfs - sync and import squashfs images
+#
+# Copyright (C) 2012 Canonical
+#
+# Authors:
+# Andres Rodriguez <andres.rodriguez@xxxxxxxxxxxxx>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, version 3 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Exit immediately if a command exits with a non-zero status.
+set -o errexit
+# Treat unset variables as an error when substituting.
+set -o nounset
+
+# Load settings if available.
+settings="/etc/maas/import_squashfs"
+[ -r $settings ] && . $settings
+local_settings="$(pwd)/$settings"
+[ -r $local_settings ] && . $local_settings
+
+# Download locations for Ubuntu releases.
+#http://cdimage.ubuntu.com/ubuntu-server/daily/current/
+SQUASHFS_ARCHIVE=${ARCHIVE:-http://cdimage.ubuntu.com/}
+
+# Ubuntu releases that are to be downloaded.
+SUPPORTED_RELEASES=""
+for supported in $(distro-info --supported)
+do
+ if [ $(expr "$supported" \>= "quantal") -eq 1 ]; then
+ SUPPORTED_RELEASES="${SUPPORTED_RELEASES:-}${supported} "
+ fi
+done
+
+EFFECTIVE_RELEASES=""
+if [ -z "$RELEASES" ]; then
+ RELEASES=${RELEASES:-$SUPPORTED_RELEASES}
+else
+ for release in $RELEASES
+ do
+ [[ "$SUPPORTED_RELEASES" =~ "${release}" ]] && EFFECTIVE_RELEASES="${EFFECTIVE_RELEASES:-}${release} "
+ done
+ RELEASES="$EFFECTIVE_RELEASES"
+fi
+
+# The current Ubuntu release.
+STABLE_RELEASE=$(distro-info --stable)
+
+# Supported architectures.
+ARCHES=${ARCHES:-amd64 i386}
+
+# Command line to download a resource at a given URL into the current
+# directory. A wget command line will work here, but curl will do as well.
+DOWNLOAD=${DOWNLOAD:-wget --no-verbose}
+
+# Whether to download squashfs images as well: "1" for yes, "0" for no.
+# Default is yes.
+IMPORT_SQUASHFS=${IMPORT_SQUASHFS:-1}
+
+# Put together a full URL for where the installer files for architecture $1
+# and release $2 can be downloaded.
+compose_installer_download_url() {
+ local arch=$1 release=$2
+
+ case $arch in
+ amd64|i386)
+ local installer_url="$SQUASHFS_ARCHIVE/ubuntu-server/daily/current"
+ echo $installer_url
+ ;;
+ *)
+ echo "Unknown architecture: $arch" >&2
+ exit 1
+ ;;
+ esac
+}
+
+# Return a list of files for architecture $1 and release $2 that need to be
+# downloaded
+compose_installer_download_files() {
+ local arch=$1 release=$2
+
+ case $arch in
+ amd64|i386)
+ echo "$release-server-$arch.squashfs"
+ ;;
+ *)
+ echo "Unknown architecture: $arch" >&2
+ exit 1
+ ;;
+ esac
+}
+
+# Rename downloaded files for architecture $1 and release $2 into the form that
+# MAAS expects them
+rename_installer_download_files() {
+ local arch=$1 release=$2
+
+ case $arch in
+ amd64|i386)
+ mv $release-server-$arch.squashfs filesystem.squashfs
+ ;;
+ *)
+ echo "Unknown architecture: $arch" >&2
+ exit 1
+ ;;
+ esac
+}
+
+# Download kernel/initrd for installing Ubuntu release $2 for
+# architecture $1 and install it into the TFTP directory hierarchy.
+update_install_files() {
+ local arch=$1 release=$2
+ local files=$(compose_installer_download_files $arch $release)
+ local url=$(compose_installer_download_url $arch $release)
+ local file
+
+ mkdir "install"
+ pushd "install" >/dev/null
+ for file in $files
+ do
+ $DOWNLOAD $url/$file
+ done
+ rename_installer_download_files $arch $release
+ popd >/dev/null
+
+ maas-provision install-pxe-image \
+ --arch="${arch}" --subarch="generic" \
+ --release=$release --purpose="filesystem" \
+ --image="install"
+}
+
+
+# Download and install the "install" images.
+import_install_images() {
+ local arch release DOWNLOAD_DIR
+
+ DOWNLOAD_DIR=$(mktemp -d)
+ echo "Downloading to temporary location $DOWNLOAD_DIR."
+ pushd -- $DOWNLOAD_DIR
+
+ for arch in $ARCHES
+ do
+ for release in $RELEASES
+ do
+ update_install_files $arch $release
+ done
+ done
+
+ popd
+ rm -rf -- $DOWNLOAD_DIR
+}
+
+
+main() {
+ # All files we create here are public. The TFTP user will need to be
+ # able to read them.
+ umask a+r
+ import_install_images
+}
+
+main
=== modified file 'setup.py'
--- setup.py 2012-09-28 23:08:20 +0000
+++ setup.py 2012-09-29 03:32:21 +0000
@@ -58,6 +58,7 @@
'etc/maas_cluster.conf',
'etc/txlongpoll.yaml',
'contrib/maas_local_celeryconfig.py',
+ 'etc/maas/import_squashfs',
'etc/maas/import_ephemerals',
'etc/maas/import_pxe_files',
'etc/maas/commissioning-user-data',
@@ -77,7 +78,8 @@
'contrib/preseeds_v2/enlist_userdata',
'contrib/preseeds_v2/preseed_master']),
('/usr/sbin',
- ['scripts/maas-import-ephemerals',
+ ['scripts/maas-import-squashfs',
+ 'scripts/maas-import-ephemerals',
'scripts/maas-import-pxe-files']),
],
=== modified file 'src/provisioningserver/tests/test_maas_import_pxe_files.py'
--- src/provisioningserver/tests/test_maas_import_pxe_files.py 2012-09-21 14:53:58 +0000
+++ src/provisioningserver/tests/test_maas_import_pxe_files.py 2012-09-29 03:32:21 +0000
@@ -160,6 +160,9 @@
# Suppress running of maas-import-ephemerals. It gets too
# intimate with the system to test here.
'IMPORT_EPHEMERALS': '0',
+ # Suppress running of maas-import-squashfs. It gets too
+ # intimate with the system to test here.
+ 'IMPORT_SQUASHFS': '0',
}
env.update(self.config_fixture.environ)
if arch is not None:
Follow ups