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

Processor pools support for PowerVS #443

Merged
merged 6 commits into from
Feb 1, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,22 @@ def provider_region
@provider_region ||= cloud_manager.pcloud_location(connection)
end

def shared_processor_pools
@shared_processor_pools ||= shared_processor_pools_api.pcloud_sharedprocessorpools_getall(cloud_instance_id) || []
end

def shared_processor_pools_by_id
@shared_processor_pools_by_id ||= shared_processor_pools_api.pcloud_sharedprocessorpools_getall(cloud_instance_id).shared_processor_pools.index_by(&:id)
end

def shared_processor_pool(shared_processor_pool_id)
shared_processor_pools_by_id[shared_processor_pool_id] ||= shared_processor_pools_api.pcloud_sharedprocessorpools_get(cloud_instance_id, shared_processor_pool_id)
rescue IbmCloudPower::ApiError => err
error_message = JSON.parse(err.response_body)["description"]
_log.debug("SharedProcessorGroupID '#{shared_processor_pool_id}' not found: #{error_message}")
nil
end

private

def connection
Expand Down Expand Up @@ -195,4 +211,8 @@ def cloud_instances_api
def snapshots_api
@snapshots_api ||= IbmCloudPower::PCloudSnapshotsApi.new(connection)
end

def shared_processor_pools_api
@shared_processor_pools_api ||= IbmCloudPower::PCloudSharedProcessorPoolsApi.new(connection)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def parse
sshkeys
placement_groups
snapshots
shared_processor_pools
end

def ext_management_system
Expand Down Expand Up @@ -60,7 +61,8 @@ def pvm_instances
:raw_power_state => instance.status,
:uid_ems => instance.pvm_instance_id,
:format => instance.storage_type,
:placement_group => persister.placement_groups.lazy_find(instance.placement_group)
:placement_group => persister.placement_groups.lazy_find(instance.placement_group),
:resource_pool => persister.resource_pools.lazy_find(instance.shared_processor_pool_id)
)

# saving hardware information (CPU, Memory, etc.)
Expand Down Expand Up @@ -333,6 +335,22 @@ def snapshots
end
end

def shared_processor_pools
collector.shared_processor_pools.shared_processor_pools.each do |pool|
params = {
:uid_ems => pool.id,
:ems_ref => pool.id,
:name => pool.name,
:cpu_shares => pool.allocated_cores,
:cpu_reserve => pool.available_cores,
:cpu_reserve_expand => true,
:cpu_limit => pool.allocated_cores + pool.available_cores,
:is_default => false
}
persister.resource_pools.build(params)
end
end

def software_licenses_description(software_licenses)
return "" if software_licenses.nil?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def initialize_cloud_inventory_collections
add_cloud_collection(:miq_templates)
add_cloud_collection(:snapshots)
add_cloud_collection(:ext_management_system)
add_cloud_collection(:resource_pools)
add_cloud_collection(:vm_resource_pools)
add_advanced_settings
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class ManageIQ::Providers::IbmCloud::PowerVirtualServers::CloudManager < ManageI
require_nested :Snapshot
require_nested :Template
require_nested :Vm
require_nested :ResourcePool

include ManageIQ::Providers::IbmCloud::PowerVirtualServers::ManagerMixin

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class ManageIQ::Providers::IbmCloud::PowerVirtualServers::CloudManager::ResourcePool < ManageIQ::Providers::CloudManager::ResourcePool
end
90 changes: 76 additions & 14 deletions lib/tasks_private/power_virtual_servers.rake
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ namespace :vcr do
"policy" => "anti-affinity"
)
],
:spp_placement_groups => [
IbmCloudPower::SPPPlacementGroupCreate.new(
"name" => "test_spppg",
"policy" => "affinity"
)
],
:resource_pools => [
IbmCloudPower::SharedProcessorPoolCreate.new(
"host_group" => "s922",
"name" => "test_pool",
"reserved_cores" => 1
)
],
:volumes => [
IbmCloudPower::CreateDataVolume.new(
"name" => "test-volume-1GB-tier3-sharable",
Expand Down Expand Up @@ -130,26 +143,25 @@ namespace :vcr do
"key_pair_name" => "test-ssh-key-with-comment-line-breaks",
"migratable" => true,
"pin_policy" => "hard",
"placement_group" => "test-placement-group-anti-affinity",
"networks" => [
IbmCloudPower::PVMInstanceAddNetwork.new(
"network_id" => "test-network-pub-vlan"
)
]
),
IbmCloudPower::PVMInstanceCreate.new(
"server_name" => "test-instance-rhel-s922-shared-tier3",
"image_id" => "RHEL8-SP6",
"sys_type" => "s922",
"proc_type" => "shared",
"storage_type" => "tier3",
"processors" => 0.50,
"memory" => 2,
"key_pair_name" => "test-ssh-key-no-comment",
"migratable" => true,
"pin_policy" => "none",
"placement_group" => "test-placement-group-affinity",
"networks" => [
"server_name" => "test-instance-rhel-s922-shared-tier3",
"image_id" => "RHEL8-SP6",
"sys_type" => "s922",
"proc_type" => "shared",
"storage_type" => "tier3",
"processors" => 0.50,
"memory" => 2,
"key_pair_name" => "test-ssh-key-no-comment",
"migratable" => true,
"pin_policy" => "none",
"shared_processor_pool" => "test_pool",
"networks" => [
IbmCloudPower::PVMInstanceAddNetwork.new(
"network_id" => "test-network-pub-vlan-dns"
)
Expand All @@ -166,7 +178,6 @@ namespace :vcr do
"key_pair_name" => "test-ssh-key-no-comment",
"migratable" => true,
"pin_policy" => "none",
"placement_group" => "test-placement-group-affinity",
"networks" => [
IbmCloudPower::PVMInstanceAddNetwork.new(
"network_id" => "test-network-vlan"
Expand Down Expand Up @@ -277,6 +288,53 @@ namespace :vcr do
end
end

## Shared Processor Pool Placement Groups
spp_pgs_api = IbmCloudPower::PCloudSPPPlacementGroupsApi.new(connection)

spp_pgs = {}

spp_pgs_api.pcloud_sppplacementgroups_getall(cloud_instance_id).spp_placement_groups.each do |spppg|
spp_pgs[spppg.name] = spppg
end

resources[:spp_placement_groups].each do |placement_group|
if spp_pgs.include?(placement_group.name)
puts "SPP Placement group '#{placement_group.name}' already exists"
else
puts "Creating SPP placement group '#{placement_group.name}'"
created_placement_group = spp_pgs_api.pcloud_sppplacementgroups_post(
cloud_instance_id,
placement_group
)
spp_pgs[placement_group.name] = created_placement_group
end
end

## Shared Processor Pools
proc_pools_api = IbmCloudPower::PCloudSharedProcessorPoolsApi.new(connection)

proc_pools = {}

proc_pools_api.pcloud_sharedprocessorpools_getall(cloud_instance_id).shared_processor_pools.each do |proc_pool|
proc_pools[proc_pool.name] = proc_pool
end

resources[:resource_pools].each do |resource_pool|
if proc_pools.include?(resource_pool.name)
puts "Shared processor pool '#{resource_pool.name}' already exists"
else
puts "Creating Shared processor pool '#{resource_pool.name}'"

resource_pool.placement_group_id = spp_pgs[resources[:spp_placement_groups].first.name].id

created_proc_pool = proc_pools_api.pcloud_sharedprocessorpools_post(
cloud_instance_id,
resource_pool
)
proc_pools[resource_pool.name] = created_proc_pool
end
end

## Volumes
volumes_api = IbmCloudPower::PCloudVolumesApi.new(connection)

Expand Down Expand Up @@ -365,6 +423,10 @@ namespace :vcr do
instance.placement_group = placement_groups[instance.placement_group].id
end

unless instance.shared_processor_pool.nil?
instance.shared_processor_pool = proc_pools[instance.shared_processor_pool].id
end

created_instance = pvm_instances_api.pcloud_pvminstances_post(
cloud_instance_id,
instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def assert_ems_counts

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

Expand All @@ -110,7 +110,7 @@ def assert_specific_flavor
end

def assert_specific_vm
instance_name = "test-instance-rhel-s922-shared-tier3"
instance_name = "test-instance-ibmi-s922-capped-tier1"
vm = ems.vms.find_by(:name => instance_name)
placement_group = ems.placement_groups.find_by(:name => "test-placement-group-affinity")
expect(vm).to have_attributes(
Expand All @@ -130,21 +130,21 @@ def assert_specific_vm
:cpu_sockets => 1,
:cpu_total_cores => 1,
:memory_mb => 2048,
:cpu_type => "ppc64le",
:guest_os => "linux_redhat",
:cpu_type => "ppc64",
:guest_os => "ibm_i",
:bitness => 64
)

expect(vm.operating_system).to have_attributes(
:product_name => "linux_redhat"
:product_name => "ibm_i"
)

expect(vm.advanced_settings.find { |setting| setting['name'] == 'entitled_processors' }).to have_attributes(
:value => "0.5"
:value => "0.25"
)

expect(vm.advanced_settings.find { |setting| setting['name'] == 'processor_type' }).to have_attributes(
:value => "shared"
:value => "capped"
)

expect(vm.advanced_settings.find { |setting| setting['name'] == 'pin_policy' }).to have_attributes(
Expand All @@ -153,11 +153,15 @@ def assert_specific_vm

expect(vm.snapshots.first).to have_attributes(
:type => "ManageIQ::Providers::IbmCloud::PowerVirtualServers::CloudManager::Snapshot",
:name => "test-instance-rhel-s922-shared-tier3-snapshot-1",
:name => "test-instance-ibmi-s922-capped-tier1-snapshot-1",
:vm_or_template_id => vm.id
)

expect(vm.snapshots.first.total_size).to be > 0

instance_name = "test-instance-rhel-s922-shared-tier3"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we put test-instance-ibmi-s922-capped-tier1 in a resource_pool so that we don't have to check a second vm?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried once, but if placement_group and spp_placement_group contradict each other, trying to put the VM on this or that host, then it'd fail, and it did fail on me trying to provision a VM with both specified. I figured that'd be just asking for a trouble at a later time, kinda relying on a luck.

vm2 = ems.vms.find_by(:name => instance_name)
expect(vm2.parent_resource_pool&.name).to eq("test_pool")
end

def assert_specific_template
Expand Down Expand Up @@ -215,7 +219,7 @@ def assert_specific_network_port
:device_type => "VmOrTemplate"
)

expect(network_port.cloud_subnets.count).to eq(2) # TODO: Why are there two identical subnets?
expect(network_port.cloud_subnets.count).to eq(1)
end

def assert_specific_cloud_volume
Expand Down