Merge lp:~gandelman-a/ubuntu/precise/cobbler/lp900977 into lp:ubuntu/precise/cobbler

Proposed by Adam Gandelman
Status: Merged
Merged at revision: 57
Proposed branch: lp:~gandelman-a/ubuntu/precise/cobbler/lp900977
Merge into: lp:ubuntu/precise/cobbler
Diff against target: 74 lines (+32/-23)
2 files modified
debian/changelog (+8/-0)
debian/cobbler-ubuntu-import (+24/-23)
To merge this branch: bzr merge lp:~gandelman-a/ubuntu/precise/cobbler/lp900977
Reviewer Review Type Date Requested Status
Ubuntu branches Pending
Review via email: mp+84698@code.launchpad.net

Description of the change

This changes the reassign_distro() function to preserve *all* profiles associated with a distro, instead of preserving only the profile with a matching name.

Previously, when importing a new 'precise-i386' distro, only the profile named 'precise-i386' and any child profiles of the 'precise-i386' were preserved. With this change, 'cobbler profile --find=$distro' is used to find all descendant profiles and reassign accordingly to ensure they are preserved across updates.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2011-11-24 14:00:01 +0000
3+++ debian/changelog 2011-12-07 00:33:28 +0000
4@@ -1,3 +1,11 @@
5+cobbler (2.2.2-0ubuntu7) precise; urgency=low
6+
7+ * debian/cobbler-ubuntu-import: On distro import, also reassign *all*
8+ descendent profiles not just Orchestra-specific profiles (ie, $rel-$arch).
9+ Preserves user-added profiles associated with updated distros (LP: #900977)
10+
11+ -- Adam Gandelman <adamg@canonical.com> Tue, 06 Dec 2011 16:18:21 -0800
12+
13 cobbler (2.2.2-0ubuntu6) precise; urgency=low
14
15 * Fix typo in cobbler-common.install which caused the gpxe template to be
16
17=== modified file 'debian/cobbler-ubuntu-import'
18--- debian/cobbler-ubuntu-import 2011-11-22 15:36:38 +0000
19+++ debian/cobbler-ubuntu-import 2011-12-07 00:33:28 +0000
20@@ -91,30 +91,31 @@
21 }
22
23 reassign_distro() {
24- # swap out backing distro of profile with a newer, imported
25- # distro. after, remove the original and rename the new distro
26- # to match the previous distro name associated with profile
27+ # expected to be called after get_iso() has imported a more up to date iso under
28+ # a temporary name. this will reassign all profiles associated with $old_distro
29+ # with $new_distro. after all profiles have been reassigned, $old_distro is
30+ # removed.
31 local new_distro="$1"
32- local profile="$2"
33- debug "Reassigning $profile to $new_distro"
34- if ! cobbler profile list | grep -qs " $profile"; then
35- fail "cannot reassign non-existent profile '$profile'"
36- fi
37- if ! cobbler distro list | grep -qs " $profile"; then
38- fail "distro matching profile '$profile' does not exist"
39- fi
40- debug "Renaming old profile '$profile' to 'last-$profile'"
41- cobbler distro rename --name="$profile" --newname="last-$profile" ||
42- fail "could not rename distro '$profile' to 'last-$profile'"
43- debug "Assigning profile $profile to distro $new_distro"
44- cobbler profile edit --name="$profile" --distro="$new_distro" ||
45- fail "could not assign profile '$profile' to distro '$new_distro'"
46- debug "Removing distro last-$profile"
47- cobbler distro remove --name="last-$profile" ||
48- fail "could not remove stale distro 'last-$profile'"
49- debug "Renaming distro $new_distro to $profile"
50- cobbler distro rename --name="$new_distro" --newname="$profile" ||
51- fail "could not rename distro '$new_distro' to '$profile'"
52+ local old_distro="$2"
53+ descendants=`cobbler profile find --distro="$old_distro"`
54+ debug "Reassigning $old_distro to $new_distro"
55+ if ! cobbler distro list | grep -qs " $old_distro"; then
56+ fail "distro matching profile '$old_distro' does not exist"
57+ fi
58+ debug "Renaming old distro '$old_distro' to 'last-$old_distro'"
59+ cobbler distro rename --name="$old_distro" --newname="last-$old_distro" ||
60+ fail "could not rename distro '$old_distro' to 'last-$old_distro'"
61+ for profile in $descendants ; do
62+ debug "Assigning profile $profile to distro $new_distro"
63+ cobbler profile edit --name="$profile" --distro="$new_distro" ||
64+ fail "could not assign profile '$profile' to distro '$new_distro'"
65+ done
66+ debug "Removing distro last-$old_distro"
67+ cobbler distro remove --name="last-$old_distro" ||
68+ fail "could not remove stale distro 'last-$old_distro'"
69+ debug "Renaming distro $new_distro to $old_distro"
70+ cobbler distro rename --name="$new_distro" --newname="$old_distro" ||
71+ fail "could not rename distro '$new_distro' to '$old_distro'"
72 debug "Cleaning up temporary profile '$new_distro'"
73 cobbler profile remove --name="$new_distro" ||
74 fail "could not remove temp profile '$new_distro'"

Subscribers

People subscribed via source and target branches