[gnuoy,r=james-page] Add support for separate management of neutron openvswitch configuration via subordinate.

This commit is contained in:
james.page@ubuntu.com 2014-06-24 14:44:41 +01:00
commit e13997f500
8 changed files with 34 additions and 10 deletions

View File

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

View File

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

View File

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

View File

@ -15,7 +15,6 @@ from charmhelpers.core.hookenv import (
unit_get,
UnregisteredHookError,
)
from charmhelpers.core.host import (
restart_on_change,
)
@ -33,7 +32,6 @@ from charmhelpers.contrib.openstack.utils import (
from charmhelpers.contrib.storage.linux.ceph import ensure_ceph_keyring
from charmhelpers.payload.execd import execd_preinstall
from nova_compute_utils import (
create_libvirt_secret,
determine_packages,
@ -51,7 +49,7 @@ from nova_compute_utils import (
QUANTUM_CONF, NEUTRON_CONF,
ceph_config_file, CEPH_SECRET,
enable_shell, disable_shell,
fix_path_ownership
fix_path_ownership,
)
from nova_compute_context import CEPH_SECRET_UUID
@ -111,11 +109,12 @@ def amqp_changed():
log('amqp relation incomplete. Peer not ready?')
return
CONFIGS.write(NOVA_CONF)
if network_manager() == 'quantum' and neutron_plugin() == 'ovs':
CONFIGS.write(QUANTUM_CONF)
if network_manager() == 'neutron' and neutron_plugin() == 'ovs':
CONFIGS.write(NEUTRON_CONF)
# No need to write NEUTRON_CONF if neutron-plugin is managing it
if not relation_ids('neutron-plugin'):
if network_manager() == 'quantum' and neutron_plugin() == 'ovs':
CONFIGS.write(QUANTUM_CONF)
if network_manager() == 'neutron' and neutron_plugin() == 'ovs':
CONFIGS.write(NEUTRON_CONF)
@hooks.hook('shared-db-relation-joined')

View File

@ -14,7 +14,7 @@ from charmhelpers.core.hookenv import (
relation_ids,
relation_get,
DEBUG,
service_name
service_name,
)
from charmhelpers.contrib.openstack.neutron import neutron_plugin_attribute
@ -152,7 +152,8 @@ def resource_map():
# Neutron/quantum requires additional contexts, as well as new resources
# depending on the plugin used.
# NOTE(james-page): only required for ovs plugin right now
if net_manager in ['neutron', 'quantum']:
if (net_manager in ['neutron', 'quantum'] and not
relation_ids('neutron-plugin')):
if plugin == 'ovs':
if net_manager == 'quantum':
nm_rsc = QUANTUM_RESOURCES

View File

@ -27,6 +27,9 @@ requires:
nova-ceilometer:
interface: nova-ceilometer
scope: container
neutron-plugin:
interface: neutron-plugin
scope: container
peers:
compute-peer:
interface: nova

View File

@ -173,11 +173,19 @@ class NovaComputeRelationsTests(CharmTestCase):
@patch.object(hooks, 'CONFIGS')
def test_amqp_changed_with_data_and_quantum(self, configs):
self.relation_ids.return_value = []
self._amqp_test(configs, quantum=True)
self.assertEquals([call('/etc/nova/nova.conf'),
call('/etc/quantum/quantum.conf')],
configs.write.call_args_list)
@patch.object(hooks, 'CONFIGS')
def test_amqp_changed_with_data_and_quantum_api(self, configs):
self.relation_ids.return_value = ['neutron-plugin:0']
self._amqp_test(configs, quantum=True)
self.assertEquals([call('/etc/nova/nova.conf')],
configs.write.call_args_list)
def test_db_joined(self):
self.unit_get.return_value = 'nova.foohost.com'
self.is_relation_made.return_value = False

View File

@ -155,6 +155,16 @@ class NovaComputeUtilsTests(CharmTestCase):
self.assertEquals(ex, result)
@patch.object(utils, 'neutron_plugin')
@patch.object(utils, 'network_manager')
def test_resource_map_neutron_ovs_plugin(self, net_man, _plugin):
self.skipTest('skipped until contexts are properly mocked.')
self.is_relation_made = True
net_man.return_value = 'Neutron'
_plugin.return_value = 'ovs'
result = utils.resource_map()
self.assertTrue('/etc/neutron/neutron.conf' not in result)
def fake_user(self, username='foo'):
user = MagicMock()
user.pw_dir = '/home/' + username