From 076d3f539d6d97af46a03d815ac7a8a7dce0b54a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 15 Dec 2023 17:40:47 +0000 Subject: [PATCH 1/9] Add renovate.json --- renovate.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 renovate.json diff --git a/renovate.json b/renovate.json new file mode 100644 index 00000000..5db72dd6 --- /dev/null +++ b/renovate.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:recommended" + ] +} From b2440edf28956f51b15d80c820e0979f088e118d Mon Sep 17 00:00:00 2001 From: Keenan Brock Date: Tue, 27 Feb 2024 14:50:22 -0500 Subject: [PATCH 2/9] drop unsupported_reason_add --- .../providers/openstack/cloud_manager.rb | 11 +++---- .../openstack/cloud_manager/base_template.rb | 4 +-- .../openstack/cloud_manager/template.rb | 4 +-- .../providers/openstack/cloud_manager/vm.rb | 2 +- .../cloud_manager/vm/associate_ip.rb | 18 +++++------ .../vm/manage_security_groups.rb | 18 +++++------ .../openstack/cloud_manager/vm/operations.rb | 4 +-- .../cloud_manager/vm/operations/guest.rb | 14 +++++--- .../cloud_manager/vm/operations/power.rb | 16 ++++++---- .../cloud_manager/vm/operations/relocation.rb | 12 ++----- .../cloud_manager/vm/operations/snapshot.rb | 32 +++++-------------- .../openstack/cloud_manager/vm/resize.rb | 10 +++--- .../vm_or_template_shared/scanning.rb | 7 +--- .../providers/openstack/infra_manager.rb | 2 +- .../providers/openstack/infra_manager/host.rb | 6 ++-- .../openstack/infra_manager/template.rb | 7 +--- .../network_manager/cloud_network.rb | 8 ++--- .../openstack/network_manager/cloud_subnet.rb | 15 ++++----- .../openstack/network_manager/floating_ip.rb | 8 ++--- .../network_manager/network_router.rb | 15 ++++----- .../network_manager/security_group.rb | 8 ++--- .../cinder_manager/cloud_volume.rb | 9 ++++-- .../cinder_manager/cloud_volume/operations.rb | 15 ++++++--- .../storage_manager/swift_manager.rb | 5 ++- 24 files changed, 114 insertions(+), 136 deletions(-) diff --git a/app/models/manageiq/providers/openstack/cloud_manager.rb b/app/models/manageiq/providers/openstack/cloud_manager.rb index 622d3228..dd477de8 100644 --- a/app/models/manageiq/providers/openstack/cloud_manager.rb +++ b/app/models/manageiq/providers/openstack/cloud_manager.rb @@ -21,26 +21,25 @@ class ManageIQ::Providers::Openstack::CloudManager < ManageIQ::Providers::CloudM supports :cloud_tenants supports :cloud_tenant_mapping do if defined?(self.class.module_parent::CloudManager::CloudTenant) && !tenant_mapping_enabled? - unsupported_reason_add(:cloud_tenant_mapping, _("Tenant mapping is disabled on the Provider")) + _("Tenant mapping is disabled on the Provider") elsif !defined?(self.class.module_parent::CloudManager::CloudTenant) - unsupported_reason_add(:cloud_tenant_mapping, _("Tenant mapping is supported only when CloudTenant exists "\ - "on the CloudManager")) + _("Tenant mapping is supported only when CloudTenant exists on the CloudManager") end end supports :create_flavor supports :label_mapping supports :events do - unsupported_reason_add(:events, _("Events are not supported")) unless capabilities["events"] + _("Events are not supported") unless capabilities["events"] end supports :metrics supports :storage_manager supports :cinder_service do - unsupported_reason_add(:cinder_service, "Cinder service unavailable") unless openstack_handle.detect_volume_service.name == :cinder + "Cinder service unavailable" unless openstack_handle.detect_volume_service.name == :cinder end supports :swift_service do - unsupported_reason_add(:swift_service, "Swift service unavailable") unless openstack_handle.detect_volume_service.name == :swift + "Swift service unavailable" unless openstack_handle.detect_volume_service.name == :swift end before_create :ensure_managers diff --git a/app/models/manageiq/providers/openstack/cloud_manager/base_template.rb b/app/models/manageiq/providers/openstack/cloud_manager/base_template.rb index faa7850d..4e806057 100644 --- a/app/models/manageiq/providers/openstack/cloud_manager/base_template.rb +++ b/app/models/manageiq/providers/openstack/cloud_manager/base_template.rb @@ -1,9 +1,9 @@ class ManageIQ::Providers::Openstack::CloudManager::BaseTemplate < ManageIQ::Providers::CloudManager::Template supports :provisioning do if ext_management_system - unsupported_reason_add(:provisioning, ext_management_system.unsupported_reason(:provisioning)) unless ext_management_system.supports?(:provisioning) + ext_management_system.unsupported_reason(:provisioning) else - unsupported_reason_add(:provisioning, _('not connected to ems')) + _('not connected to ems') end end end diff --git a/app/models/manageiq/providers/openstack/cloud_manager/template.rb b/app/models/manageiq/providers/openstack/cloud_manager/template.rb index afa3802e..3e7c42c6 100644 --- a/app/models/manageiq/providers/openstack/cloud_manager/template.rb +++ b/app/models/manageiq/providers/openstack/cloud_manager/template.rb @@ -12,9 +12,7 @@ class ManageIQ::Providers::Openstack::CloudManager::Template < ManageIQ::Provide supports :create_image do if ext_management_system.nil? - msg = _("The Image is not connected to an active %{table}") % - {:table => ui_lookup(:table => "ext_management_system")} - unsupported_reason_add(:create_image, msg) + _("The Image is not connected to an active %{table}") % {:table => ui_lookup(:table => "ext_management_system")} end end diff --git a/app/models/manageiq/providers/openstack/cloud_manager/vm.rb b/app/models/manageiq/providers/openstack/cloud_manager/vm.rb index c585995c..34145a89 100644 --- a/app/models/manageiq/providers/openstack/cloud_manager/vm.rb +++ b/app/models/manageiq/providers/openstack/cloud_manager/vm.rb @@ -9,7 +9,7 @@ class ManageIQ::Providers::Openstack::CloudManager::Vm < ManageIQ::Providers::Cl supports :capture supports :pause do - unsupported_reason_add(:pause, _('The VM is not powered on')) unless vm_powered_on? + _('The VM is not powered on') unless vm_powered_on? end supports :snapshots diff --git a/app/models/manageiq/providers/openstack/cloud_manager/vm/associate_ip.rb b/app/models/manageiq/providers/openstack/cloud_manager/vm/associate_ip.rb index 32cbe727..3fa5e0f0 100644 --- a/app/models/manageiq/providers/openstack/cloud_manager/vm/associate_ip.rb +++ b/app/models/manageiq/providers/openstack/cloud_manager/vm/associate_ip.rb @@ -4,20 +4,18 @@ module ManageIQ::Providers::Openstack::CloudManager::Vm::AssociateIp included do supports :associate_floating_ip do if cloud_tenant.nil? || cloud_tenant.floating_ips.empty? - unsupported_reason_add(:associate_floating_ip, - _("There are no %{floating_ips} available to this %{instance}.") % { - :floating_ips => ui_lookup(:tables => "floating_ips"), - :instance => ui_lookup(:table => "vm_cloud") - }) + _("There are no %{floating_ips} available to this %{instance}.") % { + :floating_ips => ui_lookup(:tables => "floating_ips"), + :instance => ui_lookup(:table => "vm_cloud") + } end end supports :disassociate_floating_ip do if floating_ips.empty? - unsupported_reason_add(:disassociate_floating_ip, - _("This %{instance} does not have any associated %{floating_ips}") % { - :instance => ui_lookup(:table => 'vm_cloud'), - :floating_ips => ui_lookup(:tables => 'floating_ip') - }) + _("This %{instance} does not have any associated %{floating_ips}") % { + :instance => ui_lookup(:table => 'vm_cloud'), + :floating_ips => ui_lookup(:tables => 'floating_ip') + } end end end diff --git a/app/models/manageiq/providers/openstack/cloud_manager/vm/manage_security_groups.rb b/app/models/manageiq/providers/openstack/cloud_manager/vm/manage_security_groups.rb index f2874458..7cad7c77 100644 --- a/app/models/manageiq/providers/openstack/cloud_manager/vm/manage_security_groups.rb +++ b/app/models/manageiq/providers/openstack/cloud_manager/vm/manage_security_groups.rb @@ -4,20 +4,18 @@ module ManageIQ::Providers::Openstack::CloudManager::Vm::ManageSecurityGroups included do supports :add_security_group do if cloud_tenant.nil? || cloud_tenant.security_groups.empty? - unsupported_reason_add(:add_security_group, - _("There are no %{security_groups} available to this %{instance}.") % { - :security_groups => ui_lookup(:tables => "security_group"), - :instance => ui_lookup(:table => "vm_cloud") - }) + _("There are no %{security_groups} available to this %{instance}.") % { + :security_groups => ui_lookup(:tables => "security_group"), + :instance => ui_lookup(:table => "vm_cloud") + } end end supports :remove_security_group do if security_groups.empty? - unsupported_reason_add(:remove_security_group, - _("This %{instance} does not have any associated %{security_groups}") % { - :instance => ui_lookup(:table => 'vm_cloud'), - :security_groups => ui_lookup(:tables => 'security_group') - }) + _("This %{instance} does not have any associated %{security_groups}") % { + :instance => ui_lookup(:table => 'vm_cloud'), + :security_groups => ui_lookup(:tables => 'security_group') + } end end end diff --git a/app/models/manageiq/providers/openstack/cloud_manager/vm/operations.rb b/app/models/manageiq/providers/openstack/cloud_manager/vm/operations.rb index a16003be..6d4eb67b 100644 --- a/app/models/manageiq/providers/openstack/cloud_manager/vm/operations.rb +++ b/app/models/manageiq/providers/openstack/cloud_manager/vm/operations.rb @@ -8,9 +8,7 @@ module ManageIQ::Providers::Openstack::CloudManager::Vm::Operations include Snapshot included do - supports :terminate do - unsupported_reason_add(:terminate, unsupported_reason(:control)) unless supports?(:control) - end + supports(:terminate) { unsupported_reason(:control) } end def raw_destroy diff --git a/app/models/manageiq/providers/openstack/cloud_manager/vm/operations/guest.rb b/app/models/manageiq/providers/openstack/cloud_manager/vm/operations/guest.rb index fb98ee97..f9fa9228 100644 --- a/app/models/manageiq/providers/openstack/cloud_manager/vm/operations/guest.rb +++ b/app/models/manageiq/providers/openstack/cloud_manager/vm/operations/guest.rb @@ -3,13 +3,19 @@ module ManageIQ::Providers::Openstack::CloudManager::Vm::Operations::Guest included do supports :reboot_guest do - unsupported_reason_add(:reboot_guest, unsupported_reason(:control)) unless supports?(:control) - unsupported_reason_add(:reboot_guest, _("The VM is not powered on")) unless current_state == "on" + if current_state != "on" + _("The VM is not powered on") + else + unsupported_reason(:control) + end end supports :reset do - unsupported_reason_add(:reset, unsupported_reason(:control)) unless supports?(:control) - unsupported_reason_add(:reset, _("The VM is not powered on")) unless current_state == "on" + if current_state != "on" + _("The VM is not powered on") + else + unsupported_reason(:control) + end end end diff --git a/app/models/manageiq/providers/openstack/cloud_manager/vm/operations/power.rb b/app/models/manageiq/providers/openstack/cloud_manager/vm/operations/power.rb index d57a4446..b33715de 100644 --- a/app/models/manageiq/providers/openstack/cloud_manager/vm/operations/power.rb +++ b/app/models/manageiq/providers/openstack/cloud_manager/vm/operations/power.rb @@ -2,15 +2,19 @@ module ManageIQ::Providers::Openstack::CloudManager::Vm::Operations::Power extend ActiveSupport::Concern included do supports :shelve do - msg = unsupported_reason(:control) unless supports_control? - msg ||= _("The VM can't be shelved, current state has to be powered on, off, suspended or paused") unless %w(on off suspended paused).include?(current_state) - unsupported_reason_add(:shelve, msg) if msg + if %w[on off suspended paused].exclude?(current_state) + _("The VM can't be shelved, current state has to be powered on, off, suspended or paused") + else + unsupported_reason(:control) + end end supports :shelve_offload do - msg = unsupported_reason(:control) unless supports_control? - msg ||= _("The VM can't be shelved offload, current state has to be shelved") unless %w(shelved).include?(current_state) - unsupported_reason_add(:shelve_offload, msg) if msg + if current_state != "shelved" + _("The VM can't be shelved offload, current state has to be shelved") + else + unsupported_reason(:control) + end end end diff --git a/app/models/manageiq/providers/openstack/cloud_manager/vm/operations/relocation.rb b/app/models/manageiq/providers/openstack/cloud_manager/vm/operations/relocation.rb index 3a5c29db..bedae4de 100644 --- a/app/models/manageiq/providers/openstack/cloud_manager/vm/operations/relocation.rb +++ b/app/models/manageiq/providers/openstack/cloud_manager/vm/operations/relocation.rb @@ -2,15 +2,9 @@ module ManageIQ::Providers::Openstack::CloudManager::Vm::Operations::Relocation extend ActiveSupport::Concern included do - supports :live_migrate do - unsupported_reason_add(:live_migrate, unsupported_reason(:control)) unless supports?(:control) - end - - supports_not :migrate, :reason => _("Migrate operation is not supported.") - - supports :evacuate do - unsupported_reason_add(:evacuate, unsupported_reason(:control)) unless supports?(:control) - end + supports(:evacuate) { unsupported_reason(:control) } + supports(:live_migrate) { unsupported_reason(:control) } + supports_not :migrate end def raw_live_migrate(options = {}) diff --git a/app/models/manageiq/providers/openstack/cloud_manager/vm/operations/snapshot.rb b/app/models/manageiq/providers/openstack/cloud_manager/vm/operations/snapshot.rb index f81307b1..c8029a77 100644 --- a/app/models/manageiq/providers/openstack/cloud_manager/vm/operations/snapshot.rb +++ b/app/models/manageiq/providers/openstack/cloud_manager/vm/operations/snapshot.rb @@ -2,38 +2,22 @@ module ManageIQ::Providers::Openstack::CloudManager::Vm::Operations::Snapshot extend ActiveSupport::Concern included do - supports :snapshot_create do - unless supports?(:control) - unsupported_reason_add(:snapshot_create, unsupported_reason(:control)) - end - end - + supports(:snapshot_create) { unsupported_reason(:control) } supports :remove_snapshot do if supports?(:snapshots) if snapshots.size <= 0 - unsupported_reason_add(:remove_snapshot, _("No snapshots available for this VM")) - end - unless supports?(:control) - unsupported_reason_add(:remove_snapshot, unsupported_reason(:control)) + _("No snapshots available for this VM") + else + unsupported_reason(:control) end else - unsupported_reason_add(:remove_snapshot, _("Operation not supported")) - end - end - - supports :remove_all_snapshots do - unless supports?(:remove_snapshot) - unsupported_reason_add(:remove_all_snapshots, unsupported_reason(:remove_snapshot)) + _("Operation not supported") end end - supports :remove_snapshot_by_description do - unsupported_reason_add(:remove_snapshot_by_description, _("Operation not supported")) - end - - supports :revert_to_snapshot do - unsupported_reason_add(:revert_to_snapshot, _("Operation not supported")) - end + supports(:remove_all_snapshots) { unsupported_reason(:remove_snapshot) } + supports_not :remove_snapshot_by_description + supports_not :revert_to_snapshot end def raw_create_snapshot(name, desc = nil, memory) diff --git a/app/models/manageiq/providers/openstack/cloud_manager/vm/resize.rb b/app/models/manageiq/providers/openstack/cloud_manager/vm/resize.rb index 8ede9968..860acd2e 100644 --- a/app/models/manageiq/providers/openstack/cloud_manager/vm/resize.rb +++ b/app/models/manageiq/providers/openstack/cloud_manager/vm/resize.rb @@ -3,10 +3,12 @@ module ManageIQ::Providers::Openstack::CloudManager::Vm::Resize included do supports :resize do - unsupported_reason_add(:resize, unsupported_reason(:control)) unless supports?(:control) - unsupported_reason_add(:resize, _('The VM is not connected to a provider')) unless ext_management_system - unless %w(ACTIVE SHUTOFF).include?(raw_power_state) - unsupported_reason_add(:resize, _("The Instance cannot be resized, current state has to be active or shutoff.")) + if !ext_management_system + _('The VM is not connected to a provider') + elsif %w[ACTIVE SHUTOFF].exclude?(raw_power_state) + _("The Instance cannot be resized, current state has to be active or shutoff.") + else + unsupported_reason(:control) end end end diff --git a/app/models/manageiq/providers/openstack/cloud_manager/vm_or_template_shared/scanning.rb b/app/models/manageiq/providers/openstack/cloud_manager/vm_or_template_shared/scanning.rb index af39c27f..00dcc17e 100644 --- a/app/models/manageiq/providers/openstack/cloud_manager/vm_or_template_shared/scanning.rb +++ b/app/models/manageiq/providers/openstack/cloud_manager/vm_or_template_shared/scanning.rb @@ -2,12 +2,7 @@ module ManageIQ::Providers::Openstack::CloudManager::VmOrTemplateShared::Scannin extend ActiveSupport::Concern included do - supports :smartstate_analysis do - feature_supported, reason = check_feature_support('smartstate_analysis') - unless feature_supported - unsupported_reason_add(:smartstate_analysis, reason) - end - end + supports(:smartstate_analysis) { unsupported_reason(:action) } end # diff --git a/app/models/manageiq/providers/openstack/infra_manager.rb b/app/models/manageiq/providers/openstack/infra_manager.rb index 1e3d90cb..67c661c3 100644 --- a/app/models/manageiq/providers/openstack/infra_manager.rb +++ b/app/models/manageiq/providers/openstack/infra_manager.rb @@ -12,7 +12,7 @@ class ManageIQ::Providers::Openstack::InfraManager < ManageIQ::Providers::InfraM supports :catalog supports :metrics supports :events do - unsupported_reason_add(:events, _("Events are not supported")) unless capabilities["events"] + _("Events are not supported") unless capabilities["events"] end supports_not :shutdown diff --git a/app/models/manageiq/providers/openstack/infra_manager/host.rb b/app/models/manageiq/providers/openstack/infra_manager/host.rb index 2cc99706..1c4b9085 100644 --- a/app/models/manageiq/providers/openstack/infra_manager/host.rb +++ b/app/models/manageiq/providers/openstack/infra_manager/host.rb @@ -25,10 +25,10 @@ class ManageIQ::Providers::Openstack::InfraManager::Host < ::Host supports :set_node_maintenance supports :unset_node_maintenance supports :start do - unsupported_reason_add(:start, _("Cannot start. Already on.")) unless state.casecmp("off") == 0 + _("Cannot start. Already on.") unless state.casecmp("off") == 0 end supports :stop do - unsupported_reason_add(:stop, _("Cannot stop. Already off.")) unless state.casecmp("on") == 0 + _("Cannot stop. Already off.") unless state.casecmp("on") == 0 end # TODO(lsmola) for some reason UI can't handle joined table cause there is hardcoded somewhere that it selects @@ -542,7 +542,7 @@ def stop(userid = "system") supports :destroy do if !archived? && hardware.provision_state == "active" - unsupported_reason_add(:destroy, "Cannot remove #{name} because it is in #{hardware.provision_state} state.") + "Cannot remove #{name} because it is in #{hardware.provision_state} state." end end diff --git a/app/models/manageiq/providers/openstack/infra_manager/template.rb b/app/models/manageiq/providers/openstack/infra_manager/template.rb index a6c8d1fc..aed6b74b 100644 --- a/app/models/manageiq/providers/openstack/infra_manager/template.rb +++ b/app/models/manageiq/providers/openstack/infra_manager/template.rb @@ -1,12 +1,7 @@ class ManageIQ::Providers::Openstack::InfraManager::Template < ManageIQ::Providers::InfraManager::Template belongs_to :cloud_tenant - supports :smartstate_analysis do - feature_supported, reason = check_feature_support('smartstate_analysis') - unless feature_supported - unsupported_reason_add(:smartstate_analysis, reason) - end - end + supports(:smartstate_analysis) { unsupported_reason(:active) } supports_not :clone def provider_object(connection = nil) diff --git a/app/models/manageiq/providers/openstack/network_manager/cloud_network.rb b/app/models/manageiq/providers/openstack/network_manager/cloud_network.rb index 3ee881ed..2c6dbc27 100644 --- a/app/models/manageiq/providers/openstack/network_manager/cloud_network.rb +++ b/app/models/manageiq/providers/openstack/network_manager/cloud_network.rb @@ -9,17 +9,17 @@ class ManageIQ::Providers::Openstack::NetworkManager::CloudNetwork < ::CloudNetw supports :delete do if ext_management_system.nil? - unsupported_reason_add(:delete_cloud_network, _("The Cloud Network is not connected to an active %{table}") % { + _("The Cloud Network is not connected to an active %{table}") % { :table => ui_lookup(:table => "ext_management_systems") - }) + } end end supports :update do if ext_management_system.nil? - unsupported_reason_add(:update_cloud_network, _("The Cloud Network is not connected to an active %{table}") % { + _("The Cloud Network is not connected to an active %{table}") % { :table => ui_lookup(:table => "ext_management_systems") - }) + } end end diff --git a/app/models/manageiq/providers/openstack/network_manager/cloud_subnet.rb b/app/models/manageiq/providers/openstack/network_manager/cloud_subnet.rb index 398c7dad..acf75926 100644 --- a/app/models/manageiq/providers/openstack/network_manager/cloud_subnet.rb +++ b/app/models/manageiq/providers/openstack/network_manager/cloud_subnet.rb @@ -6,21 +6,20 @@ class ManageIQ::Providers::Openstack::NetworkManager::CloudSubnet < ::CloudSubne supports :create supports :delete do if ext_management_system.nil? - unsupported_reason_add(:delete, _("The subnet is not connected to an active %{table}") % { + _("The subnet is not connected to an active %{table}") % { :table => ui_lookup(:table => "ext_management_systems") - }) - end - if number_of(:vms) > 0 - unsupported_reason_add(:delete, _("The subnet has an active %{table}") % { + } + elsif number_of(:vms) > 0 + _("The subnet has an active %{table}") % { :table => ui_lookup(:table => "vm_cloud") - }) + } end end supports :update do if ext_management_system.nil? - unsupported_reason_add(:update, _("The subnet is not connected to an active %{table}") % { + _("The subnet is not connected to an active %{table}") % { :table => ui_lookup(:table => "ext_management_systems") - }) + } end end diff --git a/app/models/manageiq/providers/openstack/network_manager/floating_ip.rb b/app/models/manageiq/providers/openstack/network_manager/floating_ip.rb index 31cab281..30fa70c7 100644 --- a/app/models/manageiq/providers/openstack/network_manager/floating_ip.rb +++ b/app/models/manageiq/providers/openstack/network_manager/floating_ip.rb @@ -7,17 +7,17 @@ class ManageIQ::Providers::Openstack::NetworkManager::FloatingIp < ::FloatingIp supports :delete do if ext_management_system.nil? - unsupported_reason_add(:delete_floating, _("The Floating Ip is not connected to an active %{table}") % { + _("The Floating Ip is not connected to an active %{table}") % { :table => ui_lookup(:table => "ext_management_systems") - }) + } end end supports :update do if ext_management_system.nil? - unsupported_reason_add(:update_floating_ip, _("The Floating Ip is not connected to an active %{table}") % { + _("The Floating Ip is not connected to an active %{table}") % { :table => ui_lookup(:table => "ext_management_systems") - }) + } end end diff --git a/app/models/manageiq/providers/openstack/network_manager/network_router.rb b/app/models/manageiq/providers/openstack/network_manager/network_router.rb index 568ac788..4ee71eca 100644 --- a/app/models/manageiq/providers/openstack/network_manager/network_router.rb +++ b/app/models/manageiq/providers/openstack/network_manager/network_router.rb @@ -9,22 +9,21 @@ class ManageIQ::Providers::Openstack::NetworkManager::NetworkRouter < ::NetworkR supports :delete do if ext_management_system.nil? - unsupported_reason_add(:delete, _("The Network Router is not connected to an active %{table}") % { + _("The Network Router is not connected to an active %{table}") % { :table => ui_lookup(:table => "ext_management_systems") - }) - end - if network_ports.any? - unsupported_reason_add(:delete, _("Unable to delete \"%{name}\" because it has associated ports.") % { + } + elsif network_ports.any? + _("Unable to delete \"%{name}\" because it has associated ports.") % { :name => name - }) + } end end supports :update do if ext_management_system.nil? - unsupported_reason_add(:update, _("The Network Router is not connected to an active %{table}") % { + _("The Network Router is not connected to an active %{table}") % { :table => ui_lookup(:table => "ext_management_systems") - }) + } end end diff --git a/app/models/manageiq/providers/openstack/network_manager/security_group.rb b/app/models/manageiq/providers/openstack/network_manager/security_group.rb index 7b46ed6d..2b813748 100644 --- a/app/models/manageiq/providers/openstack/network_manager/security_group.rb +++ b/app/models/manageiq/providers/openstack/network_manager/security_group.rb @@ -5,17 +5,17 @@ class ManageIQ::Providers::Openstack::NetworkManager::SecurityGroup < ::Security supports :delete do if ext_management_system.nil? - unsupported_reason_add(:delete_security_group, _("The Security Group is not connected to an active %{table}") % { + _("The Security Group is not connected to an active %{table}") % { :table => ui_lookup(:table => "ext_management_systems") - }) + } end end supports :update do if ext_management_system.nil? - unsupported_reason_add(:update_security_group, _("The Security Group is not connected to an active %{table}") % { + _("The Security Group is not connected to an active %{table}") % { :table => ui_lookup(:table => "ext_management_systems") - }) + } end end diff --git a/app/models/manageiq/providers/openstack/storage_manager/cinder_manager/cloud_volume.rb b/app/models/manageiq/providers/openstack/storage_manager/cinder_manager/cloud_volume.rb index 8d6b4c3c..5019f30a 100644 --- a/app/models/manageiq/providers/openstack/storage_manager/cinder_manager/cloud_volume.rb +++ b/app/models/manageiq/providers/openstack/storage_manager/cinder_manager/cloud_volume.rb @@ -6,12 +6,15 @@ class ManageIQ::Providers::Openstack::StorageManager::CinderManager::CloudVolume supports :backup_restore supports :create supports :delete do - unsupported_reason_add(:delete, _("the volume is not connected to an active Provider")) unless ext_management_system - unsupported_reason_add(:delete, _("cannot delete volume that is in use.")) if status == "in-use" + if !ext_management_system + _("the volume is not connected to an active Provider") + elsif status == "in-use" + _("cannot delete volume that is in use.") + end end supports :snapshot_create supports :update do - unsupported_reason_add(:update, _("The Volume is not connected to an active Provider")) unless ext_management_system + _("The Volume is not connected to an active Provider") unless ext_management_system end def self.params_for_create(ems) diff --git a/app/models/manageiq/providers/openstack/storage_manager/cinder_manager/cloud_volume/operations.rb b/app/models/manageiq/providers/openstack/storage_manager/cinder_manager/cloud_volume/operations.rb index 903f8cc8..ef5829a8 100644 --- a/app/models/manageiq/providers/openstack/storage_manager/cinder_manager/cloud_volume/operations.rb +++ b/app/models/manageiq/providers/openstack/storage_manager/cinder_manager/cloud_volume/operations.rb @@ -3,12 +3,19 @@ module ManageIQ::Providers::Openstack::StorageManager::CinderManager::CloudVolum included do supports :attach do - unsupported_reason_add(:attach, _("the volume is not connected to an active Provider")) unless ext_management_system - unsupported_reason_add(:attach, _("the volume status is '%{status}' but should be 'available'") % {:status => status}) unless status == "available" + if !ext_management_system + _("the volume is not connected to an active Provider") + elsif status != "available" + _("the volume status is '%{status}' but should be 'available'") % {:status => status} + end end + supports :detach do - unsupported_reason_add(:detach, _("the volume is not connected to an active Provider")) unless ext_management_system - unsupported_reason_add(:detach, _("the volume status is '%{status}' but should be 'in-use'") % {:status => status}) unless status == "in-use" + if !ext_management_system + _("the volume is not connected to an active Provider") + elsif status != "in-use" + _("the volume status is '%{status}' but should be 'in-use'") % {:status => status} + end end end diff --git a/app/models/manageiq/providers/openstack/storage_manager/swift_manager.rb b/app/models/manageiq/providers/openstack/storage_manager/swift_manager.rb index 48440aff..7a476944 100644 --- a/app/models/manageiq/providers/openstack/storage_manager/swift_manager.rb +++ b/app/models/manageiq/providers/openstack/storage_manager/swift_manager.rb @@ -21,10 +21,9 @@ class ManageIQ::Providers::Openstack::StorageManager::SwiftManager < ManageIQ::P supports :swift_service do if parent_manager - unsupported_reason_add(:swift_service, parent_manager.unsupported_reason(:swift_service)) unless - parent_manager.supports?(:swift_service) + parent_manager.unsupported_reason(:swift_service) else - unsupported_reason_add(:swift_service, _('no parent_manager to ems')) + _('no parent_manager to ems') end end From 137c279a0ef96a07ba3a128602a06fff043ef96f Mon Sep 17 00:00:00 2001 From: Keenan Brock Date: Thu, 29 Feb 2024 09:44:28 -0500 Subject: [PATCH 3/9] convert supports_event to supports :event --- .../manageiq/providers/openstack/network_manager.rb | 9 ++++++++- .../openstack/storage_manager/cinder_manager.rb | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/models/manageiq/providers/openstack/network_manager.rb b/app/models/manageiq/providers/openstack/network_manager.rb index 66b50aff..69a9d5f6 100644 --- a/app/models/manageiq/providers/openstack/network_manager.rb +++ b/app/models/manageiq/providers/openstack/network_manager.rb @@ -5,6 +5,14 @@ class ManageIQ::Providers::Openstack::NetworkManager < ManageIQ::Providers::Netw supports :create_network_router supports :cloud_subnet_create + supports :events do + if parent_manager + parent_manager.unsupported_reason(:events) + else + _('no parent_manager to ems') + end + end + has_many :public_networks, :foreign_key => :ems_id, :dependent => :destroy, :class_name => "ManageIQ::Providers::Openstack::NetworkManager::CloudNetwork::Public" has_many :private_networks, :foreign_key => :ems_id, :dependent => :destroy, @@ -26,7 +34,6 @@ class ManageIQ::Providers::Openstack::NetworkManager < ManageIQ::Providers::Netw :hostname, :default_endpoint, :endpoints, - :supports_events?, :to => :parent_manager, :allow_nil => true diff --git a/app/models/manageiq/providers/openstack/storage_manager/cinder_manager.rb b/app/models/manageiq/providers/openstack/storage_manager/cinder_manager.rb index 96ecd6ae..240611ed 100644 --- a/app/models/manageiq/providers/openstack/storage_manager/cinder_manager.rb +++ b/app/models/manageiq/providers/openstack/storage_manager/cinder_manager.rb @@ -9,6 +9,14 @@ class ManageIQ::Providers::Openstack::StorageManager::CinderManager < ManageIQ:: supports :cloud_volume supports :cloud_volume_create + supports :events do + if parent_manager + parent_manager.unsupported_reason(:events) + else + _('no parent_manager to ems') + end + end + # Auth and endpoints delegations, editing of this type of manager must be disabled delegate :authentication_check, :authentication_status, @@ -27,7 +35,6 @@ class ManageIQ::Providers::Openstack::StorageManager::CinderManager < ManageIQ:: :endpoints, :cloud_tenants, :volume_availability_zones, - :supports_events?, :to => :parent_manager, :allow_nil => true From ce4c7f873ddc4b48146e4e9a9f9f4d18b38beb87 Mon Sep 17 00:00:00 2001 From: Jason Frey Date: Fri, 1 Mar 2024 14:51:38 -0500 Subject: [PATCH 4/9] Update codeclimate channel to the latest in manageiq-style --- .codeclimate.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.codeclimate.yml b/.codeclimate.yml index 03a5e6c5..bce511ef 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -31,7 +31,7 @@ plugins: rubocop: enabled: true config: ".rubocop_cc.yml" - channel: rubocop-0-82 + channel: rubocop-1-56-3 exclude_patterns: - node_modules/ - spec/ From 17a4c6adb2e7e79df15e61fb2353450be6ebcdc8 Mon Sep 17 00:00:00 2001 From: Adam Grare Date: Tue, 12 Mar 2024 10:54:13 -0400 Subject: [PATCH 5/9] Only check for duplicate endpoints for CloudManagers Fix hostname_uniqueness_valid? failing if an `Openstack::InfraManager` has the same connection details as an `Openstack::CloudManager` --- .../providers/openstack/cloud_manager.rb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/models/manageiq/providers/openstack/cloud_manager.rb b/app/models/manageiq/providers/openstack/cloud_manager.rb index dd477de8..cc18be9b 100644 --- a/app/models/manageiq/providers/openstack/cloud_manager.rb +++ b/app/models/manageiq/providers/openstack/cloud_manager.rb @@ -518,14 +518,15 @@ def hostname_uniqueness_valid? return unless hostname_required? return unless hostname.present? # Presence is checked elsewhere - existing_providers = Endpoint.where(:hostname => hostname.downcase) - .where.not(:resource_id => id).includes(:resource) - .select do |endpoint| - unless endpoint.resource.nil? - endpoint.resource.uid_ems == keystone_v3_domain_id && - endpoint.resource.provider_region == provider_region - end - end + existing_providers = + self.class + .joins(:endpoints) + .where.not(:id => id) + .where( + :endpoints => {:hostname => hostname.downcase}, + :uid_ems => keystone_v3_domain_id, + :provider_region => provider_region + ) errors.add(:hostname, "has already been taken") if existing_providers.any? end From 18b32dbfacbabfd1418b97f91ad534728d40c5c3 Mon Sep 17 00:00:00 2001 From: Adam Grare Date: Tue, 12 Mar 2024 11:15:16 -0400 Subject: [PATCH 6/9] Refactor openstack cloud validation specs --- .rubocop_local.yml | 1 + .../providers/openstack/cloud_manager_spec.rb | 99 ++++++++++--------- 2 files changed, 52 insertions(+), 48 deletions(-) diff --git a/.rubocop_local.yml b/.rubocop_local.yml index 1ea938cb..545ce1c5 100644 --- a/.rubocop_local.yml +++ b/.rubocop_local.yml @@ -1,3 +1,4 @@ Style/GlobalVars: AllowedVariables: - $fog_log + - $log diff --git a/spec/models/manageiq/providers/openstack/cloud_manager_spec.rb b/spec/models/manageiq/providers/openstack/cloud_manager_spec.rb index e5614f44..0f5db281 100644 --- a/spec/models/manageiq/providers/openstack/cloud_manager_spec.rb +++ b/spec/models/manageiq/providers/openstack/cloud_manager_spec.rb @@ -225,65 +225,68 @@ def lastlog end context "validation" do - before :each do - @ems = FactoryBot.create(:ems_openstack_with_authentication) - require 'manageiq/providers/openstack/legacy/openstack_event_monitor' - end + let!(:ems) { FactoryBot.create(:ems_openstack_with_authentication) } it "verifies AMQP credentials" do EvmSpecHelper.stub_amqp_support creds = {} creds[:amqp] = {:userid => "amqp_user", :password => "amqp_password"} - @ems.endpoints << Endpoint.create(:role => 'amqp', :hostname => 'amqp_hostname', :port => '5672') - @ems.update_authentication(creds, :save => false) - expect(@ems.verify_credentials(:amqp)).to be_truthy - end - - it "indicates that an event monitor is available" do - allow(OpenstackEventMonitor).to receive(:available?).and_return(true) - expect(@ems.event_monitor_available?).to be_truthy - end - - it "indicates that an event monitor is not available" do - allow(OpenstackEventMonitor).to receive(:available?).and_return(false) - expect(@ems.event_monitor_available?).to be_falsey - end - - it "logs an error and indicates that an event monitor is not available when there's an error checking for an event monitor" do - allow(OpenstackEventMonitor).to receive(:available?).and_raise(StandardError) - expect($log).to receive(:error).with(/Exception trying to find openstack event monitor./) - expect($log).to receive(:error) - expect(@ems.event_monitor_available?).to be_falsey - end - - it "fails uniqueness check for same hostname with same or without domains and regions" do - dup_ems = FactoryBot.build(:ems_openstack_with_authentication) - taken_hostname = @ems.endpoints.first.hostname - dup_ems.endpoints.first.hostname = taken_hostname - expect(dup_ems.valid?).to be_falsey + ems.endpoints << Endpoint.create(:role => 'amqp', :hostname => 'amqp_hostname', :port => '5672') + ems.update_authentication(creds, :save => false) + expect(ems.verify_credentials(:amqp)).to be_truthy end - it "passes uniqueness check for same hostname with different domain" do - dup_ems = FactoryBot.build(:ems_openstack_with_authentication, :uid_ems => 'my_domain') - taken_hostname = @ems.endpoints.first.hostname - dup_ems.endpoints.first.hostname = taken_hostname - expect(dup_ems.valid?).to be_truthy - end + describe "event_monitor_available?" do + require 'manageiq/providers/openstack/legacy/openstack_event_monitor' - it "passes uniqueness check for same hostname with different region" do - dup_ems = FactoryBot.build(:ems_openstack_with_authentication, :provider_region => 'RegionTwo') - taken_hostname = @ems.endpoints.first.hostname - dup_ems.endpoints.first.hostname = taken_hostname - expect(dup_ems.valid?).to be_truthy + it "indicates that an event monitor is available" do + allow(OpenstackEventMonitor).to receive(:available?).and_return(true) + expect(ems.event_monitor_available?).to be_truthy + end + + it "indicates that an event monitor is not available" do + allow(OpenstackEventMonitor).to receive(:available?).and_return(false) + expect(ems.event_monitor_available?).to be_falsey + end + + it "logs an error and indicates that an event monitor is not available when there's an error checking for an event monitor" do + allow(OpenstackEventMonitor).to receive(:available?).and_raise(StandardError) + expect($log).to receive(:error).with(/Exception trying to find openstack event monitor./) + expect($log).to receive(:error) + expect(ems.event_monitor_available?).to be_falsey + end end - it "passes uniqueness check for same hostname with different domain and region" do - dup_ems = FactoryBot.build(:ems_openstack_with_authentication, - :uid_ems => 'my_domain', :provider_region => 'RegionTwo') - taken_hostname = @ems.endpoints.first.hostname - dup_ems.endpoints.first.hostname = taken_hostname - expect(dup_ems.valid?).to be_truthy + describe "#hostname_uniqueness_valid?" do + it "fails uniqueness check for same hostname with same or without domains and regions" do + dup_ems = FactoryBot.build(:ems_openstack_with_authentication) + taken_hostname = ems.endpoints.first.hostname + dup_ems.endpoints.first.hostname = taken_hostname + expect(dup_ems.valid?).to be_falsey + end + + it "passes uniqueness check for same hostname with different domain" do + dup_ems = FactoryBot.build(:ems_openstack_with_authentication, :uid_ems => 'my_domain') + taken_hostname = ems.endpoints.first.hostname + dup_ems.endpoints.first.hostname = taken_hostname + expect(dup_ems.valid?).to be_truthy + end + + it "passes uniqueness check for same hostname with different region" do + dup_ems = FactoryBot.build(:ems_openstack_with_authentication, :provider_region => 'RegionTwo') + taken_hostname = ems.endpoints.first.hostname + dup_ems.endpoints.first.hostname = taken_hostname + expect(dup_ems.valid?).to be_truthy + end + + it "passes uniqueness check for same hostname with different domain and region" do + dup_ems = FactoryBot.build(:ems_openstack_with_authentication, + :uid_ems => 'my_domain', :provider_region => 'RegionTwo') + taken_hostname = ems.endpoints.first.hostname + dup_ems.endpoints.first.hostname = taken_hostname + expect(dup_ems.valid?).to be_truthy + end end end From 507539944f626b8435da1bcc2b5ce500cb916b4f Mon Sep 17 00:00:00 2001 From: Adam Grare Date: Tue, 12 Mar 2024 11:15:30 -0400 Subject: [PATCH 7/9] Add spec test covering existing InfraManager --- .../providers/openstack/cloud_manager_spec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spec/models/manageiq/providers/openstack/cloud_manager_spec.rb b/spec/models/manageiq/providers/openstack/cloud_manager_spec.rb index 0f5db281..0c6ceb3d 100644 --- a/spec/models/manageiq/providers/openstack/cloud_manager_spec.rb +++ b/spec/models/manageiq/providers/openstack/cloud_manager_spec.rb @@ -266,6 +266,10 @@ def lastlog expect(dup_ems.valid?).to be_falsey end + it "passes uniqueness check for own ems" do + expect(ems.valid?).to be_truthy + end + it "passes uniqueness check for same hostname with different domain" do dup_ems = FactoryBot.build(:ems_openstack_with_authentication, :uid_ems => 'my_domain') taken_hostname = ems.endpoints.first.hostname @@ -287,6 +291,15 @@ def lastlog dup_ems.endpoints.first.hostname = taken_hostname expect(dup_ems.valid?).to be_truthy end + + context "with an InfraManager" do + let!(:ems) { FactoryBot.create(:ems_openstack_infra) } + + it "passes uniqueness check with with same hostname domain and region" do + new_ems = FactoryBot.build(:ems_openstack_with_authentication, :hostname => ems.hostname, :uid_ems => ems.uid_ems, :provider_region => ems.provider_region) + expect(new_ems.valid?).to be_truthy + end + end end end From df15eaa88a3593a46423be329f14eade385b551f Mon Sep 17 00:00:00 2001 From: Keenan Brock Date: Thu, 4 Apr 2024 10:15:13 -0400 Subject: [PATCH 8/9] fix spec for supports_feature change Since we will be no longer storing the `unsupported_reason` in a temporary variable, calling `supports?()` and `unsupported_reason()` each check the `supports :feature` code. So in this test, it calls it 2 times. I removed the stub to allow the ems to be called multiple times without freaking a stub out Alternative would have been to add to the ems stub: `at_least(1).times` --- .../storage_manager/cinder_manager/cloud_volume_spec.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/spec/models/manageiq/providers/openstack/storage_manager/cinder_manager/cloud_volume_spec.rb b/spec/models/manageiq/providers/openstack/storage_manager/cinder_manager/cloud_volume_spec.rb index 007c7a4e..051bcd3f 100644 --- a/spec/models/manageiq/providers/openstack/storage_manager/cinder_manager/cloud_volume_spec.rb +++ b/spec/models/manageiq/providers/openstack/storage_manager/cinder_manager/cloud_volume_spec.rb @@ -20,13 +20,11 @@ let(:raw_volumes) do double.tap do |volumes| - handle = double - allow(handle).to receive(:volumes).and_return(volumes) allow(ExtManagementSystem).to receive(:find).with(ems.id).and_return(ems) allow(ExtManagementSystem).to receive(:find).with(ems.parent_manager.id).and_return(ems.parent_manager) allow(ems.parent_manager).to receive(:connect) .with(hash_including(:service => 'Volume', :tenant_name => tenant.name)) - .and_return(handle) + .and_return(double(:volumes => volumes)) allow(volumes).to receive(:get).with(cloud_volume.ems_ref).and_return(the_raw_volume) end end @@ -86,7 +84,7 @@ end it "validates the volume update operation when ems is missing" do - expect(cloud_volume).to receive(:ext_management_system).and_return(nil) + cloud_volume.ext_management_system = nil expect(cloud_volume.supports?(:update)).to be_falsy expect(cloud_volume.unsupported_reason(:update)).to eq("The Volume is not connected to an active Provider") end From acaf9727b801af4a8efa500151ceb73d94678dcf Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 26 Apr 2024 16:56:05 +0000 Subject: [PATCH 9/9] Update paambaati/codeclimate-action action to v6 --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2cb28e41..6a8b9bb5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -47,4 +47,4 @@ jobs: - name: Report code coverage if: "${{ github.ref == 'refs/heads/master' && matrix.ruby-version == '3.0' }}" continue-on-error: true - uses: paambaati/codeclimate-action@v5 + uses: paambaati/codeclimate-action@v6