Merge lp:~gandelman-a/ubuntu/oneiric/cobbler/lp850892 into lp:ubuntu/oneiric/cobbler

Proposed by Adam Gandelman
Status: Merged
Merged at revision: 48
Proposed branch: lp:~gandelman-a/ubuntu/oneiric/cobbler/lp850892
Merge into: lp:ubuntu/oneiric/cobbler
Diff against target: 98 lines (+46/-7)
2 files modified
debian/changelog (+8/-0)
debian/cobbler-ubuntu-import (+38/-7)
To merge this branch: bzr merge lp:~gandelman-a/ubuntu/oneiric/cobbler/lp850892
Reviewer Review Type Date Requested Status
Ubuntu branches Pending
Review via email: mp+75650@code.launchpad.net

Description of the change

Adds some functionality to be used by orchestra-import-isos to keep local ISOs in sync and up-to-date with what is on the mirror.

--update-check: Compares the md5 checksum of the local ISO with what is on the mirror, as reported in the corresponding server-side MD5SUMS file (ie, http://archive.ubuntu.com/ubuntu/dists/oneiric/main/installer-amd64/current/images/MD5SUMS). Returns true if checksums differ, or if the local ISO does not exist (it will be downloaded by orchestra-import-isos later)

--remove: If they exist, removes the ISO and/or corresponding cobbler profile from the server in preparation of a resync. Removing the profile is necessary as cobbler will not re-import the ISO if the profile name already exists and does not offer the ability to update a profile/

For a look at how it can be used on the Orchestra side, see: lp:~gandelman-a/ubuntu/oneiric/orchestra/lp850892 Remove

To post a comment you must log in.
Revision history for this message
Scott Moser (smoser) wrote :

Overall this looks good. Some minor nit picks:
 - if (cobbler distro list | grep -qs " $rel-$arch"); then
   you dont' need a subshell there. Ie, no reason for the "()"

 - md5sum_local=`md5sum $ISO_DIR/$iso | awk '{ print $1 }'`
   does not check for failure. maybe try:
    md5sum_local=$(md5sum "$ISO_DIR/$iso") && md5sum_local="${md5sum_local% *}" && [ -n "${md5sum_local}" || fail "failed to checksum"

 - md5sum_remote=`cat $TEMP_D/MD5SUMS | grep '\./netboot/mini.iso' | awk '{ print $1 }'`
   that is a "pointless use of cat"
   try:
   md5sum_remote=$(awk '$2 == "./netboot/mini.iso" { print $1 }) && [ -n "$md5sum_remote" ] || fail "failed to get remote sum"

- probably should exit with a known exit value if "out of date" ratehr than just using "fail"
  100 + [ $md5sum_local != $md5sum_remote ] && exit 0
  101 + error "$ISO_DIR/$iso up to date."
  102 + exit 3

- did you think about trying to fix bug 850880 also ?
  I like the use of the MD5SUMS file, that might help us. I'd say you can just check the -updates first, and if its not there, try the release pocket.

49. By Adam Gandelman

Shell cleanup as per smoser's comments

50. By Adam Gandelman

Whitepace cleanup

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2011-09-08 13:01:55 +0000
+++ debian/changelog 2011-09-16 05:15:32 +0000
@@ -1,3 +1,11 @@
1cobbler (2.1.0+git20110602-0ubuntu26) UNRELEASED; urgency=low
2
3 * debian/cobbler-ubuntu-import: Add --check-update and --remove
4 functionality. This should help orchestra-import-isos keep local
5 ISO caches up-to-date. (LP: #850892)
6
7 -- Adam Gandelman <adamg@canonical.com> Thu, 15 Sep 2011 16:36:39 -0700
8
1cobbler (2.1.0+git20110602-0ubuntu25) oneiric; urgency=low9cobbler (2.1.0+git20110602-0ubuntu25) oneiric; urgency=low
210
3 * debian/cobbler-common.install: Install missing pxeprofile_arm.template11 * debian/cobbler-common.install: Install missing pxeprofile_arm.template
412
=== modified file 'debian/cobbler-ubuntu-import'
--- debian/cobbler-ubuntu-import 2011-08-11 13:02:11 +0000
+++ debian/cobbler-ubuntu-import 2011-09-16 05:15:32 +0000
@@ -18,11 +18,14 @@
18 import distro and profile for Ubuntu release-arch18 import distro and profile for Ubuntu release-arch
1919
20 options:20 options:
21 -D | --delete-iso delete the mini iso after downloading. Normally21 -D | --delete-iso delete the mini iso after downloading. Normally
22 they are kept in $ISO_DIR22 they are kept in $ISO_DIR
23 -m | --mirror M use mirror rather than default for downloading iso23 -m | --mirror M use mirror rather than default for downloading iso
24 default: ${DEFAULT_MIRROR}24 default: ${DEFAULT_MIRROR}
2525 -c | --update-check check saved ISOs against what is published on the
26 mirror. exits 0 if an update is needed or iso does
27 not exist in $ISO_DIR
28 -r | --remove remove cobbler profile/distro and cached ISO
26 Note, arch can be i386, x86_64, or amd64. However,29 Note, arch can be i386, x86_64, or amd64. However,
27 the registered distro and profile will use 'x86_64' rather than 'amd64'.30 the registered distro and profile will use 'x86_64' rather than 'amd64'.
28 This is to keep consistent with cobbler naming.31 This is to keep consistent with cobbler naming.
@@ -49,14 +52,16 @@
49 mount -o loop "$1" "$2"52 mount -o loop "$1" "$2"
50}53}
5154
52short_opts="Dhm:o:v"55short_opts="Dhm:o:vcr"
53long_opts="delete-iso,help,mirror:,verbose"56long_opts="delete-iso,help,mirror:,verbose,update-check,remove"
54getopt_out=$(getopt --name "${0##*/}" \57getopt_out=$(getopt --name "${0##*/}" \
55 --options "${short_opts}" --long "${long_opts}" -- "$@") &&58 --options "${short_opts}" --long "${long_opts}" -- "$@") &&
56 eval set -- "${getopt_out}" ||59 eval set -- "${getopt_out}" ||
57 bad_Usage60 bad_Usage
5861
59delete=false62delete=false
63check_update=false
64remove=false
60mirror=${DEFAULT_MIRROR}65mirror=${DEFAULT_MIRROR}
6166
62while [ $# -ne 0 ]; do67while [ $# -ne 0 ]; do
@@ -66,6 +71,8 @@
66 -m|--mirror) mirror=${2}; shift;;71 -m|--mirror) mirror=${2}; shift;;
67 -D|--delete-iso) delete=true;;72 -D|--delete-iso) delete=true;;
68 -v|--verbose) VERBOSITY=$((${VERBOSITY}+1));;73 -v|--verbose) VERBOSITY=$((${VERBOSITY}+1));;
74 -c|--update-check) check_update=true;;
75 -r|--remove) remove=true;;
69 --) shift; break;;76 --) shift; break;;
70 esac77 esac
71 shift;78 shift;
@@ -91,6 +98,30 @@
91 ubuntu_arch=$arch; [ "$arch" = "x86_64" ] && ubuntu_arch=amd6498 ubuntu_arch=$arch; [ "$arch" = "x86_64" ] && ubuntu_arch=amd64
92 iso=$rel-$arch-mini.iso99 iso=$rel-$arch-mini.iso
93 u=$mirror/dists/$rel/main/installer-$ubuntu_arch/current/images/netboot/mini.iso100 u=$mirror/dists/$rel/main/installer-$ubuntu_arch/current/images/netboot/mini.iso
101 md5=$mirror/dists/$rel/main/installer-$ubuntu_arch/current/images/MD5SUMS
102 if $remove; then
103 if [ -f "$ISO_DIR/$iso" ]; then
104 rm -rf "$ISO_DIR/$iso" ||
105 fail "Could not delete $ISO_DIR/$iso"
106 fi
107 if cobbler distro list | grep -qs " $rel-$arch"; then
108 cobbler distro remove --name=$rel-$arch ||
109 fail "Could not remove cobbler profile for $rel-$arch"
110 fi
111 exit 0
112 fi
113 if $check_update; then
114 # compare md5 of the local iso to whats on the mirror.
115 [ ! -f "$ISO_DIR/$iso" ] && exit 0
116 md5=$mirror/dists/$rel/main/installer-$ubuntu_arch/current/images/MD5SUMS
117 md5sum_local=$(md5sum "$ISO_DIR/$iso") && md5sum_local=${md5sum_local% *} \
118 && [ -n $md5sum_local ] || fail "failed to checksum $ISO_DIR/$iso"
119 wget -qO $TEMP_D/MD5SUMS $md5 || fail "failed to download MD5SUMS for $rel-$arch: $u"
120 md5sum_remote=$(awk '$2 == "./netboot/mini.iso" { print $1 }' $TEMP_D/MD5SUMS) &&
121 [ -n $md5sum_remote ] || fail "failed to parse checksum from $TEMP_D/MD5SUM"
122 [ $md5sum_local != $md5sum_remote ] && exit 0
123 error "$ISO_DIR/$iso up to date." && exit 3
124 fi
94 if [ ! -f "$ISO_DIR/$iso" ]; then125 if [ ! -f "$ISO_DIR/$iso" ]; then
95 wget -O "$TEMP_D/$iso" "$u" && [ -s "$TEMP_D/$iso" ] ||126 wget -O "$TEMP_D/$iso" "$u" && [ -s "$TEMP_D/$iso" ] ||
96 fail "failed download for $rel-$arch: $u"127 fail "failed download for $rel-$arch: $u"

Subscribers

People subscribed via source and target branches