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