58e0b8bafb
KeyError exception is seen because of following reasons * DhcpRpcCallback._port_action() is called by two functions - DhcpRpcCallback.create_dchp_port() - DhcpRpcCallback.update_dhcp_port() * When create_dhcp_port() function calls _port_action(), the function argument 'port' will have the body as {'port': {'network_id': foo_network_id, 'fixed_ips': [..] ...} * When update_dhcp_port() function calls _port_action(), the function argument 'port' will have the body as {'id': port_id, 'port': {{'port': {'network_id': foo_network_id, 'fixed_ips': [..] ...}} * If an exception occurs when _port_action() calls plugin.create_port(), network id is accessed as net_id = port['port']['network_id'] * If an exception occurs when _port_action() calls plugin.update_port(), network id is accessed as net_id = port['port']['network_id'] which is causing the KeyError. network_id should have been accessed as net_id = port['port']['port']['network_id'] This patch fixes the issue by making the _port_action() take the same port body. update_dhcp_port() insteading of passing the port_id and port information in a single argument, it now adds port_id in the port body itself. Change-Id: I70b92fa20b421b05ca2053a9a57f62db726f7625 Closes-bug: #1378508