-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add EmsFolder class to VMware provider.
Add EmsFolder class to VMware provider for move_into_folder method. https://bugzilla.redhat.com/show_bug.cgi?id=1090957
- Loading branch information
Showing
3 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
app/models/manageiq/providers/vmware/infra_manager/ems_folder.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class ManageIQ::Providers::Vmware::InfraManager::EmsFolder < 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 |
15 changes: 15 additions & 0 deletions
15
spec/models/manageiq/providers/vmware/infra_manager/ems_folder_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
describe ManageIQ::Providers::Vmware::InfraManager::EmsFolder 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 |