Class: InventoryRefresh::SaveInventory

Inherits:
Object
  • Object
show all
Extended by:
Logging
Defined in:
lib/inventory_refresh/save_inventory.rb

Class Method Summary collapse

Methods included from Logging

logger

Class Method Details

.save_inventory(ems, inventory_collections, strategy = nil) ⇒ Object

Saves the passed InventoryCollection objects

Parameters:

  • ems (ExtManagementSystem)

    manager owning the inventory_collections

  • inventory_collections (Array<InventoryRefresh::InventoryCollection>)

    array of InventoryCollection objects for saving



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/inventory_refresh/save_inventory.rb', line 14

def save_inventory(ems, inventory_collections, strategy = nil)
  logger.debug("#{log_header(ems)} Scanning Inventory Collections...Start")
  InventoryRefresh::InventoryCollection::Scanner.scan!(inventory_collections)
  logger.debug("#{log_header(ems)} Scanning Inventory Collections...Complete")

  logger.info("#{log_header(ems)} Saving EMS Inventory...")

  if strategy.try(:to_sym) == :recursive
    InventoryRefresh::SaveCollection::Recursive.save_collections(ems, inventory_collections)
  else
    InventoryRefresh::SaveCollection::TopologicalSort.save_collections(ems, inventory_collections)
  end

  logger.info("#{log_header(ems)} Saving EMS Inventory...Complete")
  ems
end