omcmd, freeing leases via OMAPI

Ed Ravin eravin at panix.com
Mon Aug 15 22:37:37 UTC 2011


I discovered the "omcmd" utility the other day - it's a command-line
program that makes OMAPI calls.  It seems like a much easier way to
interface with dhcpd from a script than by using omshell.

Included in its documentation was a patch, appended below.  The
description is:

   ** dhcp-3.0.1 won't allow leases to be freed dynamically as-is.
   I've included a (short) dhcp-omapifree.patch, that, when applied,
   will actually free leases if state is set to 'free'.

My questions are:

1) Is the ability to free a lease using OMAPI currently in dhcpd?
I see this comment in the 4.1.0a1 release notes:

  It's now possible to update the "ends" field of a lease with OMAPI.
  This is useful if you want not only to release a lease, but also make
  it available for reuse right away.  Hat tip to Christof Chen.

But there's no mention of whether the bug described above in 3.0.1 is
fixed.

2) omcmd does not seem to have had any development for four or five
years.  Is there any reason not to use it?

Thanks,

	-- Ed

diff -urN dhcp-3.0.1.orig/server/omapi.c dhcp-3.0.1/server/omapi.c
--- dhcp-3.0.1.orig/server/omapi.c      2004-06-10 13:59:57.000000000 -0400
+++ dhcp-3.0.1/server/omapi.c   2005-12-07 14:20:02.000000000 -0500
@@ -234,6 +234,9 @@
            
            if (lease -> binding_state != bar) {
                lease -> next_binding_state = bar;
+               /* When freed via omapi, set ends to now; otherwise
+               a lease can't be freed via omapi. */
+               if (bar == FTS_FREE) lease -> ends = cur_time;
                if (supersede_lease (lease, 0, 1, 1, 1)) {
                        log_info ("lease %s state changed from %s to %s",
                                  piaddr(lease->ip_addr), ols, nls);




More information about the dhcp-users mailing list