Merge lp:~bladernr/maas-cert-server/1621986-mcs-mirror-cloud-images into lp:~hardware-certification/maas-cert-server/trunk

Proposed by Jeff Lane 
Status: Merged
Approved by: Rod Smith
Approved revision: 66
Merged at revision: 65
Proposed branch: lp:~bladernr/maas-cert-server/1621986-mcs-mirror-cloud-images
Merge into: lp:~hardware-certification/maas-cert-server/trunk
Diff against target: 110 lines (+46/-25)
1 file modified
usr/sbin/maniacs-setup (+46/-25)
To merge this branch: bzr merge lp:~bladernr/maas-cert-server/1621986-mcs-mirror-cloud-images
Reviewer Review Type Date Requested Status
Rod Smith Approve
Jeff Lane  Needs Resubmitting
Review via email: mp+305607@code.launchpad.net

Description of the change

Modifies maniacs-setup to download a mirror of cloud-images.ubuntu.com (it downloads ONLY the specified versions set up in GLOBALS and prompts the user for each one).

I've tested this on digital-ocean and it seems to work for both the case of a new server and a serve where we're re-running with -d.

To post a comment you must log in.
Revision history for this message
Rod Smith (rodsmith) wrote :

I've got some suggestions for improvements to the procedure, and one minor prompting issue. If you don't want to tackle the bigger issue now, I can approve this with just the prompt issue fixed, and you or I can fix the bigger procedural issues later.

review: Needs Fixing
66. By Jeff Lane 

fixed typo

Revision history for this message
Jeff Lane  (bladernr) wrote :

I fixed the missing 'take'. Lets go with that for now and I'll email the rest of the thoughts because I think they're a bit bigger than this MR>

review: Needs Resubmitting
Revision history for this message
Rod Smith (rodsmith) wrote :

OK, I'll approve it as-is and we can deal with the other issues later....

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'usr/sbin/maniacs-setup'
2--- usr/sbin/maniacs-setup 2016-08-22 13:20:59 +0000
3+++ usr/sbin/maniacs-setup 2016-09-13 18:57:37 +0000
4@@ -39,7 +39,7 @@
5 UPDATE_PRESEEDS=0
6 while [[ $# -gt 0 ]]; do
7 case $1 in
8- --download-virtualization-image|-d)
9+ --download-virtualization-images|-d)
10 DOWNLOAD_VIRTUALIZATION_IMAGE=1
11 DO_IT_ALL=0
12 ;;
13@@ -59,7 +59,7 @@
14 UPDATE_POINT_RELEASES=1
15 DO_IT_ALL=0
16 ;;
17- *) echo "Usage: $0 [ --download-virtualization-image ]"
18+ *) echo "Usage: $0 [ --download-virtualization-images ]"
19 echo " [ --import-boot-resources ] [ --mirror-archives ]"
20 echo " [ --update-point-releases ] [ --update-preseeds ]"
21 DO_IT_ALL=0
22@@ -140,7 +140,8 @@
23 MIRROR_LIST="/etc/apt/mirror.list"
24 # Below is URL given to nodes; it's also verified by the user later.
25 DEFAULT_REPO_URL=$MIRROR_FROM_ARCHIVE
26- CLOUD_IMAGE="trusty-server-cloudimg-i386-disk1.img"
27+ CLOUD_RELEASES="trusty xenial yakkety"
28+ CLOUD_MIRROR="/srv/cloud"
29 RETRY=10
30 MIRRORED=0
31
32@@ -512,27 +513,47 @@
33 retrieve_virtualization_image() {
34 echo
35 echo "***************************************************************************"
36- echo "* An Ubuntu cloud image is required for virtualization tests. Having such an"
37- echo "* image on your MAAS server can be convenient, but downloading it can take"
38- echo "* a while (it's about 250MiB)."
39- echo "*"
40- if [ -f /srv/$CLOUD_IMAGE ] ; then
41- echo "* A cloud image file already exists at /srv/$CLOUD_IMAGE;"
42- echo "* skipping download."
43+ echo "* An Ubuntu cloud image is required for virtualization tests. Having such"
44+ echo "* an image on your MAAS server can be convenient, but downloading it can"
45+ echo "* take a while (each image is about 250MiB). This process will import cloud"
46+ echo "* images for each supported architecture for the selected release"
47+ echo "*"
48+ if [ -d $CLOUD_MIRROR ] ; then
49+ echo "* A mirror of cloud images seems to already exists at /srv/cloud;"
50+ get_yn "* Do you wish to continue?" "N"
51+ if [ $YN = "N" ]; then
52+ echo "Skipping."
53+ return
54+ fi
55+ fi
56+ echo "* To defer this task, respond 'N' to the following question."
57+ echo "*"
58+ get_yn "* Do you want to set up a local cloud image mirror for the virtualization tests" "Y"
59+ if [ $YN = "Y" ] ; then
60+ if [ ! -d $CLOUD_MIRROR ] ; then
61+ echo "* Cloud Mirror does not exist. Creating."
62+ mkdir -p $CLOUD_MIRROR
63+ ln -sf $CLOUD_MIRROR /var/www/html
64+ fi
65+ for release in $CLOUD_RELEASES; do
66+ get_yn "* Do you want to get images for $release?" "Y"
67+ if [ $YN = "Y" ]; then
68+ get_these="$get_these $release"
69+ fi
70+ done
71+ echo "* Downloading cloud images. This may take some time."
72+ for release in $get_these; do
73+ wget --mirror -r -nH --adjust-extension --no-parent -P $CLOUD_MIRROR \
74+ --convert-links http://cloud-images.ubuntu.com/$release/current/
75+ done
76+ echo "*"
77+ echo "* Virtualization image mirror is stored as $CLOUD_MIRROR"
78+ echo "* and is available at http://$INTERNAL_IP/cloud/"
79 else
80- echo "* To defer this task, respond 'N' to the following question."
81- echo "*"
82- get_yn "* Do you want to copy a cloud image for the virtualization tests" "Y"
83- if [ $YN = "Y" ] ; then
84- wget -P /srv http://cloud-images.ubuntu.com/trusty/current/$CLOUD_IMAGE
85- echo "*"
86- echo "* Virtualization image is stored as /srv/$CLOUD_IMAGE"
87- else
88- echo "*"
89- echo "* You can download a virtualization image later by running this script with"
90- echo "* the --download-virtualization-image (or -d) option."
91- echo "*"
92- fi
93+ echo "*"
94+ echo "* You can download virtualization images later by running this script with"
95+ echo "* the --download-virtualization-images (or -d) option."
96+ echo "*"
97 fi
98 }
99
100@@ -1003,8 +1024,8 @@
101 echo "* You can set up a local mirror later by running this script with the"
102 echo "* --mirror-archives (or -m) option."
103 echo "*"
104- echo "* You can download a virtualization image later by running this script with"
105- echo "* the --download-virtualization-image (or -d) option."
106+ echo "* You can download virtualization images later by running this script with"
107+ echo "* the --download-virtualization-images (or -d) option."
108 echo "*"
109 echo "* You can import boot resources via the MAAS web UI or by re-running this"
110 echo "* script with the --import-boot-resources (or -i) option."

Subscribers

People subscribed via source and target branches

to status/vote changes: