'Release a DHCP lease.'

def _release_lease(self, mac_address, ip, client_id=None, server_id=None, iaid=None):

    if (netaddr.IPAddress(ip).version == constants.IP_VERSION_6):
        if (not self._is_dhcp_release6_supported()):
            return
        cmd = ['dhcp_release6', '--iface', self.interface_name, '--ip', ip, '--client-id', client_id, '--server-id', server_id, '--iaid', iaid]
    else:
        cmd = ['dhcp_release', self.interface_name, ip, mac_address]
        if client_id:
            cmd.append(client_id)
    ip_wrapper = ip_lib.IPWrapper(namespace=self.network.namespace)
    try:
        ip_wrapper.netns.execute(cmd, run_as_root=True)
    except RuntimeError as e:
        LOG.warning(_LW('DHCP    release    failed    for    %(cmd)s.    Reason:    %(e)s'), {'cmd': cmd, 'e': e})
