51.1.2
by Adam Gandelman
Check in start of py redux. |
1 |
#!/usr/bin/python
|
2 |
||
51.1.20
by Adam Gandelman
Install quantum utility scripts. |
3 |
import os |
4 |
import shutil |
|
51.1.2
by Adam Gandelman
Check in start of py redux. |
5 |
import sys |
52.3.6
by Adam Gandelman
Send restart trigger to compute side after db migration. |
6 |
import uuid |
51.1.2
by Adam Gandelman
Check in start of py redux. |
7 |
|
8 |
from subprocess import check_call |
|
9 |
from urlparse import urlparse |
|
10 |
||
11 |
from charmhelpers.core.hookenv import ( |
|
12 |
Hooks, |
|
13 |
UnregisteredHookError, |
|
14 |
config, |
|
51.1.20
by Adam Gandelman
Install quantum utility scripts. |
15 |
charm_dir, |
68.3.2
by yolanda.robla at canonical
added postgresql support |
16 |
is_relation_made, |
51.1.2
by Adam Gandelman
Check in start of py redux. |
17 |
log, |
95.1.1
by Liam Young
In clustered mode check if node is in databases allowed_units list before doing db work |
18 |
local_unit, |
68.3.10
by yolanda.robla at canonical
raising generic exception |
19 |
ERROR, |
51.1.2
by Adam Gandelman
Check in start of py redux. |
20 |
relation_get, |
21 |
relation_ids, |
|
22 |
relation_set, |
|
75.4.4
by Louis Bouchard
Modify hook funcions & util to work in non-relation hooks |
23 |
related_units, |
51.1.2
by Adam Gandelman
Check in start of py redux. |
24 |
open_port, |
25 |
unit_get, |
|
26 |
)
|
|
27 |
||
28 |
from charmhelpers.core.host import ( |
|
75.3.1
by Liam Young
Add support for joining charm to standalone neutron-api service |
29 |
restart_on_change, |
30 |
service_running, |
|
31 |
service_stop, |
|
100.4.1
by Liam Young
Run db migrations for neutron |
32 |
service_restart, |
51.1.56
by James Page
Resync with rebased charm-helpers |
33 |
)
|
34 |
||
35 |
from charmhelpers.fetch import ( |
|
93.4.3
by Hui Xiang
Sync charm-helpers, support haproxy for IPv6. |
36 |
apt_install, |
37 |
apt_update, |
|
73.2.1
by james.page at ubuntu
Add options to allow configuration of worker processes |
38 |
filter_installed_packages
|
51.1.2
by Adam Gandelman
Check in start of py redux. |
39 |
)
|
40 |
||
41 |
from charmhelpers.contrib.openstack.utils import ( |
|
42 |
configure_installation_source, |
|
43 |
openstack_upgrade_available, |
|
100.5.1
by Liam Young
Don't run neutron db migrations pre-juno as neutron-server does it itself |
44 |
os_release, |
93.4.25
by Hui Xiang
sync_db_with_multi_ipv6_addresses |
45 |
sync_db_with_multi_ipv6_addresses
|
51.1.2
by Adam Gandelman
Check in start of py redux. |
46 |
)
|
47 |
||
51.1.10
by Adam Gandelman
Add neutron database config, better compat for supporting both names. Adds templates, fixes HAProxy context. |
48 |
from charmhelpers.contrib.openstack.neutron import ( |
51.1.9
by Adam Gandelman
Factor neutron stuff out to helpers. |
49 |
network_manager, |
50 |
neutron_plugin_attribute, |
|
51 |
)
|
|
52 |
||
75.3.5
by Liam Young
Pass through neutron settings from api server to compute host |
53 |
from nova_cc_context import ( |
54 |
NeutronAPIContext
|
|
83
by james.page at ubuntu
[caribou,r=james-page] Second part of multiline SSH key and authorized host passing to nova-compute |
55 |
)
|
75.3.5
by Liam Young
Pass through neutron settings from api server to compute host |
56 |
|
93.2.4
by Liam Young
Give peer-echo a go |
57 |
from charmhelpers.contrib.peerstorage import ( |
58 |
peer_retrieve, |
|
59 |
peer_echo, |
|
60 |
)
|
|
93.2.1
by Liam Young
Disable services on all nova-cc nodes until dbsync is complete |
61 |
|
51.1.2
by Adam Gandelman
Check in start of py redux. |
62 |
from nova_cc_utils import ( |
51.1.10
by Adam Gandelman
Add neutron database config, better compat for supporting both names. Adds templates, fixes HAProxy context. |
63 |
api_port, |
51.1.2
by Adam Gandelman
Check in start of py redux. |
64 |
auth_token_config, |
93.2.1
by Liam Young
Disable services on all nova-cc nodes until dbsync is complete |
65 |
cmd_all_services, |
51.1.2
by Adam Gandelman
Check in start of py redux. |
66 |
determine_endpoints, |
67 |
determine_packages, |
|
68 |
determine_ports, |
|
93.2.1
by Liam Young
Disable services on all nova-cc nodes until dbsync is complete |
69 |
disable_services, |
51.1.2
by Adam Gandelman
Check in start of py redux. |
70 |
do_openstack_upgrade, |
93.2.1
by Liam Young
Disable services on all nova-cc nodes until dbsync is complete |
71 |
enable_services, |
51.1.2
by Adam Gandelman
Check in start of py redux. |
72 |
keystone_ca_cert_b64, |
100.4.1
by Liam Young
Run db migrations for neutron |
73 |
migrate_neutron_database, |
74 |
migrate_nova_database, |
|
51.1.10
by Adam Gandelman
Add neutron database config, better compat for supporting both names. Adds templates, fixes HAProxy context. |
75 |
neutron_plugin, |
51.1.2
by Adam Gandelman
Check in start of py redux. |
76 |
save_script_rc, |
77 |
ssh_compute_add, |
|
51.2.1
by Adam Gandelman
Finish up SSH compute peers. |
78 |
ssh_compute_remove, |
73.1.2
by Louis Bouchard
Functional line by line modification, except for the 'nova' user. |
79 |
ssh_known_hosts_lines, |
80 |
ssh_authorized_keys_lines, |
|
51.1.2
by Adam Gandelman
Check in start of py redux. |
81 |
register_configs, |
82 |
restart_map, |
|
83 |
volume_service, |
|
84 |
CLUSTER_RES, |
|
51.1.67
by James Page
Uses constants in hooks |
85 |
NOVA_CONF, |
86 |
QUANTUM_CONF, |
|
87 |
NEUTRON_CONF, |
|
83.1.1
by james.page at ubuntu
Add basic service guard support to inhibit services from runnig until minimum relation requirements have been fulfilled |
88 |
QUANTUM_API_PASTE, |
82.1.2
by Liam Young
Minor bug fix |
89 |
console_attributes, |
83.1.1
by james.page at ubuntu
Add basic service guard support to inhibit services from runnig until minimum relation requirements have been fulfilled |
90 |
service_guard, |
91 |
guard_map, |
|
100.4.1
by Liam Young
Run db migrations for neutron |
92 |
services, |
93.4.28
by Hui Xiang
Refactor codes. |
93 |
setup_ipv6
|
51.1.2
by Adam Gandelman
Check in start of py redux. |
94 |
)
|
95 |
||
96 |
from charmhelpers.contrib.hahelpers.cluster import ( |
|
97 |
eligible_leader, |
|
98 |
get_hacluster_config, |
|
99 |
)
|
|
100 |
||
51.1.72
by James Page
Add preinstall execd hooks |
101 |
from charmhelpers.payload.execd import execd_preinstall |
81.3.11
by james.page at ubuntu
Switch to new canonical_url helper |
102 |
|
103 |
from charmhelpers.contrib.openstack.ip import ( |
|
104 |
canonical_url, |
|
105 |
PUBLIC, INTERNAL, ADMIN |
|
106 |
)
|
|
51.1.72
by James Page
Add preinstall execd hooks |
107 |
|
81.3.12
by james.page at ubuntu
Support multi-network vip configuration |
108 |
from charmhelpers.contrib.network.ip import ( |
109 |
get_iface_for_address, |
|
93.4.1
by Hui Xiang
Support nova-cloud-controller for IPv6. |
110 |
get_netmask_for_address, |
93.4.28
by Hui Xiang
Refactor codes. |
111 |
get_address_in_network, |
112 |
get_ipv6_addr, |
|
113 |
is_ipv6
|
|
81.3.12
by james.page at ubuntu
Support multi-network vip configuration |
114 |
)
|
115 |
||
100.7.9
by james.page at ubuntu
Resync helpers, deal with clustered HA + HTTPS |
116 |
from charmhelpers.contrib.openstack.context import ADDRESS_TYPES |
117 |
||
51.1.2
by Adam Gandelman
Check in start of py redux. |
118 |
hooks = Hooks() |
119 |
CONFIGS = register_configs() |
|
120 |
||
121 |
||
122 |
@hooks.hook() |
|
123 |
def install(): |
|
51.1.72
by James Page
Add preinstall execd hooks |
124 |
execd_preinstall() |
51.1.2
by Adam Gandelman
Check in start of py redux. |
125 |
configure_installation_source(config('openstack-origin')) |
126 |
apt_update() |
|
127 |
apt_install(determine_packages(), fatal=True) |
|
93.4.8
by Hui Xiang
Fix format errors. |
128 |
|
51.1.20
by Adam Gandelman
Install quantum utility scripts. |
129 |
_files = os.path.join(charm_dir(), 'files') |
130 |
if os.path.isdir(_files): |
|
131 |
for f in os.listdir(_files): |
|
132 |
f = os.path.join(_files, f) |
|
133 |
log('Installing %s to /usr/bin' % f) |
|
134 |
shutil.copy2(f, '/usr/bin') |
|
51.1.2
by Adam Gandelman
Check in start of py redux. |
135 |
[open_port(port) for port in determine_ports()] |
93.3.2
by Liam Young
Added additional logging and only use peer_* commands if the peer relation exists |
136 |
log('Disabling services into db relation joined') |
93.2.1
by Liam Young
Disable services on all nova-cc nodes until dbsync is complete |
137 |
disable_services() |
138 |
cmd_all_services('stop') |
|
51.1.2
by Adam Gandelman
Check in start of py redux. |
139 |
|
140 |
||
51.1.7
by Adam Gandelman
Register config-changed properly. |
141 |
@hooks.hook('config-changed') |
83.1.9
by james.page at ubuntu
Disable service-guard by default |
142 |
@service_guard(guard_map(), CONFIGS, |
143 |
active=config('service-guard')) |
|
62.1.3
by Ante Karamatic
Provide both restart and stop/start functionality |
144 |
@restart_on_change(restart_map(), stopstart=True) |
51.1.2
by Adam Gandelman
Check in start of py redux. |
145 |
def config_changed(): |
93.4.8
by Hui Xiang
Fix format errors. |
146 |
if config('prefer-ipv6'): |
147 |
setup_ipv6() |
|
93.4.26
by Edward Hope-Morley
more |
148 |
sync_db_with_multi_ipv6_addresses(config('database'), |
93.4.29
by Hui Xiang
Merge trunk, refactor codes. |
149 |
config('database-user'), |
93.4.30
by Edward Hope-Morley
synced charm-helpers |
150 |
relation_prefix='nova') |
93.4.8
by Hui Xiang
Fix format errors. |
151 |
|
56.3.39
by James Page
Rework upgrade approach for renaming/different plugins |
152 |
global CONFIGS |
51.1.2
by Adam Gandelman
Check in start of py redux. |
153 |
if openstack_upgrade_available('nova-common'): |
56.3.39
by James Page
Rework upgrade approach for renaming/different plugins |
154 |
CONFIGS = do_openstack_upgrade() |
100.4.1
by Liam Young
Run db migrations for neutron |
155 |
[neutron_api_relation_joined(rid=rid, remote_restart=True) |
156 |
for rid in relation_ids('neutron-api')] |
|
51.1.2
by Adam Gandelman
Check in start of py redux. |
157 |
save_script_rc() |
158 |
configure_https() |
|
51.2.3
by Adam Gandelman
Finish off quantum networking config. |
159 |
CONFIGS.write_all() |
82.1.9
by Liam Young
Install console packages in config changed incase the console protocol is changed. Fix relation set to pass ip/hostname rather than url for console_proxy_%s_host |
160 |
if console_attributes('protocol'): |
161 |
apt_update() |
|
162 |
apt_install(console_attributes('packages'), fatal=True) |
|
163 |
[compute_joined(rid=rid) |
|
164 |
for rid in relation_ids('cloud-compute')] |
|
81.3.2
by james.page at ubuntu
Add support for internal and public networks |
165 |
for r_id in relation_ids('identity-service'): |
81.3.13
by james.page at ubuntu
Tidy lint |
166 |
identity_joined(rid=r_id) |
100.7.8
by james.page at ubuntu
Add cluster-relation-joined hook to ensure that internal address network is used if connected |
167 |
[cluster_joined(rid) for rid in relation_ids('cluster')] |
51.1.2
by Adam Gandelman
Check in start of py redux. |
168 |
|
169 |
||
170 |
@hooks.hook('amqp-relation-joined') |
|
52.2.1
by James Page
Update rabbitmq configuration to use common vhost |
171 |
def amqp_joined(relation_id=None): |
172 |
relation_set(relation_id=relation_id, |
|
173 |
username=config('rabbit-user'), vhost=config('rabbit-vhost')) |
|
51.1.2
by Adam Gandelman
Check in start of py redux. |
174 |
|
175 |
||
176 |
@hooks.hook('amqp-relation-changed') |
|
58.3.1
by Ante Karamatic
Remove duplicated functions |
177 |
@hooks.hook('amqp-relation-departed') |
83.1.9
by james.page at ubuntu
Disable service-guard by default |
178 |
@service_guard(guard_map(), CONFIGS, |
179 |
active=config('service-guard')) |
|
51.1.2
by Adam Gandelman
Check in start of py redux. |
180 |
@restart_on_change(restart_map()) |
181 |
def amqp_changed(): |
|
182 |
if 'amqp' not in CONFIGS.complete_contexts(): |
|
183 |
log('amqp relation incomplete. Peer not ready?') |
|
184 |
return
|
|
51.1.67
by James Page
Uses constants in hooks |
185 |
CONFIGS.write(NOVA_CONF) |
75.3.2
by Liam Young
Don't write {neutron,quantum} files if standalone neutron-api is present |
186 |
if not is_relation_made('neutron-api'): |
187 |
if network_manager() == 'quantum': |
|
188 |
CONFIGS.write(QUANTUM_CONF) |
|
189 |
if network_manager() == 'neutron': |
|
190 |
CONFIGS.write(NEUTRON_CONF) |
|
51.1.2
by Adam Gandelman
Check in start of py redux. |
191 |
|
192 |
||
100.4.1
by Liam Young
Run db migrations for neutron |
193 |
def conditional_neutron_migration(): |
194 |
if relation_ids('neutron-api'): |
|
195 |
log('Not running neutron database migration as neutron-api service' |
|
196 |
'is present.') |
|
100.5.1
by Liam Young
Don't run neutron db migrations pre-juno as neutron-server does it itself |
197 |
elif os_release('nova-common') <= 'icehouse': |
198 |
log('Not running neutron database migration as migrations are handled' |
|
199 |
'by the neutron-server process.') |
|
100.4.1
by Liam Young
Run db migrations for neutron |
200 |
else: |
201 |
migrate_neutron_database() |
|
202 |
# neutron-api service may have appeared while the migration was
|
|
203 |
# running so prod it just in case
|
|
204 |
[neutron_api_relation_joined(rid=rid, remote_restart=True) |
|
205 |
for rid in relation_ids('neutron-api')] |
|
206 |
if 'neutron-server' in services(): |
|
207 |
service_restart('neutron-server') |
|
208 |
||
209 |
||
51.1.2
by Adam Gandelman
Check in start of py redux. |
210 |
@hooks.hook('shared-db-relation-joined') |
211 |
def db_joined(): |
|
56.3.58
by James Page
Tidy before proposal |
212 |
if is_relation_made('pgsql-nova-db') or \ |
213 |
is_relation_made('pgsql-neutron-db'): |
|
68.3.2
by yolanda.robla at canonical
added postgresql support |
214 |
# error, postgresql is used
|
215 |
e = ('Attempting to associate a mysql database when there is already ' |
|
216 |
'associated a postgresql one') |
|
68.3.9
by yolanda.robla at canonical
fixes in oscontext and in db relations |
217 |
log(e, level=ERROR) |
68.3.10
by yolanda.robla at canonical
raising generic exception |
218 |
raise Exception(e) |
68.3.11
by yolanda.robla at canonical
fixed lint bugs |
219 |
|
93.4.30
by Edward Hope-Morley
synced charm-helpers |
220 |
if network_manager() in ['quantum', 'neutron']: |
221 |
config_neutron = True |
|
222 |
else: |
|
223 |
config_neutron = False |
|
224 |
||
93.4.1
by Hui Xiang
Support nova-cloud-controller for IPv6. |
225 |
if config('prefer-ipv6'): |
93.4.26
by Edward Hope-Morley
more |
226 |
sync_db_with_multi_ipv6_addresses(config('database'), |
93.4.28
by Hui Xiang
Refactor codes. |
227 |
config('database-user'), |
93.4.30
by Edward Hope-Morley
synced charm-helpers |
228 |
relation_prefix='nova') |
229 |
||
230 |
if config_neutron: |
|
231 |
sync_db_with_multi_ipv6_addresses(config('neutron-database'), |
|
232 |
config('neutron-database-user'), |
|
233 |
relation_prefix='neutron') |
|
93.4.1
by Hui Xiang
Support nova-cloud-controller for IPv6. |
234 |
else: |
235 |
host = unit_get('private-address') |
|
93.4.25
by Hui Xiang
sync_db_with_multi_ipv6_addresses |
236 |
relation_set(nova_database=config('database'), |
237 |
nova_username=config('database-user'), |
|
238 |
nova_hostname=host) |
|
93.4.1
by Hui Xiang
Support nova-cloud-controller for IPv6. |
239 |
|
93.4.30
by Edward Hope-Morley
synced charm-helpers |
240 |
if config_neutron: |
241 |
# XXX: Renaming relations from quantum_* to neutron_* here.
|
|
242 |
relation_set(neutron_database=config('neutron-database'), |
|
243 |
neutron_username=config('neutron-database-user'), |
|
244 |
neutron_hostname=host) |
|
51.1.2
by Adam Gandelman
Check in start of py redux. |
245 |
|
246 |
||
68.3.2
by yolanda.robla at canonical
added postgresql support |
247 |
@hooks.hook('pgsql-nova-db-relation-joined') |
248 |
def pgsql_nova_db_joined(): |
|
249 |
if is_relation_made('shared-db'): |
|
250 |
# raise error
|
|
56.3.58
by James Page
Tidy before proposal |
251 |
e = ('Attempting to associate a postgresql database' |
252 |
' when there is already associated a mysql one') |
|
68.3.9
by yolanda.robla at canonical
fixes in oscontext and in db relations |
253 |
log(e, level=ERROR) |
68.3.10
by yolanda.robla at canonical
raising generic exception |
254 |
raise Exception(e) |
68.3.2
by yolanda.robla at canonical
added postgresql support |
255 |
|
68.3.14
by yolanda.robla at canonical
typo |
256 |
relation_set(database=config('database')) |
68.3.2
by yolanda.robla at canonical
added postgresql support |
257 |
|
258 |
||
259 |
@hooks.hook('pgsql-neutron-db-relation-joined') |
|
260 |
def pgsql_neutron_db_joined(): |
|
261 |
if is_relation_made('shared-db'): |
|
262 |
# raise error
|
|
56.3.58
by James Page
Tidy before proposal |
263 |
e = ('Attempting to associate a postgresql database' |
264 |
' when there is already associated a mysql one') |
|
68.3.9
by yolanda.robla at canonical
fixes in oscontext and in db relations |
265 |
log(e, level=ERROR) |
68.3.10
by yolanda.robla at canonical
raising generic exception |
266 |
raise Exception(e) |
68.3.2
by yolanda.robla at canonical
added postgresql support |
267 |
|
68.3.14
by yolanda.robla at canonical
typo |
268 |
relation_set(database=config('neutron-database')) |
68.3.2
by yolanda.robla at canonical
added postgresql support |
269 |
|
270 |
||
51.1.2
by Adam Gandelman
Check in start of py redux. |
271 |
@hooks.hook('shared-db-relation-changed') |
83.1.9
by james.page at ubuntu
Disable service-guard by default |
272 |
@service_guard(guard_map(), CONFIGS, |
273 |
active=config('service-guard')) |
|
51.1.2
by Adam Gandelman
Check in start of py redux. |
274 |
@restart_on_change(restart_map()) |
275 |
def db_changed(): |
|
276 |
if 'shared-db' not in CONFIGS.complete_contexts(): |
|
277 |
log('shared-db relation incomplete. Peer not ready?') |
|
278 |
return
|
|
56.3.59
by James Page
Fixup bug in shared-db and postgresql changed hooks - neutron uses the db as well |
279 |
CONFIGS.write_all() |
51.1.2
by Adam Gandelman
Check in start of py redux. |
280 |
|
281 |
if eligible_leader(CLUSTER_RES): |
|
95.1.1
by Liam Young
In clustered mode check if node is in databases allowed_units list before doing db work |
282 |
# Bugs 1353135 & 1187508. Dbs can appear to be ready before the units
|
283 |
# acl entry has been added. So, if the db supports passing a list of
|
|
284 |
# permitted units then check if we're in the list.
|
|
285 |
allowed_units = relation_get('nova_allowed_units') |
|
286 |
if allowed_units and local_unit() not in allowed_units.split(): |
|
287 |
log('Allowed_units list provided and this unit not present') |
|
288 |
return
|
|
100.4.1
by Liam Young
Run db migrations for neutron |
289 |
migrate_nova_database() |
52.3.7
by Adam Gandelman
Add logging. |
290 |
log('Triggering remote cloud-compute restarts.') |
52.3.6
by Adam Gandelman
Send restart trigger to compute side after db migration. |
291 |
[compute_joined(rid=rid, remote_restart=True) |
292 |
for rid in relation_ids('cloud-compute')] |
|
100.4.1
by Liam Young
Run db migrations for neutron |
293 |
conditional_neutron_migration() |
51.1.2
by Adam Gandelman
Check in start of py redux. |
294 |
|
295 |
||
68.3.2
by yolanda.robla at canonical
added postgresql support |
296 |
@hooks.hook('pgsql-nova-db-relation-changed') |
83.1.9
by james.page at ubuntu
Disable service-guard by default |
297 |
@service_guard(guard_map(), CONFIGS, |
298 |
active=config('service-guard')) |
|
68.3.9
by yolanda.robla at canonical
fixes in oscontext and in db relations |
299 |
@restart_on_change(restart_map()) |
300 |
def postgresql_nova_db_changed(): |
|
301 |
if 'pgsql-nova-db' not in CONFIGS.complete_contexts(): |
|
68.3.16
by yolanda.robla at canonical
added db testing |
302 |
log('pgsql-nova-db relation incomplete. Peer not ready?') |
68.3.9
by yolanda.robla at canonical
fixes in oscontext and in db relations |
303 |
return
|
56.3.59
by James Page
Fixup bug in shared-db and postgresql changed hooks - neutron uses the db as well |
304 |
CONFIGS.write_all() |
68.3.9
by yolanda.robla at canonical
fixes in oscontext and in db relations |
305 |
|
306 |
if eligible_leader(CLUSTER_RES): |
|
100.4.1
by Liam Young
Run db migrations for neutron |
307 |
migrate_nova_database() |
68.3.9
by yolanda.robla at canonical
fixes in oscontext and in db relations |
308 |
log('Triggering remote cloud-compute restarts.') |
309 |
[compute_joined(rid=rid, remote_restart=True) |
|
310 |
for rid in relation_ids('cloud-compute')] |
|
100.4.1
by Liam Young
Run db migrations for neutron |
311 |
conditional_neutron_migration() |
56.3.37
by James Page
[yolanda] Add postgresql support |
312 |
|
100.4.2
by Liam Young
Added unit tests for db migration and fixed lint |
313 |
|
68.3.2
by yolanda.robla at canonical
added postgresql support |
314 |
@hooks.hook('pgsql-neutron-db-relation-changed') |
83.1.9
by james.page at ubuntu
Disable service-guard by default |
315 |
@service_guard(guard_map(), CONFIGS, |
316 |
active=config('service-guard')) |
|
68.3.2
by yolanda.robla at canonical
added postgresql support |
317 |
@restart_on_change(restart_map()) |
68.3.9
by yolanda.robla at canonical
fixes in oscontext and in db relations |
318 |
def postgresql_neutron_db_changed(): |
68.3.2
by yolanda.robla at canonical
added postgresql support |
319 |
if network_manager() in ['neutron', 'quantum']: |
320 |
plugin = neutron_plugin() |
|
321 |
# DB config might have been moved to main neutron.conf in H?
|
|
322 |
CONFIGS.write(neutron_plugin_attribute(plugin, 'config')) |
|
323 |
||
324 |
||
51.1.2
by Adam Gandelman
Check in start of py redux. |
325 |
@hooks.hook('image-service-relation-changed') |
83.1.9
by james.page at ubuntu
Disable service-guard by default |
326 |
@service_guard(guard_map(), CONFIGS, |
327 |
active=config('service-guard')) |
|
51.1.2
by Adam Gandelman
Check in start of py redux. |
328 |
@restart_on_change(restart_map()) |
329 |
def image_service_changed(): |
|
330 |
if 'image-service' not in CONFIGS.complete_contexts(): |
|
331 |
log('image-service relation incomplete. Peer not ready?') |
|
332 |
return
|
|
51.1.67
by James Page
Uses constants in hooks |
333 |
CONFIGS.write(NOVA_CONF) |
51.1.2
by Adam Gandelman
Check in start of py redux. |
334 |
# TODO: special case config flag for essex (strip protocol)
|
335 |
||
336 |
||
337 |
@hooks.hook('identity-service-relation-joined') |
|
338 |
def identity_joined(rid=None): |
|
81.3.11
by james.page at ubuntu
Switch to new canonical_url helper |
339 |
public_url = canonical_url(CONFIGS, PUBLIC) |
340 |
internal_url = canonical_url(CONFIGS, INTERNAL) |
|
341 |
admin_url = canonical_url(CONFIGS, ADMIN) |
|
81.3.2
by james.page at ubuntu
Add support for internal and public networks |
342 |
relation_set(relation_id=rid, **determine_endpoints(public_url, |
81.3.5
by james.page at ubuntu
Add extra admin-network configuration |
343 |
internal_url, |
344 |
admin_url)) |
|
51.1.2
by Adam Gandelman
Check in start of py redux. |
345 |
|
346 |
||
347 |
@hooks.hook('identity-service-relation-changed') |
|
83.1.9
by james.page at ubuntu
Disable service-guard by default |
348 |
@service_guard(guard_map(), CONFIGS, |
349 |
active=config('service-guard')) |
|
51.1.2
by Adam Gandelman
Check in start of py redux. |
350 |
@restart_on_change(restart_map()) |
351 |
def identity_changed(): |
|
352 |
if 'identity-service' not in CONFIGS.complete_contexts(): |
|
353 |
log('identity-service relation incomplete. Peer not ready?') |
|
354 |
return
|
|
355 |
CONFIGS.write('/etc/nova/api-paste.ini') |
|
51.1.67
by James Page
Uses constants in hooks |
356 |
CONFIGS.write(NOVA_CONF) |
75.3.2
by Liam Young
Don't write {neutron,quantum} files if standalone neutron-api is present |
357 |
if not is_relation_made('neutron-api'): |
358 |
if network_manager() == 'quantum': |
|
359 |
CONFIGS.write(QUANTUM_API_PASTE) |
|
360 |
CONFIGS.write(QUANTUM_CONF) |
|
361 |
save_novarc() |
|
362 |
if network_manager() == 'neutron': |
|
363 |
CONFIGS.write(NEUTRON_CONF) |
|
51.1.10
by Adam Gandelman
Add neutron database config, better compat for supporting both names. Adds templates, fixes HAProxy context. |
364 |
[compute_joined(rid) for rid in relation_ids('cloud-compute')] |
51.1.73
by James Page
Ensure keystone auth data sent to quantum-network-service related service on change |
365 |
[quantum_joined(rid) for rid in relation_ids('quantum-network-service')] |
52.3.5
by Adam Gandelman
Update vmware interface on new keystone relation. |
366 |
[nova_vmware_relation_joined(rid) for rid in relation_ids('nova-vmware')] |
81.1.1
by Liam Young
Inform neutron-api if endpoints have changed |
367 |
[neutron_api_relation_joined(rid) for rid in relation_ids('neutron-api')] |
51.1.37
by Adam Gandelman
Ensure configure_https() out of identity_changed(). |
368 |
configure_https() |
51.1.2
by Adam Gandelman
Check in start of py redux. |
369 |
|
370 |
||
371 |
@hooks.hook('nova-volume-service-relation-joined', |
|
372 |
'cinder-volume-service-relation-joined') |
|
83.1.9
by james.page at ubuntu
Disable service-guard by default |
373 |
@service_guard(guard_map(), CONFIGS, |
374 |
active=config('service-guard')) |
|
51.1.2
by Adam Gandelman
Check in start of py redux. |
375 |
@restart_on_change(restart_map()) |
376 |
def volume_joined(): |
|
51.1.67
by James Page
Uses constants in hooks |
377 |
CONFIGS.write(NOVA_CONF) |
51.1.2
by Adam Gandelman
Check in start of py redux. |
378 |
# kick identity_joined() to publish possibly new nova-volume endpoint.
|
379 |
[identity_joined(rid) for rid in relation_ids('identity-service')] |
|
380 |
||
381 |
||
382 |
def _auth_config(): |
|
383 |
'''Grab all KS auth token config from api-paste.ini, or return empty {}'''
|
|
384 |
ks_auth_host = auth_token_config('auth_host') |
|
385 |
if not ks_auth_host: |
|
386 |
# if there is no auth_host set, identity-service changed hooks
|
|
387 |
# have not fired, yet.
|
|
388 |
return {} |
|
389 |
cfg = { |
|
390 |
'auth_host': ks_auth_host, |
|
391 |
'auth_port': auth_token_config('auth_port'), |
|
58.4.10
by James Page
Resync latest ssl-everywhere helpers, add ssl_ca option. |
392 |
'auth_protocol': auth_token_config('auth_protocol'), |
393 |
'service_protocol': auth_token_config('service_protocol'), |
|
51.1.2
by Adam Gandelman
Check in start of py redux. |
394 |
'service_port': auth_token_config('service_port'), |
395 |
'service_username': auth_token_config('admin_user'), |
|
396 |
'service_password': auth_token_config('admin_password'), |
|
397 |
'service_tenant_name': auth_token_config('admin_tenant_name'), |
|
398 |
'auth_uri': auth_token_config('auth_uri'), |
|
51.1.20
by Adam Gandelman
Install quantum utility scripts. |
399 |
# quantum-gateway interface deviates a bit.
|
400 |
'keystone_host': ks_auth_host, |
|
401 |
'service_tenant': auth_token_config('admin_tenant_name'), |
|
51.1.2
by Adam Gandelman
Check in start of py redux. |
402 |
}
|
403 |
return cfg |
|
404 |
||
405 |
||
51.1.21
by Adam Gandelman
override IdentityServiceContext and ensure keystone_ec2_url is set in nova.conf |
406 |
def save_novarc(): |
407 |
auth = _auth_config() |
|
408 |
# XXX hard-coded http
|
|
58.4.10
by James Page
Resync latest ssl-everywhere helpers, add ssl_ca option. |
409 |
ks_url = '%s://%s:%s/v2.0' % (auth['auth_protocol'], |
410 |
auth['auth_host'], auth['auth_port']) |
|
51.1.21
by Adam Gandelman
override IdentityServiceContext and ensure keystone_ec2_url is set in nova.conf |
411 |
with open('/etc/quantum/novarc', 'wb') as out: |
412 |
out.write('export OS_USERNAME=%s\n' % auth['service_username']) |
|
413 |
out.write('export OS_PASSWORD=%s\n' % auth['service_password']) |
|
414 |
out.write('export OS_TENANT_NAME=%s\n' % auth['service_tenant_name']) |
|
415 |
out.write('export OS_AUTH_URL=%s\n' % ks_url) |
|
416 |
out.write('export OS_REGION_NAME=%s\n' % config('region')) |
|
417 |
||
78.2.4
by Liam Young
More unit tests and lint cleanup |
418 |
|
75.3.10
by Liam Young
Send correct api info to quantum-gateway if neutron-api charm is being used |
419 |
def neutron_settings(): |
420 |
neutron_settings = {} |
|
78.2.7
by Liam Young
Bug fix. Charm was looking for the wrong key in api relations s/_/-/ |
421 |
if is_relation_made('neutron-api', 'neutron-plugin'): |
81
by james.page at ubuntu
[gnuoy,r=james-page] Refactoring to support split-out of Neutron functionality. |
422 |
neutron_api_info = NeutronAPIContext()() |
75.3.10
by Liam Young
Send correct api info to quantum-gateway if neutron-api charm is being used |
423 |
neutron_settings.update({ |
424 |
# XXX: Rename these relations settings?
|
|
81
by james.page at ubuntu
[gnuoy,r=james-page] Refactoring to support split-out of Neutron functionality. |
425 |
'quantum_plugin': neutron_api_info['neutron_plugin'], |
75.3.10
by Liam Young
Send correct api info to quantum-gateway if neutron-api charm is being used |
426 |
'region': config('region'), |
78.2.6
by Liam Young
Fixed lint and unit tests |
427 |
'quantum_security_groups': |
81
by james.page at ubuntu
[gnuoy,r=james-page] Refactoring to support split-out of Neutron functionality. |
428 |
neutron_api_info['neutron_security_groups'], |
429 |
'quantum_url': neutron_api_info['neutron_url'], |
|
75.3.10
by Liam Young
Send correct api info to quantum-gateway if neutron-api charm is being used |
430 |
})
|
431 |
else: |
|
432 |
neutron_settings.update({ |
|
433 |
# XXX: Rename these relations settings?
|
|
434 |
'quantum_plugin': neutron_plugin(), |
|
435 |
'region': config('region'), |
|
436 |
'quantum_security_groups': config('quantum-security-groups'), |
|
81.3.11
by james.page at ubuntu
Switch to new canonical_url helper |
437 |
'quantum_url': "{}:{}".format(canonical_url(CONFIGS, INTERNAL), |
81.3.2
by james.page at ubuntu
Add support for internal and public networks |
438 |
str(api_port('neutron-server'))), |
75.3.10
by Liam Young
Send correct api info to quantum-gateway if neutron-api charm is being used |
439 |
})
|
81
by james.page at ubuntu
[gnuoy,r=james-page] Refactoring to support split-out of Neutron functionality. |
440 |
neutron_url = urlparse(neutron_settings['quantum_url']) |
441 |
neutron_settings['quantum_host'] = neutron_url.hostname |
|
442 |
neutron_settings['quantum_port'] = neutron_url.port |
|
75.3.10
by Liam Young
Send correct api info to quantum-gateway if neutron-api charm is being used |
443 |
return neutron_settings |
51.1.21
by Adam Gandelman
override IdentityServiceContext and ensure keystone_ec2_url is set in nova.conf |
444 |
|
78.2.4
by Liam Young
More unit tests and lint cleanup |
445 |
|
52.3.4
by Adam Gandelman
Pass neutron data to vmw subordinte. |
446 |
def keystone_compute_settings(): |
447 |
ks_auth_config = _auth_config() |
|
448 |
rel_settings = {} |
|
449 |
||
450 |
if network_manager() in ['quantum', 'neutron']: |
|
451 |
if ks_auth_config: |
|
452 |
rel_settings.update(ks_auth_config) |
|
75.3.10
by Liam Young
Send correct api info to quantum-gateway if neutron-api charm is being used |
453 |
rel_settings.update(neutron_settings()) |
52.3.4
by Adam Gandelman
Pass neutron data to vmw subordinte. |
454 |
ks_ca = keystone_ca_cert_b64() |
455 |
if ks_auth_config and ks_ca: |
|
456 |
rel_settings['ca_cert'] = ks_ca |
|
457 |
return rel_settings |
|
458 |
||
459 |
||
82.1.1
by Liam Young
Add config for guest console access |
460 |
def console_settings(): |
461 |
rel_settings = {} |
|
82.1.7
by Liam Young
Fixed lint |
462 |
proto = console_attributes('protocol') |
463 |
if not proto: |
|
82.1.1
by Liam Young
Add config for guest console access |
464 |
return {} |
82.1.7
by Liam Young
Fixed lint |
465 |
rel_settings['console_keymap'] = config('console-keymap') |
466 |
rel_settings['console_access_protocol'] = proto |
|
82.1.17
by Liam Young
README update, enable ability to explictly set the use of the nova-cc address and use the PUBLIC address |
467 |
if config('console-proxy-ip') == 'local': |
468 |
proxy_base_addr = canonical_url(CONFIGS, PUBLIC) |
|
469 |
else: |
|
82.1.9
by Liam Young
Install console packages in config changed incase the console protocol is changed. Fix relation set to pass ip/hostname rather than url for console_proxy_%s_host |
470 |
proxy_base_addr = "http://" + config('console-proxy-ip') |
82.1.7
by Liam Young
Fixed lint |
471 |
if proto == 'vnc': |
472 |
protocols = ['novnc', 'xvpvnc'] |
|
473 |
else: |
|
474 |
protocols = [proto] |
|
475 |
for _proto in protocols: |
|
476 |
rel_settings['console_proxy_%s_address' % (_proto)] = \ |
|
82.1.10
by Liam Young
Remove double // from console_proxy_%s_address |
477 |
"%s:%s%s" % (proxy_base_addr, |
82.1.11
by Liam Young
Added unit tests for console configuration |
478 |
console_attributes('proxy-port', proto=_proto), |
479 |
console_attributes('proxy-page', proto=_proto)) |
|
82.1.9
by Liam Young
Install console packages in config changed incase the console protocol is changed. Fix relation set to pass ip/hostname rather than url for console_proxy_%s_host |
480 |
rel_settings['console_proxy_%s_host' % (_proto)] = \ |
481 |
urlparse(proxy_base_addr).hostname |
|
82.1.7
by Liam Young
Fixed lint |
482 |
rel_settings['console_proxy_%s_port' % (_proto)] = \ |
82.1.8
by Liam Young
Fix typo |
483 |
console_attributes('proxy-port', proto=_proto) |
82.1.7
by Liam Young
Fixed lint |
484 |
|
82.1.1
by Liam Young
Add config for guest console access |
485 |
return rel_settings |
486 |
||
487 |
||
51.1.2
by Adam Gandelman
Check in start of py redux. |
488 |
@hooks.hook('cloud-compute-relation-joined') |
52.3.6
by Adam Gandelman
Send restart trigger to compute side after db migration. |
489 |
def compute_joined(rid=None, remote_restart=False): |
82.1.16
by Liam Young
Set console_settings for compute node if leader or not as leadership is irrelevant and stale settings can persist otherwise |
490 |
cons_settings = console_settings() |
491 |
relation_set(relation_id=rid, **cons_settings) |
|
51.1.2
by Adam Gandelman
Check in start of py redux. |
492 |
rel_settings = { |
51.1.10
by Adam Gandelman
Add neutron database config, better compat for supporting both names. Adds templates, fixes HAProxy context. |
493 |
'network_manager': network_manager(), |
51.1.2
by Adam Gandelman
Check in start of py redux. |
494 |
'volume_service': volume_service(), |
495 |
# (comment from bash vers) XXX Should point to VIP if clustered, or
|
|
496 |
# this may not even be needed.
|
|
497 |
'ec2_host': unit_get('private-address'), |
|
498 |
}
|
|
52.3.6
by Adam Gandelman
Send restart trigger to compute side after db migration. |
499 |
# update relation setting if we're attempting to restart remote
|
500 |
# services
|
|
501 |
if remote_restart: |
|
502 |
rel_settings['restart_trigger'] = str(uuid.uuid4()) |
|
503 |
||
52.3.4
by Adam Gandelman
Pass neutron data to vmw subordinte. |
504 |
rel_settings.update(keystone_compute_settings()) |
51.1.10
by Adam Gandelman
Add neutron database config, better compat for supporting both names. Adds templates, fixes HAProxy context. |
505 |
relation_set(relation_id=rid, **rel_settings) |
51.1.2
by Adam Gandelman
Check in start of py redux. |
506 |
|
507 |
||
51.1.8
by Adam Gandelman
Various fixes. |
508 |
@hooks.hook('cloud-compute-relation-changed') |
75.4.9
by Louis Bouchard
Implement changes following Merge Proposal |
509 |
def compute_changed(rid=None, unit=None): |
510 |
rel_settings = relation_get(rid=rid, unit=unit) |
|
75.4.5
by Louis Bouchard
Modified relation_get mechanism in compute_changed |
511 |
if 'migration_auth_type' not in rel_settings: |
512 |
return
|
|
513 |
if rel_settings['migration_auth_type'] == 'ssh': |
|
75.4.9
by Louis Bouchard
Implement changes following Merge Proposal |
514 |
key = rel_settings.get('ssh_public_key') |
51.2.1
by Adam Gandelman
Finish up SSH compute peers. |
515 |
if not key: |
516 |
log('SSH migration set but peer did not publish key.') |
|
517 |
return
|
|
75.4.9
by Louis Bouchard
Implement changes following Merge Proposal |
518 |
ssh_compute_add(key, rid=rid, unit=unit) |
73.1.1
by Louis Bouchard
Changes on the nova-cloud-controller side |
519 |
index = 0 |
75.4.9
by Louis Bouchard
Implement changes following Merge Proposal |
520 |
for line in ssh_known_hosts_lines(unit=unit): |
83
by james.page at ubuntu
[caribou,r=james-page] Second part of multiline SSH key and authorized host passing to nova-compute |
521 |
relation_set( |
522 |
relation_id=rid, |
|
523 |
relation_settings={ |
|
524 |
'known_hosts_{}'.format(index): line}) |
|
73.1.2
by Louis Bouchard
Functional line by line modification, except for the 'nova' user. |
525 |
index += 1 |
75.4.4
by Louis Bouchard
Modify hook funcions & util to work in non-relation hooks |
526 |
relation_set(relation_id=rid, known_hosts_max_index=index) |
73.1.2
by Louis Bouchard
Functional line by line modification, except for the 'nova' user. |
527 |
index = 0 |
75.4.9
by Louis Bouchard
Implement changes following Merge Proposal |
528 |
for line in ssh_authorized_keys_lines(unit=unit): |
83
by james.page at ubuntu
[caribou,r=james-page] Second part of multiline SSH key and authorized host passing to nova-compute |
529 |
relation_set( |
530 |
relation_id=rid, |
|
531 |
relation_settings={ |
|
532 |
'authorized_keys_{}'.format(index): line}) |
|
73.1.2
by Louis Bouchard
Functional line by line modification, except for the 'nova' user. |
533 |
index += 1 |
75.4.4
by Louis Bouchard
Modify hook funcions & util to work in non-relation hooks |
534 |
relation_set(relation_id=rid, authorized_keys_max_index=index) |
75.4.6
by Louis Bouchard
Add missing rel_settings test |
535 |
if 'nova_ssh_public_key' not in rel_settings: |
536 |
return
|
|
75.4.5
by Louis Bouchard
Modified relation_get mechanism in compute_changed |
537 |
if rel_settings['nova_ssh_public_key']: |
538 |
ssh_compute_add(rel_settings['nova_ssh_public_key'], |
|
75.4.9
by Louis Bouchard
Implement changes following Merge Proposal |
539 |
rid=rid, unit=unit, user='nova') |
73.1.3
by Louis Bouchard
Support for line by line for 'nova' user |
540 |
index = 0 |
75.4.9
by Louis Bouchard
Implement changes following Merge Proposal |
541 |
for line in ssh_known_hosts_lines(unit=unit, user='nova'): |
83
by james.page at ubuntu
[caribou,r=james-page] Second part of multiline SSH key and authorized host passing to nova-compute |
542 |
relation_set( |
543 |
relation_id=rid, |
|
544 |
relation_settings={ |
|
545 |
'{}_known_hosts_{}'.format( |
|
546 |
'nova', |
|
547 |
index): line}) |
|
73.1.3
by Louis Bouchard
Support for line by line for 'nova' user |
548 |
index += 1 |
83
by james.page at ubuntu
[caribou,r=james-page] Second part of multiline SSH key and authorized host passing to nova-compute |
549 |
relation_set( |
550 |
relation_id=rid, |
|
551 |
relation_settings={ |
|
552 |
'{}_known_hosts_max_index'.format('nova'): index}) |
|
73.1.3
by Louis Bouchard
Support for line by line for 'nova' user |
553 |
index = 0 |
75.4.9
by Louis Bouchard
Implement changes following Merge Proposal |
554 |
for line in ssh_authorized_keys_lines(unit=unit, user='nova'): |
83
by james.page at ubuntu
[caribou,r=james-page] Second part of multiline SSH key and authorized host passing to nova-compute |
555 |
relation_set( |
556 |
relation_id=rid, |
|
557 |
relation_settings={ |
|
558 |
'{}_authorized_keys_{}'.format( |
|
559 |
'nova', |
|
560 |
index): line}) |
|
73.1.3
by Louis Bouchard
Support for line by line for 'nova' user |
561 |
index += 1 |
83
by james.page at ubuntu
[caribou,r=james-page] Second part of multiline SSH key and authorized host passing to nova-compute |
562 |
relation_set( |
563 |
relation_id=rid, |
|
564 |
relation_settings={ |
|
565 |
'{}_authorized_keys_max_index'.format('nova'): index}) |
|
51.2.1
by Adam Gandelman
Finish up SSH compute peers. |
566 |
|
567 |
||
51.1.54
by Adam Gandelman
Add compute departed hook, ensure proper scrubbing of authorized_keys on compute depart. |
568 |
@hooks.hook('cloud-compute-relation-departed') |
75.4.9
by Louis Bouchard
Implement changes following Merge Proposal |
569 |
def compute_departed(): |
570 |
ssh_compute_remove(public_key=relation_get('ssh_public_key')) |
|
51.2.1
by Adam Gandelman
Finish up SSH compute peers. |
571 |
|
572 |
||
51.2.2
by Adam Gandelman
First pass at neutron/quantum compat. |
573 |
@hooks.hook('neutron-network-service-relation-joined', |
574 |
'quantum-network-service-relation-joined') |
|
51.1.2
by Adam Gandelman
Check in start of py redux. |
575 |
def quantum_joined(rid=None): |
75.3.10
by Liam Young
Send correct api info to quantum-gateway if neutron-api charm is being used |
576 |
rel_settings = neutron_settings() |
51.1.2
by Adam Gandelman
Check in start of py redux. |
577 |
|
578 |
# inform quantum about local keystone auth config
|
|
579 |
ks_auth_config = _auth_config() |
|
580 |
rel_settings.update(ks_auth_config) |
|
581 |
||
582 |
# must pass the keystone CA cert, if it exists.
|
|
583 |
ks_ca = keystone_ca_cert_b64() |
|
584 |
if ks_auth_config and ks_ca: |
|
585 |
rel_settings['ca_cert'] = ks_ca |
|
52.1.1
by James Page
Use correct key when setting data for quantum_joined |
586 |
relation_set(relation_id=rid, **rel_settings) |
51.1.2
by Adam Gandelman
Check in start of py redux. |
587 |
|
588 |
||
93.5.1
by Hui Xiang
Fix cluster |
589 |
@hooks.hook('cluster-relation-joined') |
93.4.28
by Hui Xiang
Refactor codes. |
590 |
def cluster_joined(relation_id=None): |
100.7.9
by james.page at ubuntu
Resync helpers, deal with clustered HA + HTTPS |
591 |
for addr_type in ADDRESS_TYPES: |
592 |
address = get_address_in_network( |
|
593 |
config('os-{}-network'.format(addr_type)) |
|
594 |
)
|
|
595 |
if address: |
|
596 |
relation_set( |
|
597 |
relation_id=relation_id, |
|
598 |
relation_settings={'{}-address'.format(addr_type): address} |
|
599 |
)
|
|
93.4.28
by Hui Xiang
Refactor codes. |
600 |
if config('prefer-ipv6'): |
601 |
private_addr = get_ipv6_addr(exc_list=[config('vip')])[0] |
|
100.7.10
by james.page at ubuntu
Rebase, resync |
602 |
relation_set(relation_id=relation_id, |
603 |
relation_settings={'private-address': private_addr}) |
|
93.5.1
by Hui Xiang
Fix cluster |
604 |
|
605 |
||
51.1.2
by Adam Gandelman
Check in start of py redux. |
606 |
@hooks.hook('cluster-relation-changed', |
607 |
'cluster-relation-departed') |
|
83.1.9
by james.page at ubuntu
Disable service-guard by default |
608 |
@service_guard(guard_map(), CONFIGS, |
609 |
active=config('service-guard')) |
|
62.1.3
by Ante Karamatic
Provide both restart and stop/start functionality |
610 |
@restart_on_change(restart_map(), stopstart=True) |
51.1.2
by Adam Gandelman
Check in start of py redux. |
611 |
def cluster_changed(): |
612 |
CONFIGS.write_all() |
|
100.3.1
by james.page at ubuntu
Only check for presence of relation when using peer relation for storage and sync |
613 |
if relation_ids('cluster'): |
93.3.2
by Liam Young
Added additional logging and only use peer_* commands if the peer relation exists |
614 |
peer_echo(includes='dbsync_state') |
615 |
dbsync_state = peer_retrieve('dbsync_state') |
|
616 |
if dbsync_state == 'complete': |
|
617 |
enable_services() |
|
618 |
cmd_all_services('start') |
|
619 |
else: |
|
620 |
log('Database sync not ready. Shutting down services') |
|
621 |
disable_services() |
|
622 |
cmd_all_services('stop') |
|
51.1.2
by Adam Gandelman
Check in start of py redux. |
623 |
|
93.3.1
by Liam Young
Shutdown nova-cloud-controller services when nova db sync is run for db relation joined |
624 |
|
51.1.2
by Adam Gandelman
Check in start of py redux. |
625 |
@hooks.hook('ha-relation-joined') |
626 |
def ha_joined(): |
|
93.4.1
by Hui Xiang
Support nova-cloud-controller for IPv6. |
627 |
cluster_config = get_hacluster_config() |
51.1.2
by Adam Gandelman
Check in start of py redux. |
628 |
resources = { |
629 |
'res_nova_haproxy': 'lsb:haproxy', |
|
630 |
}
|
|
631 |
resource_params = { |
|
632 |
'res_nova_haproxy': 'op monitor interval="5s"' |
|
633 |
}
|
|
93.4.1
by Hui Xiang
Support nova-cloud-controller for IPv6. |
634 |
|
81.3.12
by james.page at ubuntu
Support multi-network vip configuration |
635 |
vip_group = [] |
93.4.1
by Hui Xiang
Support nova-cloud-controller for IPv6. |
636 |
for vip in cluster_config['vip'].split(): |
93.4.28
by Hui Xiang
Refactor codes. |
637 |
if is_ipv6(vip): |
638 |
res_nova_vip = 'ocf:heartbeat:IPv6addr' |
|
639 |
vip_params = 'ipv6addr' |
|
640 |
else: |
|
641 |
res_nova_vip = 'ocf:heartbeat:IPaddr2' |
|
642 |
vip_params = 'ip' |
|
643 |
||
81.3.12
by james.page at ubuntu
Support multi-network vip configuration |
644 |
iface = get_iface_for_address(vip) |
645 |
if iface is not None: |
|
646 |
vip_key = 'res_nova_{}_vip'.format(iface) |
|
93.4.1
by Hui Xiang
Support nova-cloud-controller for IPv6. |
647 |
resources[vip_key] = res_nova_vip |
81.3.12
by james.page at ubuntu
Support multi-network vip configuration |
648 |
resource_params[vip_key] = ( |
93.4.1
by Hui Xiang
Support nova-cloud-controller for IPv6. |
649 |
'params {ip}="{vip}" cidr_netmask="{netmask}"' |
650 |
' nic="{iface}"'.format(ip=vip_params, |
|
651 |
vip=vip, |
|
81.3.12
by james.page at ubuntu
Support multi-network vip configuration |
652 |
iface=iface, |
653 |
netmask=get_netmask_for_address(vip)) |
|
654 |
)
|
|
655 |
vip_group.append(vip_key) |
|
656 |
||
93.4.19
by Hui Xiang
Use general BindHostContext, small refactor. |
657 |
if len(vip_group) >= 1: |
658 |
relation_set(groups={'grp_nova_vips': ' '.join(vip_group)}) |
|
81.3.13
by james.page at ubuntu
Tidy lint |
659 |
|
51.1.2
by Adam Gandelman
Check in start of py redux. |
660 |
init_services = { |
661 |
'res_nova_haproxy': 'haproxy' |
|
662 |
}
|
|
663 |
clones = { |
|
664 |
'cl_nova_haproxy': 'res_nova_haproxy' |
|
665 |
}
|
|
666 |
relation_set(init_services=init_services, |
|
93.4.1
by Hui Xiang
Support nova-cloud-controller for IPv6. |
667 |
corosync_bindiface=cluster_config['ha-bindiface'], |
668 |
corosync_mcastport=cluster_config['ha-mcastport'], |
|
51.1.2
by Adam Gandelman
Check in start of py redux. |
669 |
resources=resources, |
670 |
resource_params=resource_params, |
|
671 |
clones=clones) |
|
672 |
||
673 |
||
674 |
@hooks.hook('ha-relation-changed') |
|
675 |
def ha_changed(): |
|
51.1.30
by Adam Gandelman
Work around any inconsistencies in relation_get() return values when inspecting for clusteredness. |
676 |
clustered = relation_get('clustered') |
677 |
if not clustered or clustered in [None, 'None', '']: |
|
51.1.2
by Adam Gandelman
Check in start of py redux. |
678 |
log('ha_changed: hacluster subordinate not fully clustered.') |
679 |
return
|
|
89.2.1
by Yaguang Tang
Update nova configuration file to use vip when in ha clustering mode. |
680 |
|
681 |
CONFIGS.write(NOVA_CONF) |
|
96
by James Page
[trivial] ensure neutron/quantum configuration is registered before writing |
682 |
if not is_relation_made('neutron-api'): |
683 |
if network_manager() == 'quantum': |
|
684 |
CONFIGS.write(QUANTUM_CONF) |
|
685 |
if network_manager() == 'neutron': |
|
686 |
CONFIGS.write(NEUTRON_CONF) |
|
89.2.1
by Yaguang Tang
Update nova configuration file to use vip when in ha clustering mode. |
687 |
|
51.1.2
by Adam Gandelman
Check in start of py redux. |
688 |
log('Cluster configured, notifying other services and updating ' |
689 |
'keystone endpoint configuration') |
|
690 |
for rid in relation_ids('identity-service'): |
|
691 |
identity_joined(rid=rid) |
|
692 |
||
693 |
||
93.2.6
by Liam Young
debug etc |
694 |
@hooks.hook('shared-db-relation-broken', |
695 |
'pgsql-nova-db-relation-broken') |
|
696 |
@service_guard(guard_map(), CONFIGS, |
|
697 |
active=config('service-guard')) |
|
698 |
def db_departed(): |
|
699 |
CONFIGS.write_all() |
|
700 |
for r_id in relation_ids('cluster'): |
|
701 |
relation_set(relation_id=r_id, dbsync_state='incomplete') |
|
93.3.1
by Liam Young
Shutdown nova-cloud-controller services when nova db sync is run for db relation joined |
702 |
disable_services() |
703 |
cmd_all_services('stop') |
|
704 |
||
93.2.6
by Liam Young
debug etc |
705 |
|
51.1.43
by Adam Gandelman
Add generic relation broken hook. |
706 |
@hooks.hook('amqp-relation-broken', |
707 |
'cinder-volume-service-relation-broken', |
|
708 |
'identity-service-relation-broken', |
|
709 |
'image-service-relation-broken', |
|
710 |
'nova-volume-service-relation-broken', |
|
68.3.2
by yolanda.robla at canonical
added postgresql support |
711 |
'pgsql-neutron-db-relation-broken', |
51.1.43
by Adam Gandelman
Add generic relation broken hook. |
712 |
'quantum-network-service-relation-broken') |
83.1.11
by james.page at ubuntu
Ensure services are disabled if required relations are broken |
713 |
@service_guard(guard_map(), CONFIGS, |
714 |
active=config('service-guard')) |
|
51.1.43
by Adam Gandelman
Add generic relation broken hook. |
715 |
def relation_broken(): |
716 |
CONFIGS.write_all() |
|
717 |
||
718 |
||
51.1.2
by Adam Gandelman
Check in start of py redux. |
719 |
def configure_https(): |
720 |
'''
|
|
721 |
Enables SSL API Apache config if appropriate and kicks identity-service
|
|
722 |
with any required api updates.
|
|
723 |
'''
|
|
724 |
# need to write all to ensure changes to the entire request pipeline
|
|
725 |
# propagate (c-api, haprxy, apache)
|
|
726 |
CONFIGS.write_all() |
|
727 |
if 'https' in CONFIGS.complete_contexts(): |
|
728 |
cmd = ['a2ensite', 'openstack_https_frontend'] |
|
729 |
check_call(cmd) |
|
730 |
else: |
|
731 |
cmd = ['a2dissite', 'openstack_https_frontend'] |
|
732 |
check_call(cmd) |
|
733 |
||
734 |
for rid in relation_ids('identity-service'): |
|
735 |
identity_joined(rid=rid) |
|
736 |
||
737 |
||
51.6.3
by Adam Gandelman
Rebase on python-redux work. |
738 |
@hooks.hook() |
52.3.5
by Adam Gandelman
Update vmware interface on new keystone relation. |
739 |
def nova_vmware_relation_joined(rid=None): |
52.3.4
by Adam Gandelman
Pass neutron data to vmw subordinte. |
740 |
rel_settings = {'network_manager': network_manager()} |
741 |
||
742 |
ks_auth = _auth_config() |
|
743 |
if ks_auth: |
|
744 |
rel_settings.update(ks_auth) |
|
745 |
rel_settings.update({ |
|
746 |
'quantum_plugin': neutron_plugin(), |
|
747 |
'quantum_security_groups': config('quantum-security-groups'), |
|
81.3.11
by james.page at ubuntu
Switch to new canonical_url helper |
748 |
'quantum_url': "{}:{}".format(canonical_url(CONFIGS, INTERNAL), |
81.3.2
by james.page at ubuntu
Add support for internal and public networks |
749 |
str(api_port('neutron-server')))}) |
52.3.4
by Adam Gandelman
Pass neutron data to vmw subordinte. |
750 |
|
52.3.5
by Adam Gandelman
Update vmware interface on new keystone relation. |
751 |
relation_set(relation_id=rid, **rel_settings) |
51.6.3
by Adam Gandelman
Rebase on python-redux work. |
752 |
|
753 |
||
51.6.5
by Adam Gandelman
Update template to take subordinate config options. |
754 |
@hooks.hook('nova-vmware-relation-changed') |
83.1.9
by james.page at ubuntu
Disable service-guard by default |
755 |
@service_guard(guard_map(), CONFIGS, |
756 |
active=config('service-guard')) |
|
51.6.4
by Adam Gandelman
Updates, checkin link.s |
757 |
@restart_on_change(restart_map()) |
758 |
def nova_vmware_relation_changed(): |
|
759 |
CONFIGS.write('/etc/nova/nova.conf') |
|
760 |
||
761 |
||
52.2.1
by James Page
Update rabbitmq configuration to use common vhost |
762 |
@hooks.hook('upgrade-charm') |
763 |
def upgrade_charm(): |
|
73.2.1
by james.page at ubuntu
Add options to allow configuration of worker processes |
764 |
apt_install(filter_installed_packages(determine_packages()), |
765 |
fatal=True) |
|
52.2.1
by James Page
Update rabbitmq configuration to use common vhost |
766 |
for r_id in relation_ids('amqp'): |
767 |
amqp_joined(relation_id=r_id) |
|
56.3.11
by James Page
Deal with upgrades |
768 |
for r_id in relation_ids('identity-service'): |
56.3.12
by James Page
Fixup joined |
769 |
identity_joined(rid=r_id) |
75.4.5
by Louis Bouchard
Modified relation_get mechanism in compute_changed |
770 |
for r_id in relation_ids('cloud-compute'): |
771 |
for unit in related_units(r_id): |
|
772 |
compute_changed(r_id, unit) |
|
52.2.1
by James Page
Update rabbitmq configuration to use common vhost |
773 |
|
71.3.7
by Liam Young
Trigger cell restarts on db migration and lint fixes |
774 |
|
75.3.1
by Liam Young
Add support for joining charm to standalone neutron-api service |
775 |
@hooks.hook('neutron-api-relation-joined') |
100.4.1
by Liam Young
Run db migrations for neutron |
776 |
def neutron_api_relation_joined(rid=None, remote_restart=False): |
75.3.1
by Liam Young
Add support for joining charm to standalone neutron-api service |
777 |
with open('/etc/init/neutron-server.override', 'wb') as out: |
778 |
out.write('manual\n') |
|
75.3.6
by Liam Young
Pass nova_url to neutron-api server |
779 |
if os.path.isfile(NEUTRON_CONF): |
780 |
os.rename(NEUTRON_CONF, NEUTRON_CONF + '_unused') |
|
75.3.1
by Liam Young
Add support for joining charm to standalone neutron-api service |
781 |
if service_running('neutron-server'): |
782 |
service_stop('neutron-server') |
|
75.3.6
by Liam Young
Pass nova_url to neutron-api server |
783 |
for id_rid in relation_ids('identity-service'): |
784 |
identity_joined(rid=id_rid) |
|
100.4.1
by Liam Young
Run db migrations for neutron |
785 |
rel_settings = { |
786 |
'nova_url': canonical_url(CONFIGS, INTERNAL) + ":8774/v2" |
|
787 |
}
|
|
788 |
if remote_restart: |
|
789 |
rel_settings['restart_trigger'] = str(uuid.uuid4()) |
|
790 |
relation_set(relation_id=rid, **rel_settings) |
|
71.3.1
by liam.young at canonical
Added cell support |
791 |
|
78.2.4
by Liam Young
More unit tests and lint cleanup |
792 |
|
71.3.10
by Liam Young
Add neutron-api relation contexts |
793 |
@hooks.hook('neutron-api-relation-changed') |
83.1.9
by james.page at ubuntu
Disable service-guard by default |
794 |
@service_guard(guard_map(), CONFIGS, |
795 |
active=config('service-guard')) |
|
75.3.4
by Liam Young
Move NEUTRON_CONF out of the way which as the benefit of triggering a neutron restart on api relation break |
796 |
@restart_on_change(restart_map()) |
71.3.10
by Liam Young
Add neutron-api relation contexts |
797 |
def neutron_api_relation_changed(): |
798 |
CONFIGS.write(NOVA_CONF) |
|
75.3.5
by Liam Young
Pass through neutron settings from api server to compute host |
799 |
for rid in relation_ids('cloud-compute'): |
800 |
compute_joined(rid=rid) |
|
75.3.9
by Liam Young
Inform neutron gateway that the neutron api service has moved |
801 |
for rid in relation_ids('quantum-network-service'): |
802 |
quantum_joined(rid=rid) |
|
71.3.10
by Liam Young
Add neutron-api relation contexts |
803 |
|
78.2.4
by Liam Young
More unit tests and lint cleanup |
804 |
|
75.3.1
by Liam Young
Add support for joining charm to standalone neutron-api service |
805 |
@hooks.hook('neutron-api-relation-broken') |
83.1.9
by james.page at ubuntu
Disable service-guard by default |
806 |
@service_guard(guard_map(), CONFIGS, |
807 |
active=config('service-guard')) |
|
75.3.4
by Liam Young
Move NEUTRON_CONF out of the way which as the benefit of triggering a neutron restart on api relation break |
808 |
@restart_on_change(restart_map()) |
75.3.1
by Liam Young
Add support for joining charm to standalone neutron-api service |
809 |
def neutron_api_relation_broken(): |
810 |
if os.path.isfile('/etc/init/neutron-server.override'): |
|
811 |
os.remove('/etc/init/neutron-server.override') |
|
75.3.4
by Liam Young
Move NEUTRON_CONF out of the way which as the benefit of triggering a neutron restart on api relation break |
812 |
CONFIGS.write_all() |
75.3.10
by Liam Young
Send correct api info to quantum-gateway if neutron-api charm is being used |
813 |
for rid in relation_ids('cloud-compute'): |
814 |
compute_joined(rid=rid) |
|
815 |
for rid in relation_ids('quantum-network-service'): |
|
816 |
quantum_joined(rid=rid) |
|
52.2.1
by James Page
Update rabbitmq configuration to use common vhost |
817 |
|
78.2.4
by Liam Young
More unit tests and lint cleanup |
818 |
|
51.1.2
by Adam Gandelman
Check in start of py redux. |
819 |
def main(): |
820 |
try: |
|
821 |
hooks.execute(sys.argv) |
|
822 |
except UnregisteredHookError as e: |
|
823 |
log('Unknown hook {} - skipping.'.format(e)) |
|
824 |
||
825 |
||
826 |
if __name__ == '__main__': |
|
827 |
main() |