From 43bdb800d3ffc55dc5d54129cb54c5d45f1bfd68 Mon Sep 17 00:00:00 2001 From: Adam Grare Date: Tue, 10 Dec 2019 12:14:45 -0500 Subject: [PATCH] Add a Storage subclass --- app/models/manageiq/providers/vmware/infra_manager.rb | 1 + .../providers/vmware/infra_manager/refresh_parser.rb | 1 + .../manageiq/providers/vmware/infra_manager/storage.rb | 3 +++ .../infra_manager/vm_or_template_shared/operations.rb | 2 +- .../vm_or_template_shared/operations/relocation.rb | 6 +++--- .../vmware/infra_manager/inventory/collector_spec.rb | 1 + .../providers/vmware/infra_manager/refresher_spec.rb | 1 + 7 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 app/models/manageiq/providers/vmware/infra_manager/storage.rb diff --git a/app/models/manageiq/providers/vmware/infra_manager.rb b/app/models/manageiq/providers/vmware/infra_manager.rb index d2d6329d5..6086b5278 100644 --- a/app/models/manageiq/providers/vmware/infra_manager.rb +++ b/app/models/manageiq/providers/vmware/infra_manager.rb @@ -7,6 +7,7 @@ class Vmware::InfraManager < InfraManager require_nested :RefreshWorker require_nested :RefreshParser require_nested :ResourcePool + require_nested :Storage require_nested :MetricsCapture require_nested :MetricsCollectorWorker require_nested :Refresher diff --git a/app/models/manageiq/providers/vmware/infra_manager/refresh_parser.rb b/app/models/manageiq/providers/vmware/infra_manager/refresh_parser.rb index c031e1fcd..c2d9d8b2b 100644 --- a/app/models/manageiq/providers/vmware/infra_manager/refresh_parser.rb +++ b/app/models/manageiq/providers/vmware/infra_manager/refresh_parser.rb @@ -138,6 +138,7 @@ def self.storage_inv_to_hashes(inv) new_result = { :ems_ref => mor, :ems_ref_type => mor.vimType, + :type => "ManageIQ::Providers::Vmware::InfraManager::Storage", :name => summary["name"], :store_type => summary["type"].to_s.upcase, :total_space => summary["capacity"], diff --git a/app/models/manageiq/providers/vmware/infra_manager/storage.rb b/app/models/manageiq/providers/vmware/infra_manager/storage.rb new file mode 100644 index 000000000..ad374ffc2 --- /dev/null +++ b/app/models/manageiq/providers/vmware/infra_manager/storage.rb @@ -0,0 +1,3 @@ +class ManageIQ::Providers::Vmware::InfraManager::Storage < ManageIQ::Providers::InfraManager::Storage + include ManageIQ::Providers::Vmware::InfraManager::EmsRefObjMixin +end diff --git a/app/models/manageiq/providers/vmware/infra_manager/vm_or_template_shared/operations.rb b/app/models/manageiq/providers/vmware/infra_manager/vm_or_template_shared/operations.rb index 8bce7b07d..86e84cc35 100644 --- a/app/models/manageiq/providers/vmware/infra_manager/vm_or_template_shared/operations.rb +++ b/app/models/manageiq/providers/vmware/infra_manager/vm_or_template_shared/operations.rb @@ -13,7 +13,7 @@ def raw_clone(name, folder, pool = nil, host = nil, datastore = nil, powerOn = f folder_mor = folder.ems_ref_obj if folder.respond_to?(:ems_ref_obj) pool_mor = pool.ems_ref_obj if pool.respond_to?(:ems_ref_obj) host_mor = host.ems_ref_obj if host.respond_to?(:ems_ref_obj) - datastore_mor = VimString.new(datastore.ems_ref, datastore.ems_ref_type, :ManagedObjectReference) if datastore + datastore_mor = datastore.ems_ref_obj if datastore.respond_to?(:ems_ref_obj) run_command_via_parent(:vm_clone, :name => name, :folder => folder_mor, :pool => pool_mor, :host => host_mor, :datastore => datastore_mor, :powerOn => powerOn, :template => template_flag, :transform => transform, :config => config, :customization => customization, :disk => disk) end diff --git a/app/models/manageiq/providers/vmware/infra_manager/vm_or_template_shared/operations/relocation.rb b/app/models/manageiq/providers/vmware/infra_manager/vm_or_template_shared/operations/relocation.rb index faa37f5d2..0b4a4fc22 100644 --- a/app/models/manageiq/providers/vmware/infra_manager/vm_or_template_shared/operations/relocation.rb +++ b/app/models/manageiq/providers/vmware/infra_manager/vm_or_template_shared/operations/relocation.rb @@ -48,9 +48,9 @@ def raw_relocate(host, pool = nil, datastore = nil, disk_move_type = nil, transf end end - host_mor = host.ems_ref_obj if host - pool_mor = pool.ems_ref_obj if pool - datastore_mor = VimString.new(datastore.ems_ref, datastore.ems_ref_type, :ManagedObjectReference) if datastore + host_mor = host.ems_ref_obj if host + pool_mor = pool.ems_ref_obj if pool + datastore_mor = datastore.ems_ref_obj if datastore run_command_via_parent(:vm_relocate, :host => host_mor, :pool => pool_mor, :datastore => datastore_mor, :disk_move_type => disk_move_type, :transform => transform, :priority => priority, :disk => disk) end diff --git a/spec/models/manageiq/providers/vmware/infra_manager/inventory/collector_spec.rb b/spec/models/manageiq/providers/vmware/infra_manager/inventory/collector_spec.rb index e4521673c..a4b64947a 100644 --- a/spec/models/manageiq/providers/vmware/infra_manager/inventory/collector_spec.rb +++ b/spec/models/manageiq/providers/vmware/infra_manager/inventory/collector_spec.rb @@ -629,6 +629,7 @@ def assert_specific_datastore :name => "GlobalDS_0", :store_type => "VMFS", :total_space => 1_099_511_627_776, + :type => "ManageIQ::Providers::Vmware::InfraManager::Storage", :free_space => 824_633_720_832, :multiplehostaccess => 1, :directory_hierarchy_supported => true, diff --git a/spec/models/manageiq/providers/vmware/infra_manager/refresher_spec.rb b/spec/models/manageiq/providers/vmware/infra_manager/refresher_spec.rb index 71cfb0a93..37d7fa422 100644 --- a/spec/models/manageiq/providers/vmware/infra_manager/refresher_spec.rb +++ b/spec/models/manageiq/providers/vmware/infra_manager/refresher_spec.rb @@ -390,6 +390,7 @@ def assert_specific_storage expect(@storage).to have_attributes( :ems_ref => "datastore-953", :ems_ref_type => "Datastore", + :type => "ManageIQ::Providers::Vmware::InfraManager::Storage", :name => "StarM1-Prod1 (1)", :store_type => "VMFS", :total_space => 524254445568,