Class: ForemanNetbox::SyncHost::SyncVirtualMachine::SyncInterfaces::Create
- Inherits:
-
Object
- Object
- ForemanNetbox::SyncHost::SyncVirtualMachine::SyncInterfaces::Create
- Includes:
- Concerns::AssignTags, Interactor
- Defined in:
- app/interactors/foreman_netbox/sync_host/sync_virtual_machine/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 |
# File 'app/interactors/foreman_netbox/sync_host/sync_virtual_machine/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::Virtualization::Interface.new( new_interface.except(:type) .merge( virtual_machine: virtual_machine.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 |