Fix KeyError exception while updating dhcp port
This is caused by a missing network_id in the port body. This patch adds it so that a warning message can be traced correctly. Wording is slightly tweaked to ensure it applies to the right context. Closes-bug: #1324194 Change-Id: I4b67b5c3584aa33278eb0e9e879ca338ba0ca8b0
This commit is contained in:
parent
f7654c3b4c
commit
ab50ba6e70
@ -767,7 +767,8 @@ class DeviceManager(object):
|
||||
port_fixed_ips.extend(
|
||||
[dict(subnet_id=s) for s in dhcp_enabled_subnet_ids])
|
||||
dhcp_port = self.plugin.update_dhcp_port(
|
||||
port.id, {'port': {'fixed_ips': port_fixed_ips}})
|
||||
port.id, {'port': {'network_id': network.id,
|
||||
'fixed_ips': port_fixed_ips}})
|
||||
if not dhcp_port:
|
||||
raise exceptions.Conflict()
|
||||
else:
|
||||
@ -784,7 +785,8 @@ class DeviceManager(object):
|
||||
port_device_id = getattr(port, 'device_id', None)
|
||||
if port_device_id == constants.DEVICE_ID_RESERVED_DHCP_PORT:
|
||||
dhcp_port = self.plugin.update_dhcp_port(
|
||||
port.id, {'port': {'device_id': device_id}})
|
||||
port.id, {'port': {'network_id': network.id,
|
||||
'device_id': device_id}})
|
||||
if dhcp_port:
|
||||
break
|
||||
|
||||
|
@ -71,9 +71,10 @@ class DhcpRpcCallbackMixin(object):
|
||||
pass
|
||||
else:
|
||||
ctxt.reraise = True
|
||||
network_id = port['port']['network_id']
|
||||
LOG.warn(_("Port for network %(net_id)s could not be created: "
|
||||
"%(reason)s") % {"net_id": network_id, 'reason': e})
|
||||
net_id = port['port']['network_id']
|
||||
LOG.warn(_("Action %(action)s for network %(net_id)s "
|
||||
"could not complete successfully: %(reason)s")
|
||||
% {"action": action, "net_id": net_id, 'reason': e})
|
||||
|
||||
def get_active_networks(self, context, **kwargs):
|
||||
"""Retrieve and return a list of the active network ids."""
|
||||
|
@ -1180,6 +1180,7 @@ class TestDeviceManager(base.BaseTestCase):
|
||||
plugin.update_dhcp_port.return_value = fake_network.ports[0]
|
||||
dh.setup_dhcp_port(fake_network_copy)
|
||||
port_body = {'port': {
|
||||
'network_id': fake_network.id,
|
||||
'fixed_ips': [{'subnet_id': fake_fixed_ip1.subnet_id,
|
||||
'ip_address': fake_fixed_ip1.ip_address},
|
||||
{'subnet_id': fake_subnet2.id}]}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user