From de6341deac3854a877a48a80ea65ea5415500e85 Mon Sep 17 00:00:00 2001 From: Liam Young Date: Fri, 2 May 2014 15:25:11 +0000 Subject: [PATCH] Add in NovaCell context (should probably be in charmhelpers) --- hooks/nova_cc_context.py | 19 ++++++++++++++++++- hooks/nova_cc_hooks.py | 4 ---- hooks/nova_cc_utils.py | 3 ++- templates/icehouse/nova.conf | 1 + 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/hooks/nova_cc_context.py b/hooks/nova_cc_context.py index e844ad20..fd135965 100644 --- a/hooks/nova_cc_context.py +++ b/hooks/nova_cc_context.py @@ -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 = [] diff --git a/hooks/nova_cc_hooks.py b/hooks/nova_cc_hooks.py index 12064aa2..8324c781 100755 --- a/hooks/nova_cc_hooks.py +++ b/hooks/nova_cc_hooks.py @@ -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) diff --git a/hooks/nova_cc_utils.py b/hooks/nova_cc_utils.py index e6cb0945..9a2dd862 100644 --- a/hooks/nova_cc_utils.py +++ b/hooks/nova_cc_utils.py @@ -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], diff --git a/templates/icehouse/nova.conf b/templates/icehouse/nova.conf index 67e54f54..773ee140 100644 --- a/templates/icehouse/nova.conf +++ b/templates/icehouse/nova.conf @@ -128,3 +128,4 @@ admin_password = {{ admin_password }} [osapi_v3] enabled=True +{% include "parts/cell" %}