Only reset dns_name when unbinding port if DNS is integrated
We only set the dns_name on the port if the "DNS Integration" extension is enabled, so we should only reset it on the port when unbinding if the extension is enabled, otherwise some Neutron stadium plugins will fail since they don't expect the 'dns_name' attribute to be on the port. Change-Id: I7451fbfad53236e9e147a0387dac45ae97f3e75b Closes-Bug: #1574565
This commit is contained in:
@@ -315,11 +315,12 @@ class API(base_api.NetworkAPI):
|
|||||||
# in case the caller forgot to filter the list.
|
# in case the caller forgot to filter the list.
|
||||||
if port_id is None:
|
if port_id is None:
|
||||||
continue
|
continue
|
||||||
port_req_body = {'port': {'device_id': '', 'device_owner': '',
|
port_req_body = {'port': {'device_id': '', 'device_owner': ''}}
|
||||||
'dns_name': ''}}
|
|
||||||
if port_binding:
|
if port_binding:
|
||||||
port_req_body['port']['binding:host_id'] = None
|
port_req_body['port']['binding:host_id'] = None
|
||||||
port_req_body['port']['binding:profile'] = {}
|
port_req_body['port']['binding:profile'] = {}
|
||||||
|
if constants.DNS_INTEGRATION in self.extensions:
|
||||||
|
port_req_body['port']['dns_name'] = ''
|
||||||
try:
|
try:
|
||||||
port_client.update_port(port_id, port_req_body)
|
port_client.update_port(port_id, port_req_body)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@@ -3548,7 +3548,7 @@ class TestNeutronv2WithMock(test.TestCase):
|
|||||||
api = neutronapi.API()
|
api = neutronapi.API()
|
||||||
api._unbind_ports(mock_ctx, ports, mock_client)
|
api._unbind_ports(mock_ctx, ports, mock_client)
|
||||||
|
|
||||||
body = {'port': {'device_id': '', 'device_owner': '', 'dns_name': ''}}
|
body = {'port': {'device_id': '', 'device_owner': ''}}
|
||||||
if has_ext:
|
if has_ext:
|
||||||
body['port']['binding:host_id'] = None
|
body['port']['binding:host_id'] = None
|
||||||
body['port']['binding:profile'] = {}
|
body['port']['binding:profile'] = {}
|
||||||
@@ -3828,6 +3828,20 @@ class TestNeutronv2WithMock(test.TestCase):
|
|||||||
self.api.get_floating_ips_by_project,
|
self.api.get_floating_ips_by_project,
|
||||||
self.context)
|
self.context)
|
||||||
|
|
||||||
|
def test_unbind_ports_reset_dns_name(self):
|
||||||
|
neutron = mock.Mock()
|
||||||
|
port_client = mock.Mock()
|
||||||
|
with mock.patch.object(self.api, '_has_port_binding_extension',
|
||||||
|
return_value=False):
|
||||||
|
self.api.extensions = [constants.DNS_INTEGRATION]
|
||||||
|
ports = [uuids.port_id]
|
||||||
|
self.api._unbind_ports(self.context, ports, neutron, port_client)
|
||||||
|
port_req_body = {'port': {'device_id': '',
|
||||||
|
'device_owner': '',
|
||||||
|
'dns_name': ''}}
|
||||||
|
port_client.update_port.assert_called_once_with(
|
||||||
|
uuids.port_id, port_req_body)
|
||||||
|
|
||||||
|
|
||||||
class TestNeutronv2ModuleMethods(test.NoDBTestCase):
|
class TestNeutronv2ModuleMethods(test.NoDBTestCase):
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user