Restore management of neutron.conf to plugin

This commit is contained in:
Liam Young 2014-06-11 09:44:51 +00:00
parent 2440166014
commit c8e783883f
12 changed files with 75 additions and 71 deletions

View File

@ -1,6 +1,6 @@
options:
rabbit-user:
default: nova
default: neutron
type: string
description: Username used to access rabbitmq queue
rabbit-vhost:

1
hooks/amqp-relation-broken Symbolic link
View File

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

1
hooks/amqp-relation-changed Symbolic link
View File

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

View File

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

1
hooks/amqp-relation-joined Symbolic link
View File

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

View File

@ -487,10 +487,6 @@ class NeutronContext(OSContextGenerator):
def plugin(self):
return None
@property
def save_nova_flag(self):
return True
@property
def network_manager(self):
return None
@ -582,8 +578,7 @@ class NeutronContext(OSContextGenerator):
flags = config_flags_parser(alchemy_flags)
ctxt['neutron_alchemy_flags'] = flags
if self.save_nova_flag:
self._save_flag_file()
self._save_flag_file()
return ctxt

View File

@ -38,10 +38,6 @@ class OVSPluginContext(context.NeutronContext):
def network_manager(self):
return 'neutron'
@property
def save_nova_flag(self):
return False
@property
def neutron_security_groups(self):
return _neutron_security_groups()

View File

@ -1,14 +1,13 @@
#!/usr/bin/python
import uuid
import sys
import json
from charmhelpers.core.hookenv import (
Hooks,
UnregisteredHookError,
config,
log,
relation_set,
relation_ids,
)
from charmhelpers.core.host import (
@ -23,7 +22,7 @@ from neutron_ovs_utils import (
determine_packages,
register_configs,
restart_map,
NEUTRON_SETTINGS,
NEUTRON_CONF,
)
hooks = Hooks()
@ -35,33 +34,31 @@ def install():
apt_update()
apt_install(determine_packages(), fatal=True)
@hooks.hook('config-changed')
@restart_on_change(restart_map())
@hooks.hook('config-changed')
def config_changed():
CONFIGS.write_all()
[neutron_plugin_relation_joined(rid) for rid in relation_ids('neutron-plugin')]
@hooks.hook('neutron-plugin-relation-joined')
def neutron_plugin_relation_joined(remote_restart=True):
if remote_restart:
comment = ('restart', 'Restart Trigger: ' + str(uuid.uuid4()))
for conf in NEUTRON_SETTINGS['neutron']:
if 'sections' in NEUTRON_SETTINGS['neutron'][conf] and \
'COMMENT' in NEUTRON_SETTINGS['neutron'][conf]['sections']:
NEUTRON_SETTINGS['neutron'][conf]['sections']['COMMENT'].append(comment)
relation_set(subordinate_configuration=json.dumps(NEUTRON_SETTINGS))
@hooks.hook('neutron-plugin-relation-changed')
@restart_on_change(restart_map())
def neutron_plugin_relation_changed(remote_restart=True):
@hooks.hook('neutron-plugin-relation-changed')
def neutron_plugin_relation_changed():
CONFIGS.write_all()
if remote_restart:
comment = ('restart', 'Restart Trigger: ' + str(uuid.uuid4()))
for conf in NEUTRON_SETTINGS['neutron']:
if 'sections' in NEUTRON_SETTINGS['neutron'][conf] and \
'COMMENT' in NEUTRON_SETTINGS['neutron'][conf]['sections']:
NEUTRON_SETTINGS['neutron'][conf]['sections']['COMMENT'].append(comment)
relation_set(subordinate_configuration=json.dumps(NEUTRON_SETTINGS))
@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:

View File

@ -1,55 +1,32 @@
from charmhelpers.contrib.openstack.neutron import neutron_plugin_attribute
from copy import deepcopy
from charmhelpers.contrib.openstack import templating
from charmhelpers.contrib.openstack import context, 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
ML2_CONF = '%s/plugins/ml2/ml2_conf.ini' % NEUTRON_CONF_DIR
NEUTRON_CONF = '%s/neutron.conf' % NEUTRON_CONF_DIR
NEUTRON_DEFAULT = '/etc/default/neutron-server'
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(),
context.AMQPContext()],
}),
(ML2_CONF, {
'services': ['neutron-plugin-openvswitch-agent'],
'contexts': [neutron_ovs_context.OVSPluginContext()],
}),
])
TEMPLATES = 'templates/'
NEUTRON_SERVICE_PLUGINS=['neutron.services.l3_router.l3_router_plugin.L3RouterPlugin',
'neutron.services.firewall.fwaas_plugin.FirewallPlugin',
'neutron.services.loadbalancer.plugin.LoadBalancerPlugin',
'neutron.services.vpn.plugin.VPNDriverPlugin',
'neutron.services.metering.metering_plugin.MeteringPlugin']
NEUTRON_SETTINGS = {
"neutron": {
NEUTRON_CONF: {
"sections": {
"DEFAULT": [
('core_plugin', 'neutron.plugins.ml2.plugin.Ml2Plugin'),
('service_plugins', ','.join(NEUTRON_SERVICE_PLUGINS)),
],
"COMMENT": [
('comment1', 'Warning: some settings controlled by subordinate neutron-openvswitch'),
]
}
},
NEUTRON_DEFAULT: {
"sections": {
"DEFAULT": [
('NEUTRON_PLUGIN_CONFIG', ML2_CONF),
],
"COMMENT": [
('comment1', 'Warning: some settings controlled by subordinate neutron-openvswitch'),
]
}
}
}
}
def determine_packages():
ovs_pkgs = []
@ -61,7 +38,7 @@ def determine_packages():
return set(ovs_pkgs)
def register_configs(release=None):
release = release or os_release('neutron-common')
release = release or os_release('nova-common')
configs = templating.OSConfigRenderer(templates_dir=TEMPLATES,
openstack_release=release)
for cfg, rscs in resource_map().iteritems():

View File

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

View File

@ -0,0 +1,34 @@
# grizzly
###############################################################################
# [ WARNING ]
# Configuration file maintained by Juju. Local changes may be overwritten.
###############################################################################
[DEFAULT]
state_path = /var/lib/neutron
lock_path = $state_path/lock
bind_host = 0.0.0.0
bind_port = 9696
{% if core_plugin -%}
core_plugin = {{ core_plugin }}
{% endif -%}
api_paste_config = /etc/neutron/api-paste.ini
auth_strategy = keystone
notification_driver = neutron.openstack.common.notifier.rpc_notifier
use_syslog = {{ use_syslog }}
default_notification_level = INFO
notification_topics = notifications
{% include "parts/rabbitmq" %}
[QUOTAS]
[DEFAULT_SERVICETYPE]
[AGENT]
root_helper = sudo neutron-rootwrap /etc/neutron/rootwrap.conf
[keystone_authtoken]
signing_dir = /var/lib/neutron/keystone-signing

View File

@ -2,7 +2,6 @@
###############################################################################
# [ WARNING ]
# Configuration file maintained by Juju. Local changes may be overwritten.
# Config from neutron-openvswitch plugin
###############################################################################
[ml2]
type_drivers = gre,vxlan