Munged 'boot_servers' when attempting update via OMAPI

Patrick Rynhart P.Rynhart at massey.ac.nz
Tue May 24 01:29:16 UTC 2016


When attempting to update our DHCP server via OMAPI, I'm getting a 
strange/munged result attempting to set the option PXE.boot_servers. 
I'm using pypureomapi as the OMAPI client - and here's the relevant 
block of code:

import pypureomapi as omapi
import struct, sys

o = omapi.Omapi("ip.of.my.dns.server",7911,KEYNAME,BASE64_ENCODED_KEY)
msg = omapi.OmapiMessage.open(b'host')
msg.message.append(('create', struct.pack('!I', 1)))
msg.message.append(('exclusive', struct.pack('!I', 1)))
msg.obj.append(('hardware-address', omapi.pack_mac("01:50:56:9a:10:b8")))
msg.obj.append(('hardware-type', struct.pack('!I', 1)))
msg.obj.append(('ip-address', omapi.pack_ip("10.5.96.236")))
msg.obj.append(('name', "tur-esnode10"))
statements += 'filename "{0}"; '.format("pxelinux.0")
statements += 'next-server = "{0}"; '.format("tur-issmgmt1.massey.ac.nz")
statements += 'option vendor-class-identifier "{0}";'.format("PXEClient")
statements += 'vendor-option-space PXE;'
statements += 'option PXE.discovery-control 15;'
statements += 'option PXE.boot_servers 0 1 tur-issmgmt1.massey.ac.nz;'
msg.obj.append(('statements', statements))
o.query_server(msg)

This is the result that I'm getting in the leases file:

host tur-esnode10 {
   dynamic;
   hardware ethernet 01:50:56:9a:10:b8;
   fixed-address 10.5.96.236;
         supersede server.filename = "pxelinux.0";
         supersede server.next-server = "tur-issmgmt1.massey.ac.nz";
         supersede vendor-class-identifier = "PXEClient";
         supersede server.vendor-option-space = "PXE";
         supersede PXE.discovery-control = 0f;
         supersede PXE.boot_servers = concat (concat (00:00, 01),
                                              substring (gethostbyname (
 
"tur-issmgmt1.massey.ac.nz")
                                              , 0, 4));
}

Can anyone point out where I'm going wrong here (i.e. why the OMAPI 
update is resulting in boot_servers being formatted like this) ?

Elsewhere (in our static host definitions) we are just using

option PXE.boot_servers 0 1 tur-issmgmt1.massey.ac.nz;

With Thanks in Advance,

Patrick



More information about the dhcp-users mailing list