Cede control of neutron.conf to principle

This commit is contained in:
Liam Young 2014-06-09 10:37:59 +00:00
parent 03f35297a6
commit 7f8bb200a9
8 changed files with 21 additions and 63 deletions

View File

@ -1 +0,0 @@
neutron_ovs_hooks.py

View File

@ -1 +0,0 @@
neutron_ovs_hooks.py

View File

@ -1 +0,0 @@
neutron_ovs_hooks.py

View File

@ -1 +0,0 @@
neutron_ovs_hooks.py

View File

@ -16,33 +16,6 @@ OVS_BRIDGE = 'br-int'
class OSContextError(Exception):
pass
class NovaComputeAMQPContext(context.OSContextGenerator):
def __call__(self):
conf = config()
try:
username = conf['rabbit-user']
vhost = conf['rabbit-vhost']
except KeyError as e:
log('Could not generate shared_db context. '
'Missing required charm config options: %s.' % e)
raise OSContextError
ctxt = {}
for rid in relation_ids('neutron-plugin'):
for unit in related_units(rid):
if relation_get('clustered', rid=rid, unit=unit):
ctxt['clustered'] = True
ctxt['rabbitmq_host'] = relation_get('vip', rid=rid,
unit=unit)
else:
ctxt['rabbitmq_host'] = relation_get('private-address',
rid=rid, unit=unit)
ctxt.update({
'rabbitmq_user': username,
'rabbitmq_password': relation_get('rabbitmq_password', rid=rid,
unit=unit),
'rabbitmq_virtual_host': vhost,
})
return ctxt
def _neutron_security_groups():
'''

View File

@ -1,11 +1,11 @@
#!/usr/bin/python
import sys
import json
from charmhelpers.core.hookenv import (
Hooks,
UnregisteredHookError,
config,
log,
relation_set,
)
@ -22,7 +22,7 @@ from neutron_ovs_utils import (
determine_packages,
register_configs,
restart_map,
NEUTRON_CONF,
NEUTRON_SETTINGS,
)
hooks = Hooks()
@ -39,27 +39,16 @@ def install():
def config_changed():
CONFIGS.write_all()
@hooks.hook('neutron-plugin-relation-joined')
def neutron_plugin_relation_joined():
#relation_set(core_plugin='LYneutron.plugins.ml2.plugin.Ml2Plugin')
relation_set(subordinate_configuration=json.dumps(NEUTRON_SETTINGS))
@restart_on_change(restart_map())
@hooks.hook('neutron-plugin-relation-changed')
def neutron_plugin_relation_changed():
CONFIGS.write_all()
@hooks.hook('amqp-relation-joined')
def amqp_joined(relation_id=None):
relation_set(relation_id=relation_id,
username=config('rabbit-user'),
vhost=config('rabbit-vhost'))
@hooks.hook('amqp-relation-changed')
@hooks.hook('amqp-relation-departed')
@restart_on_change(restart_map())
def amqp_changed():
if 'amqp' not in CONFIGS.complete_contexts():
log('amqp relation incomplete. Peer not ready?')
return
CONFIGS.write(NEUTRON_CONF)
def main():
try:
hooks.execute(sys.argv)

View File

@ -1,25 +1,19 @@
from charmhelpers.contrib.openstack.neutron import neutron_plugin_attribute
from copy import deepcopy
from charmhelpers.contrib.openstack import context, templating
from charmhelpers.contrib.openstack import templating
from collections import OrderedDict
from charmhelpers.contrib.openstack.utils import (
os_release,
)
import neutron_ovs_context
from charmhelpers.core.hookenv import is_relation_made
NOVA_CONF_DIR = "/etc/nova"
NEUTRON_CONF_DIR = "/etc/neutron"
NEUTRON_CONF = '%s/neutron.conf' % NEUTRON_CONF_DIR
NEUTRON_DEFAULT = '/etc/default/neutron-server'
NEUTRON_CONF = "%s/neutron.conf" % NEUTRON_CONF_DIR
ML2_CONF = '%s/plugins/ml2/ml2_conf.ini' % NEUTRON_CONF_DIR
BASE_RESOURCE_MAP = OrderedDict([
(NEUTRON_CONF, {
'services': ['neutron-plugin-openvswitch-agent'],
'contexts': [neutron_ovs_context.OVSPluginContext()],
}),
(ML2_CONF, {
'services': ['neutron-plugin-openvswitch-agent'],
'contexts': [neutron_ovs_context.OVSPluginContext()],
@ -27,6 +21,18 @@ BASE_RESOURCE_MAP = OrderedDict([
])
TEMPLATES = 'templates/'
NEUTRON_SETTINGS = {
"neutron": {
NEUTRON_CONF: {
"sections": {
"DEFAULT": [
('core_plugin', 'LYneutron.plugins.ml2.plugin.Ml2Plugin'),
]
}
}
}
}
def determine_packages():
ovs_pkgs = []
pkgs = neutron_plugin_attribute('ovs', 'packages',
@ -50,10 +56,6 @@ def resource_map():
hook execution.
'''
resource_map = deepcopy(BASE_RESOURCE_MAP)
if is_relation_made('amqp'):
resource_map[NEUTRON_CONF]['contexts'].append(context.AMQPContext())
else:
resource_map[NEUTRON_CONF]['contexts'].append(neutron_ovs_context.NovaComputeAMQPContext())
return resource_map
def restart_map():

View File

@ -11,8 +11,6 @@ provides:
interface: neutron-plugin
scope: container
requires:
amqp:
interface: rabbitmq
container:
interface: juju-info
scope: container