Skip to content

Commit

Permalink
Add ems_metadata inventory collection
Browse files Browse the repository at this point in the history
  • Loading branch information
agrare committed May 7, 2018
1 parent 1b4120a commit c562137
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def vms_and_templates(extra_attributes = {})
attributes = {
:model_class => ::VmOrTemplate,
:association => :vms_and_templates,
:attributes_blacklist => %i(parent),
:builder_params => {
:ems_id => ->(persister) { persister.manager.id },
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ 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 vms_and_templates)
dependency_attributes = relationship_collections.each_with_object({}) do |collection_key, obj|
obj[collection_key] = [collections[collection_key]]
end

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

def default_inventory_collections
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ def assert_specific_host

expect(host).not_to be_nil

expect(host.parent).not_to be_nil
expect(host.parent.ems_ref).to eq("domain-c12")

switch = host.switches.find_by(:uid_ems => "vSwitch0")

expect(switch).not_to be_nil
Expand Down Expand Up @@ -220,8 +223,11 @@ def assert_specific_cluster
:uid_ems => "domain-c12",
)

expect(cluster.children.count).to eq(1)
expect(cluster.children.first.ems_ref).to eq("resgroup-13")
expect(cluster.parent).not_to be_nil
expect(cluster.parent.ems_ref).to eq("group-h4")

expect(cluster.children.count).to eq(5)
expect(cluster.default_resource_pool.ems_ref).to eq("resgroup-13")
end

def assert_specific_resource_pool
Expand Down Expand Up @@ -266,6 +272,9 @@ def assert_specific_dvswitch
:mac_changes => false,
)
expect(dvs.lans.count).to eq(3)

expect(dvs.parent).not_to be_nil
expect(dvs.parent.ems_ref).to eq("group-n6")
end

def assert_specific_dvportgroup
Expand Down Expand Up @@ -332,8 +341,16 @@ def assert_specific_vm
:start_connected => true,
)

# 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.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
end
end
end

0 comments on commit c562137

Please sign in to comment.