isc DHCP openLDAP python

Recenly there was a desire to make a testbed for Zero Touch Provisioning of devices with NSO.
I am not ldap guy, but I interoperated a bit with it and thus in this post you may find information
 that is required to proceed with a testbed. Most of this information is available on the internet. This post is a memo.

First we install ISC dhcp server and configuring the ‘schema’

Next we delete from “cn\=\{0\}dhcp.ldif from the bottom:

And from the top of the file we change values to the next

To

In LDAP directory we distinguish the next nodes defined by X.500 Directory Specification.

  • CN = Common Name
  • OU = Organizational Unit
  • DC = Domain Component

Now we add dhcp organization unit

Apply the data located in the file:

Add server common name

Apply the data located in the file:

Add  config common name:

Apply the data located in the file:

Add dhcp subnet common name

Apply the data located in the file:

Add the client common name:

Apply the data located in the file:

Modify the next file

and put the next information:

The next step is to use python to search the IP and MAC addresses of assigned to the device:

We are in the python3 interpreter. We have to import the next modules:
Connect to the server installed locally with credentials.
Search for the object class and retreive the IP and Mac addresses