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
=== modified file 'usr/sbin/maniacs-setup'
--- usr/sbin/maniacs-setup 2016-08-22 13:20:59 +0000
+++ usr/sbin/maniacs-setup 2016-09-13 18:57:37 +0000
@@ -39,7 +39,7 @@
39 UPDATE_PRESEEDS=039 UPDATE_PRESEEDS=0
40 while [[ $# -gt 0 ]]; do40 while [[ $# -gt 0 ]]; do
41 case $1 in41 case $1 in
42 --download-virtualization-image|-d)42 --download-virtualization-images|-d)
43 DOWNLOAD_VIRTUALIZATION_IMAGE=143 DOWNLOAD_VIRTUALIZATION_IMAGE=1
44 DO_IT_ALL=044 DO_IT_ALL=0
45 ;;45 ;;
@@ -59,7 +59,7 @@
59 UPDATE_POINT_RELEASES=159 UPDATE_POINT_RELEASES=1
60 DO_IT_ALL=060 DO_IT_ALL=0
61 ;;61 ;;
62 *) echo "Usage: $0 [ --download-virtualization-image ]"62 *) echo "Usage: $0 [ --download-virtualization-images ]"
63 echo " [ --import-boot-resources ] [ --mirror-archives ]"63 echo " [ --import-boot-resources ] [ --mirror-archives ]"
64 echo " [ --update-point-releases ] [ --update-preseeds ]"64 echo " [ --update-point-releases ] [ --update-preseeds ]"
65 DO_IT_ALL=065 DO_IT_ALL=0
@@ -140,7 +140,8 @@
140 MIRROR_LIST="/etc/apt/mirror.list"140 MIRROR_LIST="/etc/apt/mirror.list"
141 # Below is URL given to nodes; it's also verified by the user later.141 # Below is URL given to nodes; it's also verified by the user later.
142 DEFAULT_REPO_URL=$MIRROR_FROM_ARCHIVE142 DEFAULT_REPO_URL=$MIRROR_FROM_ARCHIVE
143 CLOUD_IMAGE="trusty-server-cloudimg-i386-disk1.img"143 CLOUD_RELEASES="trusty xenial yakkety"
144 CLOUD_MIRROR="/srv/cloud"
144 RETRY=10145 RETRY=10
145 MIRRORED=0146 MIRRORED=0
146147
@@ -512,27 +513,47 @@
512retrieve_virtualization_image() {513retrieve_virtualization_image() {
513 echo514 echo
514 echo "***************************************************************************"515 echo "***************************************************************************"
515 echo "* An Ubuntu cloud image is required for virtualization tests. Having such an"516 echo "* An Ubuntu cloud image is required for virtualization tests. Having such"
516 echo "* image on your MAAS server can be convenient, but downloading it can take"517 echo "* an image on your MAAS server can be convenient, but downloading it can"
517 echo "* a while (it's about 250MiB)."518 echo "* take a while (each image is about 250MiB). This process will import cloud"
518 echo "*"519 echo "* images for each supported architecture for the selected release"
519 if [ -f /srv/$CLOUD_IMAGE ] ; then520 echo "*"
520 echo "* A cloud image file already exists at /srv/$CLOUD_IMAGE;"521 if [ -d $CLOUD_MIRROR ] ; then
521 echo "* skipping download."522 echo "* A mirror of cloud images seems to already exists at /srv/cloud;"
523 get_yn "* Do you wish to continue?" "N"
524 if [ $YN = "N" ]; then
525 echo "Skipping."
526 return
527 fi
528 fi
529 echo "* To defer this task, respond 'N' to the following question."
530 echo "*"
531 get_yn "* Do you want to set up a local cloud image mirror for the virtualization tests" "Y"
532 if [ $YN = "Y" ] ; then
533 if [ ! -d $CLOUD_MIRROR ] ; then
534 echo "* Cloud Mirror does not exist. Creating."
535 mkdir -p $CLOUD_MIRROR
536 ln -sf $CLOUD_MIRROR /var/www/html
537 fi
538 for release in $CLOUD_RELEASES; do
539 get_yn "* Do you want to get images for $release?" "Y"
540 if [ $YN = "Y" ]; then
541 get_these="$get_these $release"
542 fi
543 done
544 echo "* Downloading cloud images. This may take some time."
545 for release in $get_these; do
546 wget --mirror -r -nH --adjust-extension --no-parent -P $CLOUD_MIRROR \
547 --convert-links http://cloud-images.ubuntu.com/$release/current/
548 done
549 echo "*"
550 echo "* Virtualization image mirror is stored as $CLOUD_MIRROR"
551 echo "* and is available at http://$INTERNAL_IP/cloud/"
522 else552 else
523 echo "* To defer this task, respond 'N' to the following question."553 echo "*"
524 echo "*"554 echo "* You can download virtualization images later by running this script with"
525 get_yn "* Do you want to copy a cloud image for the virtualization tests" "Y"555 echo "* the --download-virtualization-images (or -d) option."
526 if [ $YN = "Y" ] ; then556 echo "*"
527 wget -P /srv http://cloud-images.ubuntu.com/trusty/current/$CLOUD_IMAGE
528 echo "*"
529 echo "* Virtualization image is stored as /srv/$CLOUD_IMAGE"
530 else
531 echo "*"
532 echo "* You can download a virtualization image later by running this script with"
533 echo "* the --download-virtualization-image (or -d) option."
534 echo "*"
535 fi
536 fi557 fi
537}558}
538559
@@ -1003,8 +1024,8 @@
1003 echo "* You can set up a local mirror later by running this script with the"1024 echo "* You can set up a local mirror later by running this script with the"
1004 echo "* --mirror-archives (or -m) option."1025 echo "* --mirror-archives (or -m) option."
1005 echo "*"1026 echo "*"
1006 echo "* You can download a virtualization image later by running this script with"1027 echo "* You can download virtualization images later by running this script with"
1007 echo "* the --download-virtualization-image (or -d) option."1028 echo "* the --download-virtualization-images (or -d) option."
1008 echo "*"1029 echo "*"
1009 echo "* You can import boot resources via the MAAS web UI or by re-running this"1030 echo "* You can import boot resources via the MAAS web UI or by re-running this"
1010 echo "* script with the --import-boot-resources (or -i) option."1031 echo "* script with the --import-boot-resources (or -i) option."

Subscribers

People subscribed via source and target branches

to status/vote changes: