Merge "Skip PortNotFound when unbinding port"

This commit is contained in:
Jenkins 2017-03-30 13:29:23 +00:00 committed by Gerrit Code Review
commit fb76658318
3 changed files with 23 additions and 0 deletions

View File

@ -88,6 +88,9 @@ def unbind_neutron_port(port_id, client=None):
try: try:
client.update_port(port_id, body) client.update_port(port_id, body)
# NOTE(vsaienko): Ignore if port was deleted before calling vif detach.
except neutron_exceptions.PortNotFoundClient:
LOG.info('Port %s was not found while unbinding.', port_id)
except neutron_exceptions.NeutronClientException as e: except neutron_exceptions.NeutronClientException as e:
msg = (_('Unable to clear binding profile for ' msg = (_('Unable to clear binding profile for '
'neutron port %(port_id)s. Error: ' 'neutron port %(port_id)s. Error: '

View File

@ -686,3 +686,21 @@ class TestUnbindPort(base.TestCase):
mock_client.assert_called_once_with() mock_client.assert_called_once_with()
mock_client.return_value.update_port.assert_called_once_with(port_id, mock_client.return_value.update_port.assert_called_once_with(port_id,
body) body)
@mock.patch.object(neutron, 'LOG')
def test_unbind_neutron_port_not_found(self, mock_log, mock_client):
port_id = 'fake-port-id'
mock_client.return_value.update_port.side_effect = (
neutron_client_exc.PortNotFoundClient())
body = {
'port': {
'binding:host_id': '',
'binding:profile': {}
}
}
neutron.unbind_neutron_port(port_id)
mock_client.assert_called_once_with()
mock_client.return_value.update_port.assert_called_once_with(port_id,
body)
mock_log.info.assert_called_once_with('Port %s was not found while '
'unbinding.', port_id)

View File

@ -330,6 +330,8 @@ class BaremetalStandaloneScenarioTest(BaremetalStandaloneManager):
def resource_cleanup(cls): def resource_cleanup(cls):
cls.cleanup_floating_ip(cls.node_ip) cls.cleanup_floating_ip(cls.node_ip)
vifs = cls.get_node_vifs(cls.node['uuid']) vifs = cls.get_node_vifs(cls.node['uuid'])
# Remove ports before deleting node, to catch regression for cases
# when user did this prior unprovision node.
for vif in vifs: for vif in vifs:
cls.ports_client.delete_port(vif) cls.ports_client.delete_port(vif)
cls.terminate_node(cls.node['uuid']) cls.terminate_node(cls.node['uuid'])