Ensure that metadata agent packages are not uninstalled if dvr is enabled but local dhcp is not
This commit is contained in:
parent
c5a6bc3373
commit
f7c430f9d0
@ -2,6 +2,8 @@
|
||||
|
||||
import sys
|
||||
|
||||
from copy import deepcopy
|
||||
|
||||
from charmhelpers.contrib.openstack.utils import (
|
||||
config_value_changed,
|
||||
git_install_requested,
|
||||
@ -28,6 +30,7 @@ from charmhelpers.contrib.openstack.utils import (
|
||||
from neutron_ovs_utils import (
|
||||
DHCP_PACKAGES,
|
||||
DVR_PACKAGES,
|
||||
METADATA_PACKAGES,
|
||||
configure_ovs,
|
||||
git_install,
|
||||
get_topics,
|
||||
@ -89,7 +92,13 @@ def neutron_plugin_joined(relation_id=None):
|
||||
if enable_local_dhcp():
|
||||
install_packages()
|
||||
else:
|
||||
purge_packages(DHCP_PACKAGES)
|
||||
pkgs = deepcopy(DHCP_PACKAGES)
|
||||
# NOTE: only purge metadata packages if dvr is not
|
||||
# in use as this will remove the l3 agent
|
||||
# see https://pad.lv/1515008
|
||||
if not use_dvr():
|
||||
pkgs.extend(METADATA_PACKAGES)
|
||||
purge_packages(pkgs)
|
||||
secret = get_shared_secret() if enable_nova_metadata() else None
|
||||
rel_data = {
|
||||
'metadata-shared-secret': secret,
|
||||
|
@ -97,7 +97,8 @@ ML2_CONF = '%s/plugins/ml2/ml2_conf.ini' % NEUTRON_CONF_DIR
|
||||
EXT_PORT_CONF = '/etc/init/ext-port.conf'
|
||||
NEUTRON_METADATA_AGENT_CONF = "/etc/neutron/metadata_agent.ini"
|
||||
DVR_PACKAGES = ['neutron-l3-agent']
|
||||
DHCP_PACKAGES = ['neutron-metadata-agent', 'neutron-dhcp-agent']
|
||||
DHCP_PACKAGES = ['neutron-dhcp-agent']
|
||||
METADATA_PACKAGES = ['neutron-metadata-agent']
|
||||
PHY_NIC_MTU_CONF = '/etc/init/os-charm-phy-nic-mtu.conf'
|
||||
TEMPLATES = 'templates/'
|
||||
|
||||
@ -183,6 +184,7 @@ def determine_packages():
|
||||
pkgs.extend(DVR_PACKAGES)
|
||||
if enable_local_dhcp():
|
||||
pkgs.extend(DHCP_PACKAGES)
|
||||
pkgs.extend(METADATA_PACKAGES)
|
||||
|
||||
if git_install_requested():
|
||||
pkgs.extend(BASE_GIT_PACKAGES)
|
||||
|
@ -140,9 +140,10 @@ class NeutronOVSHooksTests(CharmTestCase):
|
||||
self.purge_packages.assert_called_with(['neutron-l3-agent'])
|
||||
|
||||
@patch.object(hooks, 'git_install_requested')
|
||||
def test_neutron_plugin_joined(self, git_requested):
|
||||
def test_neutron_plugin_joined_dvr_dhcp(self, git_requested):
|
||||
self.enable_nova_metadata.return_value = True
|
||||
self.enable_local_dhcp.return_value = True
|
||||
self.use_dvr.return_value = True
|
||||
git_requested.return_value = False
|
||||
self.get_shared_secret.return_value = 'secret'
|
||||
self._call_hook('neutron-plugin-relation-joined')
|
||||
@ -153,6 +154,44 @@ class NeutronOVSHooksTests(CharmTestCase):
|
||||
relation_id=None,
|
||||
**rel_data
|
||||
)
|
||||
self.assertTrue(self.install_packages.called)
|
||||
|
||||
@patch.object(hooks, 'git_install_requested')
|
||||
def test_neutron_plugin_joined_dvr_nodhcp(self, git_requested):
|
||||
self.enable_nova_metadata.return_value = True
|
||||
self.enable_local_dhcp.return_value = False
|
||||
self.use_dvr.return_value = True
|
||||
git_requested.return_value = False
|
||||
self.get_shared_secret.return_value = 'secret'
|
||||
self._call_hook('neutron-plugin-relation-joined')
|
||||
rel_data = {
|
||||
'metadata-shared-secret': 'secret',
|
||||
}
|
||||
self.relation_set.assert_called_with(
|
||||
relation_id=None,
|
||||
**rel_data
|
||||
)
|
||||
self.purge_packages.assert_called_with(['neutron-dhcp-agent'])
|
||||
self.assertFalse(self.install_packages.called)
|
||||
|
||||
@patch.object(hooks, 'git_install_requested')
|
||||
def test_neutron_plugin_joined_nodvr_nodhcp(self, git_requested):
|
||||
self.enable_nova_metadata.return_value = False
|
||||
self.enable_local_dhcp.return_value = False
|
||||
self.use_dvr.return_value = False
|
||||
git_requested.return_value = False
|
||||
self.get_shared_secret.return_value = 'secret'
|
||||
self._call_hook('neutron-plugin-relation-joined')
|
||||
rel_data = {
|
||||
'metadata-shared-secret': None,
|
||||
}
|
||||
self.relation_set.assert_called_with(
|
||||
relation_id=None,
|
||||
**rel_data
|
||||
)
|
||||
self.purge_packages.assert_called_with(['neutron-dhcp-agent',
|
||||
'neutron-metadata-agent'])
|
||||
self.assertFalse(self.install_packages.called)
|
||||
|
||||
def test_amqp_joined(self):
|
||||
self._call_hook('amqp-relation-joined')
|
||||
|
Loading…
Reference in New Issue
Block a user