Merge lp:~gandelman-a/charms/precise/swift-storage/upgrade into lp:~openstack-charmers/charms/precise/swift-storage/ha-support

Proposed by Adam Gandelman
Status: Merged
Merged at revision: 28
Proposed branch: lp:~gandelman-a/charms/precise/swift-storage/upgrade
Merge into: lp:~openstack-charmers/charms/precise/swift-storage/ha-support
Diff against target: 119 lines (+54/-11)
4 files modified
hooks/lib/openstack-common (+19/-8)
hooks/swift-storage-node-common (+21/-0)
hooks/swift-storage-node-relations (+13/-2)
revision (+1/-1)
To merge this branch: bzr merge lp:~gandelman-a/charms/precise/swift-storage/upgrade
Reviewer Review Type Date Requested Status
James Page Approve
Review via email: mp+165256@code.launchpad.net
To post a comment you must log in.
Revision history for this message
James Page (james-page) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/lib/openstack-common'
2--- hooks/lib/openstack-common 2013-04-26 21:48:49 +0000
3+++ hooks/lib/openstack-common 2013-05-22 21:51:25 +0000
4@@ -190,15 +190,26 @@
5 }
6
7 get_os_codename_package() {
8- local pkg_vers=$(dpkg -l | grep "$1" | awk '{ print $3 }') || echo "none"
9+ local pkg_vers=$(dpkg -l | grep " $1 " | awk '{ print $3 }') || echo "none"
10 pkg_vers=$(echo $pkg_vers | cut -d: -f2) # epochs
11- case "${pkg_vers:0:6}" in
12- "2011.2") echo "diablo" ;;
13- "2012.1") echo "essex" ;;
14- "2012.2") echo "folsom" ;;
15- "2013.1") echo "grizzly" ;;
16- "2013.2") echo "havana" ;;
17- esac
18+ if echo "$1" | grep -q swift ; then
19+ case "${pkg_vers:0:5}" in
20+ "1.4.3") echo "diablo" ;;
21+ "1.4.8") echo "essex" ;;
22+ "1.7.4") echo "folsom" ;;
23+ "1.7.6") echo "grizzly" ;;
24+ "1.7.7") echo "grizzly" ;;
25+ "1.8.0") echo "grizzly" ;;
26+ esac
27+ else
28+ case "${pkg_vers:0:6}" in
29+ "2011.2") echo "diablo" ;;
30+ "2012.1") echo "essex" ;;
31+ "2012.2") echo "folsom" ;;
32+ "2013.1") echo "grizzly" ;;
33+ "2013.2") echo "havana" ;;
34+ esac
35+ fi
36 }
37
38 get_os_version_codename() {
39
40=== modified file 'hooks/swift-storage-node-common'
41--- hooks/swift-storage-node-common 2013-04-25 19:43:44 +0000
42+++ hooks/swift-storage-node-common 2013-05-22 21:51:25 +0000
43@@ -4,6 +4,8 @@
44 CHARM="swift-storage"
45 HOOKS_DIR="$CHARM_DIR/hooks"
46
47+CONF_DIR="/etc/swift"
48+
49 if [[ -e "$HOOKS_DIR/lib/openstack-common" ]] ; then
50 . $HOOKS_DIR/lib/openstack-common
51 else
52@@ -130,3 +132,22 @@
53 done
54 chown -R swift:swift /srv/node
55 }
56+
57+function do_openstack_upgrade {
58+ # update openstack components to those provided by a new installation source
59+ # it is assumed the calling hook has confirmed that the upgrade is sane.
60+ local rel="$1"
61+ shift
62+ local packages=$@
63+
64+ # Backup the config directory.
65+ local stamp=$(date +"%Y%m%d%M%S")
66+ tar -pcf /var/lib/juju/$CHARM-backup-$stamp.tar $CONF_DIR
67+
68+ configure_install_source "$rel"
69+ apt-get update
70+ DEBIAN_FRONTEND=noninteractive apt-get \
71+ --option Dpkg::Options::=--force-confnew -y \
72+ install --no-install-recommends $packages
73+ swift-init all restart || true
74+}
75
76=== modified file 'hooks/swift-storage-node-relations'
77--- hooks/swift-storage-node-relations 2013-04-25 19:43:44 +0000
78+++ hooks/swift-storage-node-relations 2013-05-22 21:51:25 +0000
79@@ -12,7 +12,17 @@
80 fi
81
82 function config_changed {
83-
84+ # perform openstack upgrade if openstack-origin has been bumped.
85+ local install_src=$(config-get openstack-origin)
86+ local cur=$(get_os_codename_package "python-swift")
87+ local available=$(get_os_codename_install_source "$install_src")
88+ if [[ "$available" != "unknown" ]] ; then
89+ if dpkg --compare-versions $(get_os_version_codename "$cur") lt \
90+ $(get_os_version_codename "$available") ; then
91+ juju-log "$CHARM: Upgrading OpenStack release: $cur -> $available."
92+ do_openstack_upgrade "$install_src" $PACKAGES
93+ fi
94+ fi
95 declare -a env_vars=()
96 for i in account container object ; do
97 port=$(config-get ${i}-server-port)
98@@ -29,7 +39,7 @@
99
100 # Save our scriptrc env variables for health checks
101 save_script_rc ${env_vars[@]}
102-}
103+}
104
105 function install_hook {
106 apt-get -y --force-yes install python-software-properties || exit 1
107@@ -89,4 +99,5 @@
108 "config-changed") config_changed ;;
109 "swift-storage-relation-joined") storage_joined ;;
110 "swift-storage-relation-changed") storage_changed ;;
111+ "config-changed") config_changed ;;
112 esac
113
114=== modified file 'revision'
115--- revision 2013-04-26 21:10:59 +0000
116+++ revision 2013-05-22 21:51:25 +0000
117@@ -1,1 +1,1 @@
118-58
119+59

Subscribers

People subscribed via source and target branches