'Update the dhcp port.'

@oslo_messaging.expected_exceptions(exceptions.IpAddressGenerationFailure)
@db_api.retry_db_errors
def update_dhcp_port(self, context, **kwargs):

    host = kwargs.get('host')
    port = kwargs.get('port')
    port['id'] = kwargs.get('port_id')
    port['port'][portbindings.HOST_ID] = host
    plugin = directory.get_plugin()
    try:
        old_port = plugin.get_port(context, port['id'])
        if ((old_port['device_id'] != n_const.DEVICE_ID_RESERVED_DHCP_PORT) and (old_port['device_id'] != utils.get_dhcp_agent_device_id(port['port']['network_id'], host))):
            raise n_exc.DhcpPortInUse(port_id=port['id'])
        LOG.debug('Update    dhcp    port    %(port)s    from    %(host)s.', {'port': port, 'host': host})
        return self._port_action(plugin, context, port, 'update_port')
    except exceptions.PortNotFound:
        LOG.debug('Host    %(host)s    tried    to    update    port    %(port_id)s    which    no    longer    exists.', {'host': host, 'port_id': port['id']})
        return None
