Merge lp:~jtv/maas/bug-1050033 into lp:~maas-committers/maas/trunk

Proposed by Jeroen T. Vermeulen
Status: Merged
Approved by: Jeroen T. Vermeulen
Approved revision: no longer in the source branch.
Merged at revision: 1236
Proposed branch: lp:~jtv/maas/bug-1050033
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 47 lines (+25/-5)
1 file modified
scripts/maas-import-ephemerals (+25/-5)
To merge this branch: bzr merge lp:~jtv/maas/bug-1050033
Reviewer Review Type Date Requested Status
Julian Edwards (community) Approve
Review via email: mp+128685@code.launchpad.net

Commit message

Fix “cp: cannot stat” errors in maas-import-ephemerals (as run by maas-import-pxe-files) after upgrade from Precise to Quantal.

Description of the change

The cause of the problem was that maas-import-ephemerals will install boot images from its iSCSI directories, but some of the pre-quantal boot images may have files “kernel” and “initrd,” which nowadays we call “linux” and “initrd.gz” respectively.

You may wonder why I'm blithely renaming initrd to initrd.gz, instead of compressing it. That's because behind the scenes, initrd is already a gzipped file.

Jeroen

To post a comment you must log in.
Revision history for this message
Julian Edwards (julian-edwards) wrote :

Approved if you make $2 and $3 $1 and $2 respectively, and $3 becomes $1 for the more "traditional" ordering :)

review: Approve
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

Done.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'scripts/maas-import-ephemerals'
2--- scripts/maas-import-ephemerals 2012-10-02 16:59:29 +0000
3+++ scripts/maas-import-ephemerals 2012-10-09 11:42:33 +0000
4@@ -269,6 +269,27 @@
5 }
6
7
8+copy_first_available() {
9+ # Copy file $1 or $2 (the first that is available) to destination $3.
10+ local preferred_file="$1" alternate_file="$2" destination="$3"
11+ local actual=""
12+
13+ if [ -f "${preferred_file}" ]; then
14+ actual="${preferred_file}"
15+ elif [ -f "${alternate_file}" ]; then
16+ actual="${alternate_file}"
17+ else
18+ error "Could not copy to ${destination}."
19+ error "Neither ${preferred_file} nor ${alternate_file} exists."
20+ return 1
21+ fi
22+
23+ cp -- "${actual}" "${destination}" ||
24+ { error "Could not copy ${actual} to ${destination}."; return 1; }
25+ return 0
26+}
27+
28+
29 install_tftp_image() {
30 # Make image in directory $1, for architecture $2 and subarchitecture $3,
31 # and OS release $4, available over TFTP for netbooting nodes. Only the
32@@ -280,11 +301,10 @@
33 # deletes it.
34 tmpdir="$(mktemp -d)"
35
36- for filename in linux initrd.gz
37- do
38- cp -- "$src/$filename" "$tmpdir/" ||
39- { error "cp of $filename from $src failed"; return 1; }
40- done
41+ copy_first_available "$src/linux" "$src/kernel" "$tmpdir/linux" ||
42+ return 1
43+ copy_first_available "$src/initrd.gz" "$src/initrd" "$tmpdir/initrd.gz" ||
44+ return 1
45
46 local cmd out=""
47 cmd=( maas-provision install-pxe-image