Last active
April 23, 2018 06:04
-
-
Save timogoebel/17f29624d7117b951d7778b6bcd58dfb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lib/foreman_solarwinds/engine.rb | |
config.autoload_paths += Dir["#{config.root}/app/services"] | |
config.autoload_paths += Dir["#{config.root}/app/services/concerns"] | |
config.to_prepare do | |
begin | |
::IPAM.send(:include, ForemanSolarwinds::IpamExtensions) | |
rescue StandardError => e | |
Rails.logger.warn "ForemanSolarwinds: skipping engine hook (#{e})" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/services/concerns/foreman_solarwinds/ipam_extensions.rb | |
module ForemanSolarwinds | |
module IpamExtensions | |
extend ActiveSupport::Concern | |
module Overrides | |
module ClassMethods | |
def new(type, *args) | |
if type == ::IPAM::MODES[:solarwinds] | |
::IPAM::Solarwinds.new(*args) | |
else | |
super | |
end | |
end | |
end | |
def self.prepended(base) | |
class << base | |
prepend ClassMethods | |
end | |
end | |
end | |
included do | |
::IPAM::MODES[:solarwinds] ||= N_('Solarwinds') | |
prepend Overrides | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/services/ipam/solarwinds.rb | |
module IPAM | |
class Solarwinds < Base | |
def suggest_ip | |
# Your code here | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment