Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persister: InventoryCollection building through add_collection() #288

Merged
merged 3 commits into from
Jun 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def parse_vm(vm)
:ems_ref => uid,
:name => name,
:hostname => hostname,
:location => uid,
:vendor => "vmware",
:raw_power_state => status,
:snapshots => [parse_snapshot(vm)].compact,
Expand Down Expand Up @@ -193,6 +194,7 @@ def parse_image(image, is_public)
:uid_ems => uid,
:ems_ref => uid,
:name => name,
:location => uid,
:vendor => "vmware",
:raw_power_state => "never",
:publicly_available => is_public
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def vms
:uid_ems => vm[:vm].id,
:name => vm[:vm].name,
:hostname => vm[:hostname],
:location => vm[:vm].id,
:vendor => 'vmware',
:raw_power_state => vm[:vm].status,
:orchestration_stack => persister.orchestration_stacks.lazy_find(vm[:vm].vapp_id),
Expand Down Expand Up @@ -98,6 +99,7 @@ def images
persister.miq_templates.find_or_build(image[:image].id).assign_attributes(
:uid_ems => image[:image].id,
:name => image[:image].name,
:location => image[:image].id,
:vendor => 'vmware',
:raw_power_state => 'never',
:publicly_available => image[:is_published]
Expand Down
4 changes: 2 additions & 2 deletions app/models/manageiq/providers/vmware/inventory/persister.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def cloud
ManageIQ::Providers::Vmware::InventoryCollectionDefault::CloudManager
end

def targeted
def targeted?
false
end

Expand All @@ -20,7 +20,7 @@ def shared_options

settings_options.merge(
:strategy => strategy,
:targeted => targeted,
:targeted => targeted?,
)
end
end
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
class ManageIQ::Providers::Vmware::Inventory::Persister::CloudManager < ManageIQ::Providers::Vmware::Inventory::Persister
include ::ManageIQ::Providers::Vmware::Inventory::Persister::Definitions::CloudCollections

def initialize_inventory_collections
add_inventory_collections(
cloud,
%i(
availability_zones
orchestration_stacks
vms
snapshots
hardwares
disks
operating_systems
orchestration_templates
miq_templates
)
)
initialize_cloud_inventory_collections
end

def shared_options
{
:strategy => strategy,
:targeted => targeted?,
:parent => manager.presence
}
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
module ManageIQ::Providers::Vmware::Inventory::Persister::Definitions::CloudCollections
extend ActiveSupport::Concern

def cloud
::ManagerRefresh::InventoryCollection::Builder::CloudManager
end

def initialize_cloud_inventory_collections
%i(vms
availability_zones
disks
hardwares
operating_systems
snapshots).each do |name|

add_collection(cloud, name)
end

add_orchestration_templates

add_orchestration_stacks

add_miq_templates
end

# ------ IC provider specific definitions -------------------------

def add_miq_templates
add_collection(cloud, :miq_templates) do |builder|
builder.add_properties(:model_class => ::ManageIQ::Providers::Vmware::CloudManager::Template)
end
end

# TODO: mslemr - parent model_class used anywhere? If not, should be deleted from core
def add_orchestration_stacks
add_collection(cloud, :orchestration_stacks) do |builder|
builder.add_properties(:model_class => ::ManageIQ::Providers::Vmware::CloudManager::OrchestrationStack)
end
end

def add_orchestration_templates
add_collection(cloud, :orchestration_templates) do |builder|
builder.add_builder_params(:ems_id => manager.id)
end
end
end

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def assert_specific_template
:vendor => 'vmware',
:power_state => 'never',
:publicly_available => false,
:location => 'unknown',
:location => 'vm-ac90bd58-3bc4-47a5-bc8c-f1c8f5c468b6',
:tools_status => nil,
:boot_time => nil,
:standby_action => nil,
Expand Down Expand Up @@ -205,7 +205,7 @@ def assert_specific_vm_powered_on
:uid_ems => 'vm-84faa107-c0b9-4a21-adc5-b17e0c5355a2',
:vendor => 'vmware',
:power_state => 'on',
:location => 'unknown',
:location => 'vm-84faa107-c0b9-4a21-adc5-b17e0c5355a2',
:tools_status => nil,
:boot_time => nil,
:standby_action => nil,
Expand Down Expand Up @@ -295,7 +295,7 @@ def assert_specific_vm_powered_off
:uid_ems => 'vm-aaf94123-cbf9-4de9-841c-41dd41ac310e',
:vendor => 'vmware',
:power_state => 'off',
:location => 'unknown',
:location => 'vm-aaf94123-cbf9-4de9-841c-41dd41ac310e',
:tools_status => nil,
:boot_time => nil,
:standby_action => nil,
Expand Down