Add neutron-api relation contexts
This commit is contained in:
parent
5a0c37051a
commit
46ecc13154
@ -31,7 +31,7 @@ class NovaCellContext(context.OSContextGenerator):
|
||||
interfaces = ['nova-cell']
|
||||
|
||||
def __call__(self):
|
||||
log('Generating template context for identity-service')
|
||||
log('Generating template context for cell')
|
||||
ctxt = {}
|
||||
for rid in relation_ids('nova-cell'):
|
||||
for unit in related_units(rid):
|
||||
@ -44,6 +44,14 @@ class NovaCellContext(context.OSContextGenerator):
|
||||
return ctxt
|
||||
return {}
|
||||
|
||||
class NeutronAPIContext(context.OSContextGenerator):
|
||||
def __call__(self):
|
||||
log('Generating template context for neutron plugin')
|
||||
ctxt = {}
|
||||
for rid in relation_ids('neutron-api'):
|
||||
for unit in related_units(rid):
|
||||
ctxt = relation_get(rid=rid, unit=unit)
|
||||
return ctxt
|
||||
|
||||
class VolumeServiceContext(context.OSContextGenerator):
|
||||
interfaces = []
|
||||
@ -222,3 +230,4 @@ class NeutronPostgresqlDBContext(context.PostgresqlDBContext):
|
||||
def __init__(self):
|
||||
super(NeutronPostgresqlDBContext,
|
||||
self).__init__(config('neutron-database'))
|
||||
|
||||
|
@ -536,6 +536,11 @@ def nova_cell_relation_changed():
|
||||
relation_set(dbready=False)
|
||||
CONFIGS.write(NOVA_CONF)
|
||||
|
||||
@hooks.hook('neutron-api-relation-changed')
|
||||
def neutron_api_relation_changed():
|
||||
print "In neutron-api-relation-changed"
|
||||
CONFIGS.write(NOVA_CONF)
|
||||
|
||||
|
||||
def main():
|
||||
try:
|
||||
|
@ -33,6 +33,7 @@ from charmhelpers.core.hookenv import (
|
||||
relation_get,
|
||||
relation_ids,
|
||||
remote_unit,
|
||||
is_relation_made,
|
||||
INFO,
|
||||
ERROR,
|
||||
)
|
||||
@ -96,7 +97,6 @@ BASE_RESOURCE_MAP = OrderedDict([
|
||||
'contexts': [context.AMQPContext(ssl_dir=NOVA_CONF_DIR),
|
||||
context.SharedDBContext(
|
||||
relation_prefix='nova', ssl_dir=NOVA_CONF_DIR),
|
||||
nova_cc_context.NovaPostgresqlDBContext(),
|
||||
context.ImageServiceContext(),
|
||||
context.OSConfigFlagContext(),
|
||||
context.SubordinateConfigContext(
|
||||
@ -113,7 +113,6 @@ BASE_RESOURCE_MAP = OrderedDict([
|
||||
nova_cc_context.HAProxyContext(),
|
||||
nova_cc_context.IdentityServiceContext(),
|
||||
nova_cc_context.VolumeServiceContext(),
|
||||
nova_cc_context.NeutronCCContext(),
|
||||
nova_cc_context.NovaCellContext()],
|
||||
}),
|
||||
(NOVA_API_PASTE, {
|
||||
@ -195,40 +194,53 @@ def resource_map():
|
||||
|
||||
net_manager = network_manager()
|
||||
|
||||
# pop out irrelevant resources from the OrderedDict (easier than adding
|
||||
# them late)
|
||||
if net_manager != 'quantum':
|
||||
[resource_map.pop(k) for k in list(resource_map.iterkeys())
|
||||
if 'quantum' in k]
|
||||
if net_manager != 'neutron':
|
||||
[resource_map.pop(k) for k in list(resource_map.iterkeys())
|
||||
if 'neutron' in k]
|
||||
|
||||
if os.path.exists('/etc/apache2/conf-available'):
|
||||
resource_map.pop(APACHE_CONF)
|
||||
else:
|
||||
resource_map.pop(APACHE_24_CONF)
|
||||
|
||||
# add neutron plugin requirements. nova-c-c only needs the neutron-server
|
||||
# associated with configs, not the plugin agent.
|
||||
if net_manager in ['quantum', 'neutron']:
|
||||
plugin = neutron_plugin()
|
||||
if plugin:
|
||||
conf = neutron_plugin_attribute(plugin, 'config', net_manager)
|
||||
ctxts = (neutron_plugin_attribute(plugin, 'contexts', net_manager)
|
||||
or [])
|
||||
services = neutron_plugin_attribute(plugin, 'server_services',
|
||||
net_manager)
|
||||
resource_map[conf] = {}
|
||||
resource_map[conf]['services'] = services
|
||||
resource_map[conf]['contexts'] = ctxts
|
||||
resource_map[conf]['contexts'].append(
|
||||
nova_cc_context.NeutronCCContext())
|
||||
|
||||
# update for postgres
|
||||
resource_map[conf]['contexts'].append(
|
||||
nova_cc_context.NeutronPostgresqlDBContext())
|
||||
|
||||
if is_relation_made('neutron-api'):
|
||||
resource_map.pop(QUANTUM_CONF)
|
||||
resource_map.pop(QUANTUM_DEFAULT)
|
||||
resource_map.pop(NEUTRON_CONF)
|
||||
resource_map.pop(NEUTRON_DEFAULT)
|
||||
resource_map[NOVA_CONF]['contexts'].append(
|
||||
nova_cc_context.NeutronAPIContext())
|
||||
else:
|
||||
resource_map[NOVA_CONF]['contexts'].append(
|
||||
nova_cc_context.NeutronCCContext())
|
||||
resource_map[NOVA_CONF]['contexts'].append(
|
||||
nova_cc_context.NeutronPostgresqlDBContext())
|
||||
# pop out irrelevant resources from the OrderedDict (easier than adding
|
||||
# them late)
|
||||
if net_manager != 'quantum':
|
||||
[resource_map.pop(k) for k in list(resource_map.iterkeys())
|
||||
if 'quantum' in k]
|
||||
if net_manager != 'neutron':
|
||||
[resource_map.pop(k) for k in list(resource_map.iterkeys())
|
||||
if 'neutron' in k]
|
||||
|
||||
|
||||
# add neutron plugin requirements. nova-c-c only needs the neutron-server
|
||||
# associated with configs, not the plugin agent.
|
||||
if net_manager in ['quantum', 'neutron']:
|
||||
plugin = neutron_plugin()
|
||||
if plugin:
|
||||
conf = neutron_plugin_attribute(plugin, 'config', net_manager)
|
||||
ctxts = (neutron_plugin_attribute(plugin, 'contexts', net_manager)
|
||||
or [])
|
||||
services = neutron_plugin_attribute(plugin, 'server_services',
|
||||
net_manager)
|
||||
resource_map[conf] = {}
|
||||
resource_map[conf]['services'] = services
|
||||
resource_map[conf]['contexts'] = ctxts
|
||||
resource_map[conf]['contexts'].append(
|
||||
nova_cc_context.NeutronCCContext())
|
||||
|
||||
# update for postgres
|
||||
resource_map[conf]['contexts'].append(
|
||||
nova_cc_context.NeutronPostgresqlDBContext())
|
||||
|
||||
# nova-conductor for releases >= G.
|
||||
if os_release('nova-common') not in ['essex', 'folsom']:
|
||||
resource_map['/etc/nova/nova.conf']['services'] += ['nova-conductor']
|
||||
|
@ -32,6 +32,8 @@ requires:
|
||||
interface: quantum
|
||||
nova-cell:
|
||||
interface: nova-cell
|
||||
neutron-api:
|
||||
interface: neutron-api
|
||||
ha:
|
||||
interface: hacluster
|
||||
scope: container
|
||||
|
Loading…
x
Reference in New Issue
Block a user