Only clear dns_name when user specifies parameter

Previously dns_name would be set to empty string as long as the
dns-integration extension was enabled and the user didn't specify a
different value. This meant that dns_name would be cleared even if the
user didn't pass it as a parameter at all. This patch only clears
dns_name if the user passed that parameter without specifying a value.

Change-Id: I1be9a2f9c3dc9850cc167b204506e36d5272d642
Closes-Bug: 1554153
This commit is contained in:
James Anziano 2016-03-07 19:42:47 +00:00
parent 4f04102e57
commit 58e9102bff
2 changed files with 1 additions and 6 deletions
neutron
db
tests/unit/extensions

@ -1285,7 +1285,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
original_ips = self._make_fixed_ip_dict(port['fixed_ips'])
original_dns_name = port.get('dns_name', '')
request_dns_name = self._get_request_dns_name(new_port)
if not request_dns_name:
if 'dns_name' in new_port and not request_dns_name:
new_port['dns_name'] = ''
new_mac = new_port.get('mac_address')
self._validate_port_for_update(context, port, new_port, new_mac)

@ -33,7 +33,6 @@ from neutron.callbacks import registry
from neutron.callbacks import resources
from neutron.common import constants as l3_constants
from neutron.common import exceptions as n_exc
from neutron.common import utils
from neutron import context
from neutron.db import common_db_mixin
from neutron.db import db_base_plugin_v2
@ -44,7 +43,6 @@ from neutron.db import l3_attrs_db
from neutron.db import l3_db
from neutron.db import l3_dvr_db
from neutron.db import l3_dvrscheduler_db
from neutron.extensions import dns
from neutron.extensions import external_net
from neutron.extensions import l3
from neutron.extensions import portbindings
@ -1204,9 +1202,6 @@ class L3NatTestCaseBase(L3NatTestCaseMixin):
expected_port_update = {
'device_owner': l3_constants.DEVICE_OWNER_ROUTER_INTF,
'device_id': r['router']['id']}
plugin = manager.NeutronManager.get_plugin()
if utils.is_extension_supported(plugin, dns.Dns.get_alias()):
expected_port_update['dns_name'] = ''
update_port.assert_called_with(
mock.ANY, p['port']['id'], {'port': expected_port_update})
# fetch port and confirm device_id