Updates for NVP support

This commit is contained in:
James Page 2013-10-16 10:26:17 +01:00
parent 812fafd5b7
commit 1fef31d0b8
3 changed files with 36 additions and 6 deletions

View File

@ -105,7 +105,8 @@ def db_joined(rid=None):
nova_database=config('database'),
nova_username=config('database-user'),
nova_hostname=unit_get('private-address'))
if network_manager() in ['quantum', 'neutron']:
if (network_manager() in ['quantum', 'neutron']
and neutron_plugin() == 'ovs'):
# XXX: Renaming relations from quantum_* to neutron_* here.
relation_set(relation_id=rid,
neutron_database=config('neutron-database'),
@ -121,8 +122,8 @@ def db_changed():
return
CONFIGS.write(NOVA_CONF)
nm = network_manager()
if nm in ['quantum', 'neutron']:
plugin = neutron_plugin()
plugin = neutron_plugin()
if nm in ['quantum', 'neutron'] and plugin == 'ovs':
CONFIGS.write(neutron_plugin_attribute(plugin, 'config', nm))
@ -156,7 +157,8 @@ def compute_changed():
CONFIGS.write_all()
import_authorized_keys()
import_keystone_ca_cert()
if network_manager() in ['quantum', 'neutron']:
if (network_manager() in ['quantum', 'neutron']
and neutron_plugin() == 'ovs'):
# in case we already have a database relation, need to request
# access to the additional neutron database.
[db_joined(rid) for rid in relation_ids('shared-db')]

View File

@ -52,6 +52,8 @@ firewall_driver = nova.virt.firewall.NoopFirewallDriver
{% if neutron_plugin and neutron_plugin == 'nvp' -%}
libvirt_vif_driver = nova.virt.libvirt.vif.LibvirtOpenVswitchVirtualPortDriver
security_group_api = neutron
firewall_driver = nova.virt.firewall.NoopFirewallDriver
{% endif -%}
{% if network_manager_config -%}

View File

@ -146,9 +146,10 @@ class NovaComputeRelationsTests(CharmTestCase):
nova_hostname='nova.foohost.com')
self.unit_get.assert_called_with('private-address')
def test_db_joined_quantum(self):
def test_db_joined_quantum_ovs(self):
self.unit_get.return_value = 'nova.foohost.com'
self.network_manager.return_value = 'quantum'
self.neutron_plugin.return_value = 'ovs'
hooks.db_joined(rid='shared-db:0')
calls = [call(nova_database='nova',
nova_username='nova',
@ -162,6 +163,21 @@ class NovaComputeRelationsTests(CharmTestCase):
for c in calls]
self.unit_get.assert_called_with('private-address')
def test_db_joined_quantum_nvp(self):
self.unit_get.return_value = 'nova.foohost.com'
self.network_manager.return_value = 'quantum'
self.neutron_plugin.return_value = 'nvp'
hooks.db_joined(rid='shared-db:0')
calls = [call(nova_database='nova',
nova_username='nova',
nova_hostname='nova.foohost.com',
relation_id='shared-db:0')]
# NVP plugin requires no DB access - check it was not
# requested
[self.assertIn(c, self.relation_set.call_args_list)
for c in calls]
self.unit_get.assert_called_with('private-address')
@patch.object(hooks, 'CONFIGS')
def test_db_changed_missing_relation_data(self, configs):
configs.complete_contexts = MagicMock()
@ -186,12 +202,22 @@ class NovaComputeRelationsTests(CharmTestCase):
configs.write.call_args_list)
@patch.object(hooks, 'CONFIGS')
def test_db_changed_with_data_and_quantum(self, configs):
def test_db_changed_with_data_and_quantum_ovs(self, configs):
self.neutron_plugin_attribute.return_value = '/etc/quantum/plugin.conf'
self.neutron_plugin.return_value = 'ovs'
self._shared_db_test(configs, quantum=True)
ex = [call('/etc/nova/nova.conf'), call('/etc/quantum/plugin.conf')]
self.assertEquals(ex, configs.write.call_args_list)
@patch.object(hooks, 'CONFIGS')
def test_db_changed_with_data_and_quantum_nvp(self, configs):
self.neutron_plugin_attribute.return_value = '/etc/quantum/plugin.conf'
self.neutron_plugin.return_value = 'nvp'
self._shared_db_test(configs, quantum=True)
ex = [call('/etc/nova/nova.conf')]
# NVP has no compute agent for neutron; check no config files generated
self.assertEquals(ex, configs.write.call_args_list)
@patch.object(hooks, 'CONFIGS')
def test_image_service_missing_relation_data(self, configs):
configs.complete_contexts = MagicMock()