Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
202 additions
and
36 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
45 changes: 45 additions & 0 deletions
45
...utomate/ManageIQ/Infrastructure/VM/Transform/Import.class/__methods__/list_driver_isos.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,45 @@ | ||
module ManageIQ | ||
module Automate | ||
module Infrastructure | ||
module VM | ||
module Transform | ||
module Import | ||
class ListDriverIsos | ||
def initialize(handle = $evm) | ||
@handle = handle | ||
end | ||
|
||
def main | ||
values_hash = {} | ||
values_hash[nil] = '-- select provider first --' | ||
|
||
provider_id = @handle.root['dialog_provider'] | ||
if provider_id.present? && provider_id != '!' | ||
provider = @handle.vmdb(:ext_management_system, provider_id) | ||
unless provider.nil? | ||
values_hash[nil] = '-- select drivers ISO from list --' | ||
provider.iso_datastore.iso_images.pluck(:name).grep(/toolsSetup/).each do |iso| | ||
values_hash[iso] = iso | ||
end | ||
end | ||
end | ||
list_values = { | ||
'sort_by' => :description, | ||
'data_type' => :string, | ||
'required' => true, | ||
'values' => values_hash, | ||
'visible' => @handle.root['dialog_install_drivers'] | ||
} | ||
list_values.each { |key, value| @handle.object[key] = value } | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
if __FILE__ == $PROGRAM_NAME | ||
ManageIQ::Automate::Infrastructure::VM::Transform::Import::ListDriverIsos.new.main | ||
end |
12 changes: 12 additions & 0 deletions
12
...omate/ManageIQ/Infrastructure/VM/Transform/Import.class/__methods__/list_driver_isos.yaml
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,12 @@ | ||
--- | ||
object_type: method | ||
version: 1.0 | ||
object: | ||
attributes: | ||
name: list_driver_isos | ||
display_name: | ||
description: | ||
scope: instance | ||
language: ruby | ||
location: inline | ||
inputs: [] |
12 changes: 12 additions & 0 deletions
12
content/automate/ManageIQ/Infrastructure/VM/Transform/Import.class/list_driver_isos.yaml
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,12 @@ | ||
--- | ||
object_type: instance | ||
version: 1.0 | ||
object: | ||
attributes: | ||
display_name: | ||
name: list_driver_isos | ||
inherits: | ||
description: | ||
fields: | ||
- execute: | ||
value: list_driver_isos |
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
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
52 changes: 52 additions & 0 deletions
52
...te/ManageIQ/Infrastructure/VM/Transform/Import.class/__methods__/list_driver_isos_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,52 @@ | ||
require_domain_file | ||
|
||
describe ManageIQ::Automate::Infrastructure::VM::Transform::Import::ListDriverIsos do | ||
let!(:iso_datastore) do | ||
iso_images = %w( | ||
RHEV-toolsSetup_3.5_15.iso | ||
RHEV-toolsSetup_4.0_7.iso | ||
random-image.iso | ||
RHEV-toolsSetup_4.1_5.iso | ||
oVirt-toolsSetup-4.0-1.fc24.iso | ||
oVirt-toolsSetup-4.1-3.fc24.iso | ||
another-random-image.iso | ||
oVirt-toolsSetup-4.2-4.fc25.iso | ||
).map { |iso| FactoryGirl.create(:iso_image, :name => iso) } | ||
FactoryGirl.create(:iso_datastore, :iso_images => iso_images) | ||
end | ||
let!(:provider) { FactoryGirl.create(:ems_redhat, :with_clusters, :iso_datastore => iso_datastore) } | ||
|
||
let(:root_object) do | ||
Spec::Support::MiqAeMockObject.new( | ||
'dialog_provider' => provider.id.to_s | ||
) | ||
end | ||
|
||
let(:ae_service) do | ||
Spec::Support::MiqAeMockService.new(root_object).tap do |service| | ||
current_object = Spec::Support::MiqAeMockObject.new | ||
current_object.parent = root_object | ||
service.object = current_object | ||
end | ||
end | ||
|
||
it "should list iso images of selected infra provider's iso datastore" do | ||
described_class.new(ae_service).main | ||
|
||
expect(ae_service.object['sort_by']).to eq(:description) | ||
expect(ae_service.object['data_type']).to eq(:string) | ||
expect(ae_service.object['required']).to eq(true) | ||
|
||
isos = { nil => '-- select drivers ISO from list --' } | ||
%w( | ||
RHEV-toolsSetup_3.5_15.iso | ||
RHEV-toolsSetup_4.0_7.iso | ||
RHEV-toolsSetup_4.1_5.iso | ||
oVirt-toolsSetup-4.0-1.fc24.iso | ||
oVirt-toolsSetup-4.1-3.fc24.iso | ||
oVirt-toolsSetup-4.2-4.fc25.iso | ||
).each { |iso| isos[iso] = iso } | ||
|
||
expect(ae_service.object['values']).to eq(isos) | ||
end | ||
end |