Merge "Don't set administratively disabled ports as ACTIVE" into stable/pike

This commit is contained in:
Zuul 2018-07-03 18:51:55 +00:00 committed by Gerrit Code Review
commit 4b0d844ba1
2 changed files with 17 additions and 0 deletions

View File

@ -253,6 +253,10 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
LOG.debug("Port %s had new provisioning blocks added so it "
"will not transition to active.", port_id)
return
if not port.admin_state_up:
LOG.debug("Port %s is administratively disabled so it will "
"not transition to active.", port_id)
return
self.update_port_status(context, port_id, const.PORT_STATUS_ACTIVE)
@log_helpers.log_method_call

View File

@ -720,6 +720,19 @@ class TestMl2PortsV2(test_plugin.TestPortsV2, Ml2PluginV2TestCase):
self.assertIsNone(plugin._port_provisioned('port', 'evt', 'trigger',
self.context, port_id))
def test__port_provisioned_port_admin_state_down(self):
plugin = directory.get_plugin()
ups = mock.patch.object(plugin, 'update_port_status').start()
port_id = 'fake_port_id'
binding = mock.Mock(vif_type=portbindings.VIF_TYPE_OVS)
port = mock.Mock(
id=port_id, admin_state_up=False, port_binding=binding)
with mock.patch('neutron.plugins.ml2.plugin.db.get_port',
return_value=port):
plugin._port_provisioned('port', 'evt', 'trigger',
self.context, port_id)
self.assertFalse(ups.called)
def test_port_after_create_outside_transaction(self):
self.tx_open = True
receive = lambda *a, **k: setattr(self, 'tx_open',