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
=== modified file 'scripts/maas-import-ephemerals'
--- scripts/maas-import-ephemerals 2012-10-02 16:59:29 +0000
+++ scripts/maas-import-ephemerals 2012-10-09 11:42:33 +0000
@@ -269,6 +269,27 @@
269}269}
270270
271271
272copy_first_available() {
273 # Copy file $1 or $2 (the first that is available) to destination $3.
274 local preferred_file="$1" alternate_file="$2" destination="$3"
275 local actual=""
276
277 if [ -f "${preferred_file}" ]; then
278 actual="${preferred_file}"
279 elif [ -f "${alternate_file}" ]; then
280 actual="${alternate_file}"
281 else
282 error "Could not copy to ${destination}."
283 error "Neither ${preferred_file} nor ${alternate_file} exists."
284 return 1
285 fi
286
287 cp -- "${actual}" "${destination}" ||
288 { error "Could not copy ${actual} to ${destination}."; return 1; }
289 return 0
290}
291
292
272install_tftp_image() {293install_tftp_image() {
273 # Make image in directory $1, for architecture $2 and subarchitecture $3,294 # Make image in directory $1, for architecture $2 and subarchitecture $3,
274 # and OS release $4, available over TFTP for netbooting nodes. Only the295 # and OS release $4, available over TFTP for netbooting nodes. Only the
@@ -280,11 +301,10 @@
280 # deletes it.301 # deletes it.
281 tmpdir="$(mktemp -d)"302 tmpdir="$(mktemp -d)"
282303
283 for filename in linux initrd.gz304 copy_first_available "$src/linux" "$src/kernel" "$tmpdir/linux" ||
284 do305 return 1
285 cp -- "$src/$filename" "$tmpdir/" ||306 copy_first_available "$src/initrd.gz" "$src/initrd" "$tmpdir/initrd.gz" ||
286 { error "cp of $filename from $src failed"; return 1; }307 return 1
287 done
288308
289 local cmd out=""309 local cmd out=""
290 cmd=( maas-provision install-pxe-image310 cmd=( maas-provision install-pxe-image