Class: ForemanNetbox::SyncHost::SyncDevice::SyncInterfaces::Create
- Inherits:
-
Object
- Object
- ForemanNetbox::SyncHost::SyncDevice::SyncInterfaces::Create
- Includes:
- Concerns::AssignTags, Interactor
- Defined in:
- app/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/create.rb
Instance Method Summary collapse
Methods included from Concerns::AssignTags
#assign_tags_to, #default_tag_ids
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/create.rb', line 15 def call netbox_params.fetch(:interfaces, []) .select { |i| i[:name] } .reject { |i| interfaces.map(&:name).include?(i[:name]) } .map do |new_interface| ForemanNetbox::API.client::DCIM::Interface.new( new_interface.except(:type) .merge( type: new_interface.dig(:type, :value), device: device.id, tags: default_tag_ids ) ).save end rescue NetboxClientRuby::LocalError, NetboxClientRuby::ClientError, NetboxClientRuby::RemoteError => e ::Foreman::Logging.logger('foreman_netbox/import').error("#{self.class} error #{e}: #{e.backtrace}") context.fail!(error: "#{self.class}: #{e}") end |