Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into radjabov
Browse files Browse the repository at this point in the history
  • Loading branch information
Fryguy committed May 22, 2024
2 parents 888a39f + 4cdece9 commit 00e8c47
Show file tree
Hide file tree
Showing 30 changed files with 140 additions and 144 deletions.
2 changes: 1 addition & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,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
11 changes: 5 additions & 6 deletions app/models/manageiq/providers/openstack/cloud_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

#
Expand Down
2 changes: 1 addition & 1 deletion app/models/manageiq/providers/openstack/infra_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions app/models/manageiq/providers/openstack/infra_manager/host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
9 changes: 8 additions & 1 deletion app/models/manageiq/providers/openstack/network_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -26,7 +34,6 @@ class ManageIQ::Providers::Openstack::NetworkManager < ManageIQ::Providers::Netw
:hostname,
:default_endpoint,
:endpoints,
:supports_events?,
:to => :parent_manager,
:allow_nil => true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading

0 comments on commit 00e8c47

Please sign in to comment.