Skip to content

Commit

Permalink
Merge pull request #479 from jaywcarman/powervs_targeted_vm_refresh_s…
Browse files Browse the repository at this point in the history
…pecs

Add targeted refresh specs to PowerVS / Fix targeted VM refresh bug

(cherry picked from commit 14a1b1d)
  • Loading branch information
agrare authored and Fryguy committed Jan 31, 2024
1 parent 9cabeca commit a1be394
Show file tree
Hide file tree
Showing 5 changed files with 903 additions and 311 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,18 @@ def sshkeys
[]
end

def snapshots
begin
@snapshots ||= snapshots_api.pcloud_cloudinstances_snapshots_getall(cloud_instance_id).snapshots.select do |snapshot|
references(:vms).include?(snapshot.pvm_instance_id)
end
rescue IbmCloudPower::ApiError => err
error_message = JSON.parse(err.response_body)["description"]
_log.debug("Error retrieving snapshots: #{error_message}")
nil
end.compact
end

private

def parse_targets!
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks_private/power_virtual_servers.rake
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ namespace :vcr do
),
IbmCloudPower::PVMInstanceCreate.new(
"server_name" => "test-instance-ibmi-s922-capped-tier1",
"image_id" => "IBMi-75-00-2984-1",
"image_id" => "IBMi-75-02-2984-1",
"sys_type" => "s922",
"proc_type" => "capped",
"storage_type" => "tier1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
describe ManageIQ::Providers::IbmCloud::PowerVirtualServers::CloudManager::Refresher do
include Spec::Support::EmsRefreshHelper
it ".ems_type" do
expect(described_class.ems_type).to eq(:ibm_cloud_power_virtual_servers)
end
Expand Down Expand Up @@ -67,12 +68,26 @@
end
end

context "targeted refresh of VM" do
before { with_vcr { ems.refresh } }

context "vm target", :target_vm => true do
let(:target) { ems.vms.find_by(:name => "test-instance-ibmi-s922-capped-tier1") }

it "doesn't impact other inventory" do
assert_inventory_not_changed do
with_vcr("vm_target") { EmsRefresh.refresh(target) }
end
end
end
end

def assert_table_counts
expect(CloudVolume.count).to eq(10)
expect(CloudNetwork.count).to eq(4)
expect(CloudSubnet.count).to eq(4)
expect(CloudSubnetNetworkPort.count).to eq(12)
expect(Flavor.count).to eq(56)
expect(CloudSubnetNetworkPort.count).to eq(8)
expect(Flavor.count).to eq(58)
expect(MiqTemplate.count).to eq(6)
expect(ManageIQ::Providers::CloudManager::AuthKeyPair.count).to be > 1
expect(NetworkPort.count).to eq(8)
Expand All @@ -89,14 +104,14 @@ def assert_ems_counts
expect(ems.network_manager.network_ports.count).to eq(8)
expect(ems.operating_systems.count).to eq(12)
expect(ems.placement_groups.count).to eq(2)
expect(ems.storage_manager.cloud_volume_types.count).to eq(2)
expect(ems.storage_manager.cloud_volume_types.count).to eq(4)
expect(ems.storage_manager.cloud_volumes.count).to eq(10)
expect(ems.vms.count).to eq(6)
end

def assert_cloud_manager
expect(ems).to have_attributes(
:provider_region => "us-east01"
:provider_region => "mon01"
)
end

Expand Down
Loading

0 comments on commit a1be394

Please sign in to comment.