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(
|
port_fixed_ips.extend(
|
||||||
[dict(subnet_id=s) for s in dhcp_enabled_subnet_ids])
|
[dict(subnet_id=s) for s in dhcp_enabled_subnet_ids])
|
||||||
dhcp_port = self.plugin.update_dhcp_port(
|
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:
|
if not dhcp_port:
|
||||||
raise exceptions.Conflict()
|
raise exceptions.Conflict()
|
||||||
else:
|
else:
|
||||||
@ -784,7 +785,8 @@ class DeviceManager(object):
|
|||||||
port_device_id = getattr(port, 'device_id', None)
|
port_device_id = getattr(port, 'device_id', None)
|
||||||
if port_device_id == constants.DEVICE_ID_RESERVED_DHCP_PORT:
|
if port_device_id == constants.DEVICE_ID_RESERVED_DHCP_PORT:
|
||||||
dhcp_port = self.plugin.update_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:
|
if dhcp_port:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -71,9 +71,10 @@ class DhcpRpcCallbackMixin(object):
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
ctxt.reraise = True
|
ctxt.reraise = True
|
||||||
network_id = port['port']['network_id']
|
net_id = port['port']['network_id']
|
||||||
LOG.warn(_("Port for network %(net_id)s could not be created: "
|
LOG.warn(_("Action %(action)s for network %(net_id)s "
|
||||||
"%(reason)s") % {"net_id": network_id, 'reason': e})
|
"could not complete successfully: %(reason)s")
|
||||||
|
% {"action": action, "net_id": net_id, 'reason': e})
|
||||||
|
|
||||||
def get_active_networks(self, context, **kwargs):
|
def get_active_networks(self, context, **kwargs):
|
||||||
"""Retrieve and return a list of the active network ids."""
|
"""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]
|
plugin.update_dhcp_port.return_value = fake_network.ports[0]
|
||||||
dh.setup_dhcp_port(fake_network_copy)
|
dh.setup_dhcp_port(fake_network_copy)
|
||||||
port_body = {'port': {
|
port_body = {'port': {
|
||||||
|
'network_id': fake_network.id,
|
||||||
'fixed_ips': [{'subnet_id': fake_fixed_ip1.subnet_id,
|
'fixed_ips': [{'subnet_id': fake_fixed_ip1.subnet_id,
|
||||||
'ip_address': fake_fixed_ip1.ip_address},
|
'ip_address': fake_fixed_ip1.ip_address},
|
||||||
{'subnet_id': fake_subnet2.id}]}}
|
{'subnet_id': fake_subnet2.id}]}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user