forked from ManageIQ/manageiq-providers-ibm_cloud
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ManageIQ#47 from iv1111/issue_119
Added support for Cloud Volume creation in IBM PVS provisioning
- Loading branch information
Showing
6 changed files
with
208 additions
and
3 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
15 changes: 15 additions & 0 deletions
15
...nageiq/providers/ibm_cloud/power_virtual_servers/cloud_manager/provision/state_machine.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 |
---|---|---|
@@ -1,5 +1,20 @@ | ||
module ManageIQ::Providers::IbmCloud::PowerVirtualServers::CloudManager::Provision::StateMachine | ||
def create_destination | ||
signal :prepare_volumes | ||
end | ||
|
||
def prepare_volumes | ||
new_volumes = options[:new_volumes] | ||
phase_context[:new_volumes] = [] | ||
|
||
if new_volumes.any? | ||
source.with_provider_object(:service => "PowerIaas") do |power_iaas| | ||
new_volumes.each do |new_volume| | ||
phase_context[:new_volumes] << power_iaas.create_volume(new_volume)['volumeID'] | ||
end | ||
end | ||
end | ||
|
||
signal :prepare_provision | ||
end | ||
end |
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
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
125 changes: 125 additions & 0 deletions
125
...nageiq/providers/ibm_cloud/power_virtual_servers/cloud_manager/provision_workflow_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,125 @@ | ||
describe ManageIQ::Providers::IbmCloud::PowerVirtualServers::CloudManager::ProvisionWorkflow do | ||
include Spec::Support::WorkflowHelper | ||
|
||
let(:admin) { FactoryBot.create(:user_with_group) } | ||
let(:ems) { FactoryBot.create(:ems_ibm_cloud_power_virtual_servers_cloud) } | ||
let(:template) do | ||
FactoryBot.create( | ||
:template_ibm_cloud_power_virtual_servers, | ||
:name => "template", | ||
:ext_management_system => ems | ||
) | ||
end | ||
let(:workflow) do | ||
stub_dialog | ||
allow(User).to receive_messages(:server_timezone => "UTC") | ||
described_class.new({:src_vm_id => template.id}, admin.userid) | ||
end | ||
|
||
it "#parse_new_volumes_fields" do | ||
values = { | ||
:name => nil, | ||
:size => nil, | ||
:shareable => false, | ||
:diskType => nil | ||
} | ||
expect(workflow.parse_new_volumes_fields(values)) | ||
.to match_array([]) | ||
values = { | ||
:name => nil, | ||
:size => nil, | ||
:shareable => false, | ||
:diskType => nil, | ||
:name_1 => "disk_one", | ||
:size_1 => "1", | ||
:diskType_1 => "tier1", | ||
:shareable_1 => "null", | ||
:name_2 => "disk_two", | ||
:size_2 => "2", | ||
:diskType_2 => "standard-legacy", | ||
:name_3 => "disk_three", | ||
:size_3 => "3", | ||
:diskType_3 => "tier3", | ||
:shareable_3 => nil, | ||
:name_4 => "disk_four", | ||
:size_4 => "4", | ||
:diskType_4 => "ssd-legacy", | ||
:shareable_4 => true | ||
} | ||
expect(workflow.parse_new_volumes_fields(values)) | ||
.to match_array( | ||
[ | ||
{ | ||
:name => "disk_one", | ||
:size => 1, | ||
:diskType => "tier1", | ||
:shareable => false | ||
}, | ||
{ | ||
:name => "disk_two", | ||
:size => 2, | ||
:diskType => "standard-legacy", | ||
:shareable => false | ||
}, | ||
{ | ||
:name => "disk_three", | ||
:size => 3, | ||
:diskType => "tier3", | ||
:shareable => false | ||
}, | ||
{ | ||
:name => "disk_four", | ||
:size => 4, | ||
:diskType => "ssd-legacy", | ||
:shareable => true | ||
} | ||
] | ||
) | ||
values = { | ||
:name => nil, | ||
:size => nil, | ||
:shareable => false, | ||
:diskType => nil, | ||
:name_1 => "disk_one", | ||
:diskType_1 => "tier1", | ||
:shareable_1 => "null", | ||
:size_2 => "2", | ||
:diskType_2 => "standard-legacy", | ||
:name_3 => "disk_three", | ||
:size_3 => "3", | ||
:diskType_3 => "tier3", | ||
:name_4 => "disk_four", | ||
:size_4 => "", | ||
:diskType_4 => "ssd-legacy", | ||
:shareable_4 => true | ||
} | ||
expect(workflow.parse_new_volumes_fields(values)) | ||
.to match_array( | ||
[ | ||
{ | ||
:name => "disk_one", | ||
:diskType => "tier1", | ||
:size => 0, | ||
:shareable => false | ||
}, | ||
{ | ||
:size => 2, | ||
:diskType => "standard-legacy", | ||
:shareable => false | ||
}, | ||
{ | ||
:name => "disk_three", | ||
:size => 3, | ||
:diskType => "tier3", | ||
:shareable => false | ||
}, | ||
{ | ||
:name => "disk_four", | ||
:size => 0, | ||
:diskType => "ssd-legacy", | ||
:shareable => true | ||
} | ||
] | ||
) | ||
end | ||
end |