Skip to content

Commit

Permalink
Persister's add_collection() interface refactoring
Browse files Browse the repository at this point in the history
switching from old interface for IC definitions
  • Loading branch information
slemrmartin committed Jul 19, 2018
1 parent c7ce240 commit 0b00342
Show file tree
Hide file tree
Showing 3 changed files with 314 additions and 75 deletions.
Original file line number Diff line number Diff line change
@@ -1,76 +1,8 @@
class ManageIQ::Providers::Vmware::InfraManager::Inventory::Persister < ManagerRefresh::Inventory::Persister
def initialize_inventory_collections
add_inventory_collections(
default_inventory_collections, inventory_collection_names, inventory_collection_options
)

relationship_collections = %i(ems_clusters ems_folders hosts resource_pools storages)
dependency_attributes = relationship_collections.each_with_object({}) do |collection_key, obj|
obj[collection_key] = [collections[collection_key]]
end

add_inventory_collection(
default_inventory_collections.parent_blue_folders(:dependency_attributes => dependency_attributes)
)

add_inventory_collection(
default_inventory_collections.vm_parent_blue_folders(
:dependency_attributes => {:vms_and_templates => [collections[:vms_and_templates]]},
)
)

add_inventory_collection(
default_inventory_collections.vm_resource_pools(
:dependency_attributes => {:vms_and_templates => [collections[:vms_and_templates]]},
)
)

add_inventory_collection(
default_inventory_collections.root_folder_relationship(
:dependency_attributes => {:ems_folders => [collections[:ems_folders]]},
)
)

add_inventory_collection(
default_inventory_collections.snapshot_parent(
:dependency_attributes => {:snapshots => [collections[:snapshots]]},
)
)
end
include ::ManageIQ::Providers::Vmware::InfraManager::Inventory::Persister::Definitions::InfraCollections

def default_inventory_collections
ManageIQ::Providers::Vmware::InfraManager::Inventory::InventoryCollections
end

def inventory_collection_names
%i(
custom_attributes
customization_specs
disks
ems_clusters
ems_folders
guest_devices
hardwares
hosts
host_guest_devices
host_hardwares
host_networks
host_storages
host_switches
host_system_services
host_operating_systems
lans
miq_scsi_luns
miq_scsi_targets
networks
operating_systems
resource_pools
snapshots
storages
storage_profiles
switches
vms_and_templates
)
def initialize_inventory_collections
initialize_infra_inventory_collections
end

def complete
Expand All @@ -85,16 +17,21 @@ def strategy
nil
end

def targeted
def targeted?
false
end

def inventory_collection_options
def parent
manager.presence
end

def shared_options
{
:complete => complete,
:saver_strategy => saver_strategy,
:strategy => strategy,
:targeted => targeted,
:targeted => targeted?,
:parent => parent
}
end

Expand Down
Loading

0 comments on commit 0b00342

Please sign in to comment.