I am in the process of developing a foreman plugin for Netbox IPAM. When someone creates a new subnet in Foreman and selects IPAM, I want to add an item the list that drops down. Does anyone know how I should go about doing this?
You need to extend the supported_ipam_modes
class method in subnet ipv4 from your plugin (using prepend most likely): https://github.com/theforeman/foreman/blob/develop/app/models/subnet/ipv4.rb#L29
Okay thanks, I’ll try it out!
Were you suggesting something like this https://github.com/stephen-nelsonjr/foreman_netbox/blob/master/app/models/subnet/ipv4.rb? Not sure if I’m on the right track.
it should look something like:
# in app/models/subnet_extention
module ForemanNetbox
module SubnetClassExtensions
def supported_ipam_modes
super + [:netbox_ipam]
end
end
end
# in lib/foreman_netbox/engine.rb under config.to_prepare block
Subnet::Ipv4.singleton_class.send(:prepend, ForemanNetbox::SubnetClassExtensions)
I haven’t actually tested this so it might require a bit of tweaking to get working properly.
Okay thank you, it worked. I’ve never used prepend
before so I learned something new. The selection is blank (the words: “netbox_ipam” don’t show up), but I’ll try to tweak things around to get what I need. I appreciate your help.