diff --git a/neutron/plugins/ml2/drivers/macvtap/agent/macvtap_neutron_agent.py b/neutron/plugins/ml2/drivers/macvtap/agent/macvtap_neutron_agent.py index 41115f8d394..a14480e6cc8 100644 --- a/neutron/plugins/ml2/drivers/macvtap/agent/macvtap_neutron_agent.py +++ b/neutron/plugins/ml2/drivers/macvtap/agent/macvtap_neutron_agent.py @@ -173,6 +173,11 @@ class MacvtapManager(amb.CommonAgentManagerBase): def parse_interface_mappings(): + if not cfg.CONF.macvtap.physical_interface_mappings: + LOG.error(_LE("No physical_interface_mappings provided, but at least " + "one mapping is required. Agent terminated!")) + sys.exit(1) + try: interface_mappings = n_utils.parse_mappings( cfg.CONF.macvtap.physical_interface_mappings) diff --git a/neutron/tests/unit/plugins/ml2/drivers/macvtap/agent/test_macvtap_neutron_agent.py b/neutron/tests/unit/plugins/ml2/drivers/macvtap/agent/test_macvtap_neutron_agent.py index 0101b491889..b91857a0139 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/macvtap/agent/test_macvtap_neutron_agent.py +++ b/neutron/tests/unit/plugins/ml2/drivers/macvtap/agent/test_macvtap_neutron_agent.py @@ -191,6 +191,11 @@ class TestMacvtapMain(base.BaseTestCase): macvtap_neutron_agent.parse_interface_mappings() mock_exit.assert_called_with(1) + def test_parse_interface_mappings_no_mapping(self): + with mock.patch.object(sys, 'exit') as mock_exit: + macvtap_neutron_agent.parse_interface_mappings() + mock_exit.assert_called_with(1) + def test_validate_firewall_driver_noop_long(self): cfg.CONF.set_override('firewall_driver', 'neutron.agent.firewall.NoopFirewallDriver', diff --git a/releasenotes/notes/terminate-macvtap-agt-when-interface_mapping-not-present-3109faf3b44d366a.yaml b/releasenotes/notes/terminate-macvtap-agt-when-interface_mapping-not-present-3109faf3b44d366a.yaml new file mode 100644 index 00000000000..c912ea2cf3d --- /dev/null +++ b/releasenotes/notes/terminate-macvtap-agt-when-interface_mapping-not-present-3109faf3b44d366a.yaml @@ -0,0 +1,6 @@ +--- +upgrade: + - After upgrade, a macvtap agent without + physical_interface_mappings configured can not + be started. Specify a valid mapping to be able + to start and use the macvtap agent.