Add in NovaCell context (should probably be in charmhelpers)
This commit is contained in:
parent
7dea84f81f
commit
de6341deac
@ -1,7 +1,7 @@
|
||||
|
||||
from charmhelpers.core.hookenv import (
|
||||
config, relation_ids, relation_set, log, ERROR,
|
||||
unit_get)
|
||||
unit_get, related_units, relation_get)
|
||||
|
||||
from charmhelpers.fetch import apt_install, filter_installed_packages
|
||||
from charmhelpers.contrib.openstack import context, neutron, utils
|
||||
@ -26,6 +26,23 @@ class ApacheSSLContext(context.ApacheSSLContext):
|
||||
self.external_ports = determine_ports()
|
||||
return super(ApacheSSLContext, self).__call__()
|
||||
|
||||
class NovaCellContext(context.OSContextGenerator):
|
||||
interfaces = ['nova-cell']
|
||||
|
||||
def __call__(self):
|
||||
log('Generating template context for identity-service')
|
||||
ctxt = {}
|
||||
for rid in relation_ids('nova-cell'):
|
||||
for unit in related_units(rid):
|
||||
rdata = relation_get(rid=rid, unit=unit)
|
||||
ctxt = {
|
||||
'cell_type': rdata.get('cell_type'),
|
||||
'cell_name': rdata.get('cell_name'),
|
||||
}
|
||||
if context.context_complete(ctxt):
|
||||
return ctxt
|
||||
return {}
|
||||
|
||||
|
||||
class VolumeServiceContext(context.OSContextGenerator):
|
||||
interfaces = []
|
||||
|
@ -508,7 +508,6 @@ def upgrade_charm():
|
||||
|
||||
@hooks.hook('nova-cell-relation-joined')
|
||||
def nova_cell_relation_joined(rid=None):
|
||||
print "nova_cell_relation_joined" + rid
|
||||
if is_relation_made('shared-db',['nova_password']):
|
||||
relation_set(relation_id=rid, dbready=True)
|
||||
else:
|
||||
@ -529,9 +528,6 @@ def nova_cell_relation_joined(rid=None):
|
||||
@hooks.hook('nova-cell-relation-changed')
|
||||
def nova_cell_relation_changed():
|
||||
CONFIGS.complete_contexts()
|
||||
print "bob"
|
||||
cellname = relation_get('cell_name')
|
||||
celltype = relation_get('cell_type')
|
||||
# XXX Can we trust this ? Does the presence of a password always imply db is setup? (probably not)
|
||||
if is_relation_made('shared-db',['nova_password']):
|
||||
relation_set(dbready=True)
|
||||
|
@ -113,7 +113,8 @@ BASE_RESOURCE_MAP = OrderedDict([
|
||||
nova_cc_context.HAProxyContext(),
|
||||
nova_cc_context.IdentityServiceContext(),
|
||||
nova_cc_context.VolumeServiceContext(),
|
||||
nova_cc_context.NeutronCCContext()],
|
||||
nova_cc_context.NeutronCCContext(),
|
||||
nova_cc_context.NovaCellContext()],
|
||||
}),
|
||||
(NOVA_API_PASTE, {
|
||||
'services': [s for s in BASE_SERVICES if 'api' in s],
|
||||
|
@ -128,3 +128,4 @@ admin_password = {{ admin_password }}
|
||||
[osapi_v3]
|
||||
enabled=True
|
||||
|
||||
{% include "parts/cell" %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user