Merge lp:~gandelman-a/charms/precise/glance/trunk into lp:~charmers/charms/precise/glance/trunk

Proposed by Adam Gandelman
Status: Merged
Merge reported by: Adam Gandelman
Merged at revision: not available
Proposed branch: lp:~gandelman-a/charms/precise/glance/trunk
Merge into: lp:~charmers/charms/precise/glance/trunk
Diff against target: 200 lines (+84/-13)
6 files modified
config.yaml (+1/-1)
glance.yaml (+0/-6)
hooks/glance-common (+40/-3)
hooks/glance-relations (+40/-2)
metadata.yaml (+2/-0)
revision (+1/-1)
To merge this branch: bzr merge lp:~gandelman-a/charms/precise/glance/trunk
Reviewer Review Type Date Requested Status
charmers Pending
Review via email: mp+86847@code.launchpad.net

Description of the change

Adds relations to keystone and support for passing custom PPAs to config 'glance-release' (in addition to distro, (upstream) milestone/trunk/milestone-propsed)

To post a comment you must log in.
13. By Adam Gandelman

Merge lp:~gandelman-a/charm/precise/glance/trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config.yaml'
2--- config.yaml 2011-09-16 17:34:31 +0000
3+++ config.yaml 2011-12-24 02:19:24 +0000
4@@ -2,7 +2,7 @@
5 glance-release:
6 default: distro
7 type: string
8- description: Glance PPA from which to install. (distro, trunk, milestone, milestone-proposed)
9+ description: Glance PPA from which to install. (distro, trunk, milestone, milestone-proposed or ppa:somewhere/else)
10 api-config:
11 default: /etc/glance/glance-api.conf
12 type: string
13
14=== added file 'glance.yaml'
15--- glance.yaml 1970-01-01 00:00:00 +0000
16+++ glance.yaml 2011-12-24 02:19:24 +0000
17@@ -0,0 +1,6 @@
18+glance:
19+ glance-release: trunk
20+ registry-config: /etc/glance/glance-registry.conf
21+ api-config: /etc/glance/glance-api.conf
22+ db-user: glance
23+ nova-db: nova
24
25=== removed file 'glance.yaml'
26--- glance.yaml 2011-08-23 21:08:17 +0000
27+++ glance.yaml 1970-01-01 00:00:00 +0000
28@@ -1,6 +0,0 @@
29-glance:
30- glance-release: trunk
31- registry-config: /etc/glance/glance-registry.conf
32- api-config: /etc/glance/glance-api.conf
33- db-user: glance
34- nova-db: nova
35
36=== modified file 'hooks/glance-common'
37--- hooks/glance-common 2011-12-02 23:33:07 +0000
38+++ hooks/glance-common 2011-12-24 02:19:24 +0000
39@@ -1,6 +1,8 @@
40 #!/bin/bash
41
42 SERVICES="glance-api glance-registry"
43+PACKAGES="glance python-mysqldb python-swift python-keystone"
44+
45 GLANCE_REGISTRY_CONF=$(config-get registry-config)
46 GLANCE_API_CONF=$(config-get api-config)
47
48@@ -47,6 +49,27 @@
49 done
50 }
51
52+function update_pipeline {
53+ # updates pipeline middleware definitions in api-paste.ini
54+ local pipeline="$1"
55+ local new="$2"
56+ local config="$3"
57+
58+ case $config in
59+ "api") local api_conf=$GLANCE_API_CONF ;;
60+ "registry") local api_conf=$GLANCE_REGISTRY_CONF ;;
61+ *) juju-log "ERROR: update_pipeline: invalid config=$config" && exit 1 ;;
62+ esac
63+
64+ local tag="\[pipeline:$pipeline\]"
65+ if ! grep -q "$tag" $api_conf ; then
66+ juju-log "ERROR: update_pipeline: pipeline not found: $pipeline"
67+ return 1
68+ fi
69+ juju-log "Updating pipeline:$pipeline in $api_conf"
70+ sed -i "/$tag/, +1 s/\(pipeline = \).*/\1$new/g" $api_conf
71+}
72+
73 function set_or_update {
74 # This handles configuration of both api and registry server
75 # until LP #806241 is resolved. Until then, $3 is either
76@@ -56,6 +79,8 @@
77 VALUE=$2
78 [[ $3 == "api" ]] && CONF=$GLANCE_API_CONF
79 [[ $3 == "registry" ]] && CONF=$GLANCE_REGISTRY_CONF
80+ [[ -z $CONF ]] && juju-log "ERROR: set_or_update: No config file specified" &&
81+ exit 1
82 [[ -z $KEY ]] && exit 1
83 [[ -z $VALUE ]] && exit 1
84 cat $CONF | grep "$KEY = $VALUE" >/dev/null \
85@@ -71,8 +96,20 @@
86 # Install from archive instead of PPA.
87 [[ $PPA == "distro" ]] && return 0
88 . /etc/lsb-release
89- juju-log "glance: Setting up PPA for $PPA"
90 [[ -z $PPA ]] && return 0
91- PPA_URL="deb http://ppa.launchpad.net/nova-core/$PPA/ubuntu $DISTRIB_CODENAME main"
92- add-apt-repository "$PPA_URL" || exit 1
93+ # if referenced by name, setup ppa to upstream PPAs
94+ if [[ "$PPA" == "trunk" ]] ||
95+ [[ "$PPA" == "milestone" ]] ||
96+ [[ "$PPA" == "milestone-proposed" ]] ; then
97+ juju-log "glance: Configuring installation from upstream PPA ($PPA)"
98+ PPA_URL="deb http://ppa.launchpad.net/glance-core/$PPA/ubuntu $DISTRIB_CODENAME main"
99+ add-apt-repository "$PPA_URL" || exit 1
100+ return
101+ fi
102+ if [[ "${PPA:0:4}" == "ppa:" ]] ; then
103+ juju-log "glance: Configuring installation from custom PPA ($PPA)"
104+ add-apt-repository -y "$PPA" || exit 1
105+ return
106+ fi
107+ juju-log "glance: No PPA specified. Falling back to installation from Ubuntu archive."
108 }
109
110=== modified file 'hooks/glance-relations'
111--- hooks/glance-relations 2011-12-02 23:33:07 +0000
112+++ hooks/glance-relations 2011-12-24 02:19:24 +0000
113@@ -10,13 +10,13 @@
114 fi
115
116 function install_hook {
117- juju-log "Installing nova packages"
118+ juju-log "Installing glance packages"
119 apt-get -y install python-software-properties || exit 1
120
121 add_ppa
122
123 apt-get update || exit 1
124- apt-get -y install glance python-mysqldb python-swift || exit 1
125+ apt-get -y install $PACKAGES || exit 1
126
127 glance_ctl all stop
128
129@@ -77,6 +77,42 @@
130 glance_ctl glance-api restart
131 }
132
133+function keystone_joined {
134+ # advertise our API endpoint to keystone
135+ url="http://$(unit-get private-address):9292/v1.1/"
136+ relation-set service="glance" \
137+ region="RegionOne" public_url=$url admin_url=$url internal_url=$url
138+}
139+
140+function keystone_changed {
141+ # we hopefully get a token in return. configure middleware accordingly
142+ token=$(relation-get admin_token)
143+ service_port=$(relation-get service_port)
144+ auth_port=$(relation-get auth_port)
145+ [[ -z "$token" ]] || [[ -z "$service_port" ]] || [[ -z "$auth_port" ]] &&
146+ juju-log "keystone_changed: Peer not ready" && exit 0
147+ [[ "$token" == "-1" ]] &&
148+ juju-log "keystone_changed: admin token error" && exit 1
149+ juju-log "keystone_changed: Acquired admin. token"
150+ keystone_host=`dig +short +search $(relation-get private-address)`
151+
152+ # update the pipeline settings in both configs
153+ update_pipeline "glance-api" \
154+ "versionnegotiation authtoken auth-context apiv1app" "api"
155+ update_pipeline "glance-registry" \
156+ "authtoken auth-context registryapp" "registry"
157+
158+ for i in api registry ; do
159+ set_or_update "service_host" "$keystone_host" $i
160+ set_or_update "service_port" "$service_port" $i
161+ set_or_update "auth_host" "$keystone_host" $i
162+ set_or_update "auth_port" "$auth_port" $i
163+ set_or_update "auth_uri" "http://$keystone_host:$service_port/" $i
164+ set_or_update "admin_token" "$token" $i
165+ done
166+ glance_ctl all restart
167+}
168+
169 case $ARG0 in
170 "start"|"stop") glance_ctl all $ARG0 ;;
171 "install") install_hook ;;
172@@ -86,5 +122,7 @@
173 "image-service-relation-changed") exit 0 ;;
174 "object-store-relation-joined") exit 0 ;;
175 "object-store-relation-changed") object-store_changed ;;
176+ "identity-service-relation-joined") keystone_joined ;;
177+ "identity-service-relation-changed") keystone_changed ;;
178 esac
179
180
181=== added symlink 'hooks/identity-service-relation-changed'
182=== target is u'glance-relations'
183=== added symlink 'hooks/identity-service-relation-joined'
184=== target is u'glance-relations'
185=== modified file 'metadata.yaml'
186--- metadata.yaml 2011-10-12 05:46:10 +0000
187+++ metadata.yaml 2011-12-24 02:19:24 +0000
188@@ -14,3 +14,5 @@
189 interface: mysql-shared
190 object-store:
191 interface: swift
192+ identity-service:
193+ interface: keystone
194
195=== modified file 'revision'
196--- revision 2011-10-12 05:46:10 +0000
197+++ revision 2011-12-24 02:19:24 +0000
198@@ -1,1 +1,1 @@
199-31
200+47

Subscribers

People subscribed via source and target branches