ndejong / pfsense_fauxapi

REST based API interface for pfSense 2.3.x and 2.4.x to facilitate devops
Apache License 2.0
354 stars 61 forks source link

Can't delete last element of the static map (DHCP Server) #64

Open SpikeeBaut opened 4 years ago

SpikeeBaut commented 4 years ago

Hello, Thanks for your API. I started to use it this week but I have a little issue. In my application, I try to delete the connexion betwenn MAC adress and IP adress. To do so I get the DHCP config and remove the element of the satic map I want to.

self.get_config()
for i in range(0, len(self.config["dhcpd"]["lan"]["staticmap"])-1):
    if self.config["dhcpd"]["lan"]["staticmap"][i]["mac"] == mac_to_delete:
        self.config["dhcpd"]["lan"]["staticmap"].pop(i)
self.execute()

It works well but when I want to delete the last element of the static map it doesn't work and I don't have any error. How can I solve this problem ?

Thanks

Thibaut

ndejong commented 4 years ago

This kinda-feels like a pfSense quirk but here are some things to check -

If you resolve please do report back, as it helps others.

Failing this, if you could supply a sample config XML file that I could take a look at, I can dig deeper when I find time