Adding Parameters for Creating a Subnet in Foreman

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):

1 Like

Okay thanks, I’ll try it out!

Were you suggesting something like this 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]

# 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.

1 Like