Hello All
I'm wondering how can I get list of all IP addresses in one specific subnet, along with MAC address of a corresponding device via REST API, so I can feed this data as reservations to Kea DHCP server? Kea accepts configuration in JSON format, so this should be straightforward, but i just don't know how.
I have a reservations block in Kea with actual reservations included from file in JSON format like:
I'm afraid that you won't be able to get the info through a simple REST/JSON request. Based on the datamodel (that you'll need to carefully look at) , you should be able to:
query the list of IP addresses contained in a given range,
query the list of devices attached to these IPs together with their MAC address.
A way to go is to let TeemIp create part of the dhcpd configuration file(s) (like what is done to build the DNS db file) and allow users to get them through the REST/JSON API. But I'd need to go through a specification exercise first.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hmmm. I'm not sure I understand how to "let TeemIp create dhcpd configuraion files".
That's what am I aiming for.
But as I understand it, there is no such function in TeemIP which can generate configuration for dhcpd or at least some parts which can be used as snippets to automate dhcpd configuration.
I was thinking that RES/JSON API might be the way to use TeemIp as DDI solution with the Kea dhcp server which is configured through JSON files.
Can you please correct my view?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Your view is correct.
But, as TeemIp editor, I had the 'dhcpd creation tool' as a long term objective. Since work toward that goal is significant, there might be intermediate steps that could be helpful (like listing the reservations or aggregating the different options of a pool... all in dhcpd.conf format).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
But, if I'd like to use data from TeemIp to feed Kea dhcp server? At least address reservations, which needs just value pairs of MAC address and assigned IP address. Is it possible to get this information via REST/JSON API? The documentation of operations/classes/keys needs some work I think. How can I retrieve this MAC/IP value pairs with REST?
I don't mind to do some background script to modify the output JSON so Kea can use it.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you for your patience with me.
Finally I was able to grasp what classes I can use in REST query from Administration > Universal Search > Search for [Combo Box] and came up with something like this
You need to browse the Data Model available from the Administration menu to better understand the structure of the different classes
As you'll see, MAC addresses usually appear in the final class of a CI. As a consequence, a "SELECT PhysicalDevice" or "SELECT ConnectableCI" won't wok. You'll need to run one query per class.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you very much Chris. This works okay.
One more thing I'd like to ask.
Now, the Kea server pulls data from TeemIP every minute, even when there are no changes in the database. Is there a way to push the data from TeemIP to Kea when a change occurs, rather than pull it from Kea server constantly?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This could be done through the "WebHook Integration" extension which is documented here. The extension can be retrieved for free from iTop Hub and automatically installed within your iTop or manually installed if you use TeemIp standalone. Note that next TeemIp revision should include that extension.
Drawback is that you'll need to develop a small web application that offers an API where your scripts will be called from.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello All
I'm wondering how can I get list of all IP addresses in one specific subnet, along with MAC address of a corresponding device via REST API, so I can feed this data as reservations to Kea DHCP server? Kea accepts configuration in JSON format, so this should be straightforward, but i just don't know how.
I have a reservations block in Kea with actual reservations included from file in JSON format like:
So can you please give me an advice what json_data I have to post to REST API to get a list of these two values?
Hi,
I'm afraid that you won't be able to get the info through a simple REST/JSON request. Based on the datamodel (that you'll need to carefully look at) , you should be able to:
A way to go is to let TeemIp create part of the dhcpd configuration file(s) (like what is done to build the DNS db file) and allow users to get them through the REST/JSON API. But I'd need to go through a specification exercise first.
Hmmm. I'm not sure I understand how to "let TeemIp create dhcpd configuraion files".
That's what am I aiming for.
But as I understand it, there is no such function in TeemIP which can generate configuration for dhcpd or at least some parts which can be used as snippets to automate dhcpd configuration.
I was thinking that RES/JSON API might be the way to use TeemIp as DDI solution with the Kea dhcp server which is configured through JSON files.
Can you please correct my view?
Your view is correct.
But, as TeemIp editor, I had the 'dhcpd creation tool' as a long term objective. Since work toward that goal is significant, there might be intermediate steps that could be helpful (like listing the reservations or aggregating the different options of a pool... all in dhcpd.conf format).
But, if I'd like to use data from TeemIp to feed Kea dhcp server? At least address reservations, which needs just value pairs of MAC address and assigned IP address. Is it possible to get this information via REST/JSON API? The documentation of operations/classes/keys needs some work I think. How can I retrieve this MAC/IP value pairs with REST?
I don't mind to do some background script to modify the output JSON so Kea can use it.
It is definitely possible. But you'll probably need to retrieve the info in 2 steps:
TeemIp REST/JSON web services are described here. They rely on iTop REST/JSON web services that are described here.
Thank you for your patience with me.
Finally I was able to grasp what classes I can use in REST query from Administration > Universal Search > Search for [Combo Box] and came up with something like this
The only downside is that I get only one type of device. (In this case PCs).
Is there a way I can get all devices (PCs, Servers, ...) at once?
You need to browse the Data Model available from the Administration menu to better understand the structure of the different classes
As you'll see, MAC addresses usually appear in the final class of a CI. As a consequence, a "SELECT PhysicalDevice" or "SELECT ConnectableCI" won't wok. You'll need to run one query per class.
Thank you very much Chris. This works okay.
One more thing I'd like to ask.
Now, the Kea server pulls data from TeemIP every minute, even when there are no changes in the database. Is there a way to push the data from TeemIP to Kea when a change occurs, rather than pull it from Kea server constantly?
This could be done through the "WebHook Integration" extension which is documented here. The extension can be retrieved for free from iTop Hub and automatically installed within your iTop or manually installed if you use TeemIp standalone. Note that next TeemIp revision should include that extension.
Drawback is that you'll need to develop a small web application that offers an API where your scripts will be called from.