Skip to content

Commit

Permalink
Add Folder class to VMware provider.
Browse files Browse the repository at this point in the history
Add Folder class to VMware provider for move_into_folder method.

https://bugzilla.redhat.com/show_bug.cgi?id=1090957
  • Loading branch information
lfu committed Jun 14, 2018
1 parent 3c7687c commit 7ec9aa3
Show file tree
Hide file tree
Showing 8 changed files with 174 additions and 148 deletions.
1 change: 1 addition & 0 deletions app/models/manageiq/providers/vmware/infra_manager.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module ManageIQ::Providers
class Vmware::InfraManager < InfraManager
require_nested :DistributedVirtualSwitch
require_nested :Folder
require_nested :EventCatcher
require_nested :EventParser
require_nested :RefreshWorker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def self.parse_new_target(event)

def self.folder_update_to_hash(event)
mor = event[:mor]
klass = 'EmsFolder'
klass = 'ManageIQ::Providers::Vmware::InfraManager::Folder'
hash = {
:folders => [
{
Expand Down
13 changes: 13 additions & 0 deletions app/models/manageiq/providers/vmware/infra_manager/folder.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class ManageIQ::Providers::Vmware::InfraManager::Folder < EmsFolder
def move_into_folder(vm)
raise _("Vm cannot be nil") if vm.nil?
vm_mor = vm.ems_ref_obj
log_header = "EmsFolder: [#{name}] Vm: id [#{vm.id}], name [#{vm.name}], ems_ref [#{vm_mor}]"

with_provider_object do |vim_folder|
_log.info("#{log_header} Invoking moveIntoFolder...")
vim_folder.send(:moveIntoFolder, vm_mor)
_log.info("#{log_header} Invoking moveIntoFolder...Complete")
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def parse_folder(object, kind, props)
:ems_ref => object._ref,
:ems_ref_obj => managed_object_to_vim_string(object),
:uid_ems => object._ref,
:type => "EmsFolder",
:type => "ManageIQ::Providers::Vmware::InfraManager::Folder",
:name => CGI.unescape(props[:name]),
:parent => lazy_find_managed_object(props[:parent]),
:hidden => hidden,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ def self.folder_inv_to_hashes(inv, result, result_uids)
child_mors = get_mors(data, 'childEntity')

new_result = {
:type => EmsFolder.name,
:type => ManageIQ::Providers::Vmware::InfraManager::Folder.name,
:ems_ref => mor,
:ems_ref_obj => mor,
:uid_ems => mor,
Expand Down
15 changes: 15 additions & 0 deletions spec/models/manageiq/providers/vmware/infra_manager/folder_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
describe ManageIQ::Providers::Vmware::InfraManager::Folder do
describe "#move_into_folder" do
let(:folder) { FactoryGirl.create(:vmware_folder_vm) }
let(:vm) { FactoryGirl.create(:vm_vmware, :ems_ref_obj => "vm-1120") }
let(:provider_object) do
double("vm_vmware_provider_object", :destroy => nil).as_null_object
end

it "calls provider's method" do
expect(folder).to receive(:with_provider_object).and_yield(provider_object)
expect(provider_object).to receive(:send).with(:moveIntoFolder, vm.ems_ref_obj)
folder.move_into_folder(vm)
end
end
end
285 changes: 141 additions & 144 deletions spec/models/manageiq/providers/vmware/infra_manager/refresher_spec.rb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion spec/models/miq_vim_broker_worker/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@

it "will handle create events properly" do
mor = "group-v123"
klass = "EmsFolder"
klass = "ManageIQ::Providers::Vmware::InfraManager::EmsFolder"
find_opts = {:uid_ems => mor}

event = {
Expand Down

0 comments on commit 7ec9aa3

Please sign in to comment.