Skip to content

Commit

Permalink
Add resource_pools relationship collection
Browse files Browse the repository at this point in the history
  • Loading branch information
agrare committed May 7, 2018
1 parent 2483ff2 commit df11fa2
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module ManageIQ::Providers::Vmware::InfraManager::Inventory::Collector::Property
"resourceConfig.memoryAllocation.reservation",
"resourceConfig.memoryAllocation.shares.level",
"resourceConfig.memoryAllocation.shares.shares",
"resourcePool",
"snapshot",
"summary.vm",
"summary.config.annotation",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def vms_and_templates(extra_attributes = {})
attributes = {
:model_class => ::VmOrTemplate,
:association => :vms_and_templates,
:attributes_blacklist => %i(parent),
:attributes_blacklist => %i(parent resource_pool),
:builder_params => {
:ems_id => ->(persister) { persister.manager.id },
},
Expand Down Expand Up @@ -62,5 +62,13 @@ def guest_devices(extra_attributes = {})
attributes = {:parent_inventory_collections => [:vms_and_templates]}
super(attributes.merge(extra_attributes))
end

def parent_blue_folders(extra_attributes = {})
relationships(:parent, :ems_metadata, :parent_blue_folders, extra_attributes)
end

def vm_resource_pools(extra_attributes = {})
relationships(:resource_pool, :ems_metadata, :vm_resource_pools, extra_attributes)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,13 @@ def parse_virtual_machine(object, props)
persister.vms_and_templates.manager_uuids << object._ref
return if props.nil?

resource_pool = persister.resource_pools.lazy_find(props[:resourcePool]._ref) if props[:resourcePool]

vm_hash = {
:ems_ref => object._ref,
:vendor => "vmware",
:parent => parse_parent(props[:parent]),
:ems_ref => object._ref,
:vendor => "vmware",
:parent => parse_parent(props[:parent]),
:resource_pool => resource_pool,
}

parse_virtual_machine_config(vm_hash, props)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ def initialize_inventory_collections
end

add_inventory_collection(
default_inventory_collections.relationships(
:parent, :ems_metadata, :relationships, :dependency_attributes => dependency_attributes
default_inventory_collections.parent_blue_folders(:dependency_attributes => dependency_attributes)
)

add_inventory_collection(
default_inventory_collections.vm_resource_pools(
:dependency_attributes => {:vms_and_templates => [collections[:vms_and_templates]]}
)
)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,13 @@ def assert_specific_vm
# TODO: expect(vm.ems_cluster).not_to be_nil

expect(vm.host).not_to be_nil
expect(vm.host.ems_ref).to eq("host-16")
expect(vm.host.ems_ref).to eq("host-17")

expect(vm.parent_blue_folder).not_to be_nil
expect(vm.parent_blue_folder.ems_ref).to eq("group-v3")

# TODO: expect(vm.parent_yellow_folder).not_to be_nil
# TODO: expect(vm.parent_resource_pool).not_to be_nil
expect(vm.parent_resource_pool).not_to be_nil
end
end
end

Large diffs are not rendered by default.

0 comments on commit df11fa2

Please sign in to comment.