Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 8 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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