diff --git a/hooks/amqp-relation-broken b/hooks/amqp-relation-broken deleted file mode 120000 index 55aa8e52..00000000 --- a/hooks/amqp-relation-broken +++ /dev/null @@ -1 +0,0 @@ -neutron_ovs_hooks.py \ No newline at end of file diff --git a/hooks/amqp-relation-changed b/hooks/amqp-relation-changed deleted file mode 120000 index 55aa8e52..00000000 --- a/hooks/amqp-relation-changed +++ /dev/null @@ -1 +0,0 @@ -neutron_ovs_hooks.py \ No newline at end of file diff --git a/hooks/amqp-relation-departed b/hooks/amqp-relation-departed deleted file mode 120000 index 55aa8e52..00000000 --- a/hooks/amqp-relation-departed +++ /dev/null @@ -1 +0,0 @@ -neutron_ovs_hooks.py \ No newline at end of file diff --git a/hooks/amqp-relation-joined b/hooks/amqp-relation-joined deleted file mode 120000 index 55aa8e52..00000000 --- a/hooks/amqp-relation-joined +++ /dev/null @@ -1 +0,0 @@ -neutron_ovs_hooks.py \ No newline at end of file diff --git a/hooks/neutron_ovs_context.py b/hooks/neutron_ovs_context.py index acecab25..a294a82c 100644 --- a/hooks/neutron_ovs_context.py +++ b/hooks/neutron_ovs_context.py @@ -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(): ''' diff --git a/hooks/neutron_ovs_hooks.py b/hooks/neutron_ovs_hooks.py index 913e2c49..26c43e66 100755 --- a/hooks/neutron_ovs_hooks.py +++ b/hooks/neutron_ovs_hooks.py @@ -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) diff --git a/hooks/neutron_ovs_utils.py b/hooks/neutron_ovs_utils.py index e626066e..c5129068 100644 --- a/hooks/neutron_ovs_utils.py +++ b/hooks/neutron_ovs_utils.py @@ -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(): diff --git a/metadata.yaml b/metadata.yaml index 8d09b884..afdac68f 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -11,8 +11,6 @@ provides: interface: neutron-plugin scope: container requires: - amqp: - interface: rabbitmq container: interface: juju-info scope: container