Skip to content

Commit

Permalink
Remove alias_attribute on non-attributes
Browse files Browse the repository at this point in the history
Fixes deprecation of this variety:

Foo model aliases `x`, but `x` is not an attribute. Starting in Rails 7.2, alias_attribute with non-attribute targets will raise. Use `alias_method :y, :x` or define the method manually.
  • Loading branch information
jrafanie committed Dec 12, 2024
1 parent 6c76b19 commit fe9ba76
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 17 deletions.
3 changes: 2 additions & 1 deletion app/models/automation_request.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class AutomationRequest < MiqRequest
alias_attribute :automation_tasks, :miq_request_tasks
alias_method :automation_tasks, :miq_request_tasks
alias_method :automation_tasks=, :miq_request_tasks=

TASK_DESCRIPTION = N_('Automation Request')
DEFAULT_NAMESPACE = "SYSTEM"
Expand Down
3 changes: 2 additions & 1 deletion app/models/automation_task.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class AutomationTask < MiqRequestTask
alias_attribute :automation_request, :miq_request
alias_method :automation_request, :miq_request
alias_method :automation_request=, :miq_request=
AUTOMATE_DRIVES = false

def self.get_description(_request_obj)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ class ManageIQ::Providers::EmbeddedAutomationManager::Authentication < ManageIQ:
# other models

alias_attribute :manager_id, :resource_id
alias_attribute :manager, :resource
alias_method :manager, :resource
alias_method :manager=, :resource=

after_create :set_manager_ref

Expand Down
11 changes: 7 additions & 4 deletions app/models/miq_provision.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ class MiqProvision < MiqProvisionTask
include StateMachine
include Tagging

alias_attribute :miq_provision_request, :miq_request # Legacy provisioning support
alias_attribute :provision_type, :request_type # Legacy provisioning support
alias_attribute :vm, :destination
alias_attribute :vm_template, :source
alias_method :miq_provision_request, :miq_request # Legacy provisioning support
alias_method :miq_provision_request=, :miq_request= # Legacy provisioning support
alias_attribute :provision_type, :request_type # Legacy provisioning support
alias_method :vm, :destination
alias_method :vm=, :destination=
alias_method :vm_template, :source
alias_method :vm_template=, :source=

before_create :set_template_and_networking

Expand Down
7 changes: 5 additions & 2 deletions app/models/miq_provision_request.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
class MiqProvisionRequest < MiqRequest
alias_attribute :vm_template, :source
alias_attribute :provision_type, :request_type
alias_attribute :miq_provisions, :miq_request_tasks
alias_attribute :src_vm_id, :source_id

alias_method :vm_template, :source
alias_method :vm_template=, :source=
alias_method :miq_provisions, :miq_request_tasks
alias_method :miq_provisions=, :miq_request_tasks=

delegate :my_zone, :to => :source

TASK_DESCRIPTION = N_('VM Provisioning')
Expand Down
3 changes: 2 additions & 1 deletion app/models/persistent_volume.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ class PersistentVolume < ContainerVolume
delegate :name, :to => :parent, :prefix => true, :allow_nil => true
has_many :container_volumes, -> { where(:type => 'ContainerVolume') }, :through => :persistent_volume_claim
has_many :parents, -> { distinct }, :through => :container_volumes, :source_type => 'ContainerGroup'
alias_attribute :container_groups, :parents
alias_method :container_groups, :parents
alias_method :container_groups=, :parents=

virtual_attribute :parent_name, :string
virtual_attribute :storage_capacity, :string
Expand Down
3 changes: 2 additions & 1 deletion app/models/physical_switch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class PhysicalSwitch < Switch
:through => :connected_components,
:source => :managed_entity

alias_attribute :physical_servers, :connected_physical_servers
alias_method :physical_servers, :connected_physical_servers
alias_method :physical_servers=, :connected_physical_servers=

def my_zone
ems = ext_management_system
Expand Down
4 changes: 3 additions & 1 deletion app/models/resource_group.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
class ResourceGroup < ApplicationRecord
acts_as_miq_taggable
alias_attribute :images, :templates

belongs_to :ext_management_system, :foreign_key => :ems_id

Expand All @@ -13,4 +12,7 @@ class ResourceGroup < ApplicationRecord
has_many :cloud_networks, :dependent => :nullify
has_many :network_ports, :dependent => :nullify
has_many :security_groups, :dependent => :nullify

alias_method :images, :templates
alias_method :images=, :templates=
end
5 changes: 4 additions & 1 deletion app/models/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ class Service < ApplicationRecord
supports :retire

alias parent_service parent
alias_attribute :service, :parent

alias_method :service, :parent
alias_method :service=, :parent=

deprecate_attribute :display, :visible, :type => :boolean
virtual_belongs_to :service

Expand Down
3 changes: 2 additions & 1 deletion app/models/service_template_provision_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class ServiceTemplateProvisionRequest < MiqRequest

after_create :process_service_order

alias_attribute :service_template, :source
alias_method :service_template, :source
alias_method :service_template=, :source=

virtual_has_one :picture
virtual_has_one :service_template
Expand Down
3 changes: 2 additions & 1 deletion app/models/vm_migrate_task.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class VmMigrateTask < MiqRequestTask
alias_attribute :vm, :source
alias_method :vm, :source
alias_method :vm=, :source=

validate :validate_request_type, :validate_state
default_value_for :request_type, "vm_migrate"
Expand Down
3 changes: 2 additions & 1 deletion app/models/vm_reconfigure_task.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class VmReconfigureTask < MiqRequestTask
alias_attribute :vm, :source
alias_method :vm, :source
alias_method :vm=, :source=

validate :validate_request_type, :validate_state

Expand Down
3 changes: 2 additions & 1 deletion app/models/vm_retire_task.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class VmRetireTask < MiqRetireTask
alias_attribute :vm, :source
alias_method :vm, :source
alias_method :vm=, :source=
default_value_for :request_type, "vm_retire"

def self.base_model
Expand Down

0 comments on commit fe9ba76

Please sign in to comment.