From d5b3c09c7acdac1262695859a76697e8a1844d2a Mon Sep 17 00:00:00 2001 From: Hilda Stastna Date: Tue, 4 Sep 2018 15:20:34 +0200 Subject: [PATCH] Add refresh relationships and power states support to various models --- app/models/ext_management_system.rb | 2 ++ app/models/host.rb | 1 + app/models/orchestration_stack.rb | 1 + app/models/physical_chassis.rb | 2 ++ app/models/physical_rack.rb | 2 ++ app/models/physical_server.rb | 2 ++ app/models/physical_storage.rb | 2 ++ app/models/physical_switch.rb | 2 ++ app/models/provider.rb | 2 ++ 9 files changed, 16 insertions(+) diff --git a/app/models/ext_management_system.rb b/app/models/ext_management_system.rb index a2e03a3d0dd0..a047ff75be12 100644 --- a/app/models/ext_management_system.rb +++ b/app/models/ext_management_system.rb @@ -90,6 +90,8 @@ def self.api_allowed_attributes serialize :options + supports :refresh_ems + def hostname_uniqueness_valid? return unless hostname_required? return unless hostname.present? # Presence is checked elsewhere diff --git a/app/models/host.rb b/app/models/host.rb index 11c1a28a06d1..09b32a99dcf2 100644 --- a/app/models/host.rb +++ b/app/models/host.rb @@ -183,6 +183,7 @@ class Host < ApplicationRecord unsupported_reason_add(:reset, _("The Host has invalid IPMI credentials")) end end + supports :refresh_ems def self.non_clustered where(:ems_cluster_id => nil) diff --git a/app/models/orchestration_stack.rb b/app/models/orchestration_stack.rb index 3977480958b2..6db43dd36d47 100644 --- a/app/models/orchestration_stack.rb +++ b/app/models/orchestration_stack.rb @@ -54,6 +54,7 @@ class OrchestrationStack < ApplicationRecord alias_method :orchestration_stack_outputs, :outputs alias_method :orchestration_stack_resources, :resources + supports :refresh_ems supports :retire def orchestration_stacks diff --git a/app/models/physical_chassis.rb b/app/models/physical_chassis.rb index 9ceea6403931..8be696f247e5 100644 --- a/app/models/physical_chassis.rb +++ b/app/models/physical_chassis.rb @@ -17,6 +17,8 @@ class PhysicalChassis < ApplicationRecord has_one :asset_detail, :as => :resource, :dependent => :destroy, :inverse_of => false has_many :guest_devices, :through => :hardware + supports :refresh_ems + def my_zone ems = ext_management_system ems ? ems.my_zone : MiqServer.my_zone diff --git a/app/models/physical_rack.rb b/app/models/physical_rack.rb index fc45f45d757a..d2790f5f51cc 100644 --- a/app/models/physical_rack.rb +++ b/app/models/physical_rack.rb @@ -7,6 +7,8 @@ class PhysicalRack < ApplicationRecord has_many :physical_servers, :dependent => :nullify, :inverse_of => :physical_rack has_many :physical_storages, :dependent => :nullify, :inverse_of => :physical_rack + supports :refresh_ems + def my_zone ems = ext_management_system ems ? ems.my_zone : MiqServer.my_zone diff --git a/app/models/physical_server.rb b/app/models/physical_server.rb index 4476f889a22f..3b1ee0693584 100644 --- a/app/models/physical_server.rb +++ b/app/models/physical_server.rb @@ -36,6 +36,8 @@ class PhysicalServer < ApplicationRecord has_many :physical_switches, :through => :computer_system, :source => :connected_physical_switches + supports :refresh_ems + def name_with_details details % { :name => name, diff --git a/app/models/physical_storage.rb b/app/models/physical_storage.rb index 01243c690800..320132cdb794 100644 --- a/app/models/physical_storage.rb +++ b/app/models/physical_storage.rb @@ -13,6 +13,8 @@ class PhysicalStorage < ApplicationRecord has_many :physical_disks, :dependent => :destroy, :inverse_of => :physical_storage + supports :refresh_ems + def my_zone ems = ext_management_system ems ? ems.my_zone : MiqServer.my_zone diff --git a/app/models/physical_switch.rb b/app/models/physical_switch.rb index 3dec23ac39cb..cf4b6011e37d 100644 --- a/app/models/physical_switch.rb +++ b/app/models/physical_switch.rb @@ -19,6 +19,8 @@ class PhysicalSwitch < Switch alias_attribute :physical_servers, :connected_physical_servers + supports :refresh_ems + def my_zone ems = ext_management_system ems ? ems.my_zone : MiqServer.my_zone diff --git a/app/models/provider.rb b/app/models/provider.rb index 43778b4e632e..65574978757b 100644 --- a/app/models/provider.rb +++ b/app/models/provider.rb @@ -20,6 +20,8 @@ class Provider < ApplicationRecord virtual_column :verify_ssl, :type => :integer virtual_column :security_protocol, :type => :string + supports :refresh_ems + def self.leaf_subclasses descendants.select { |d| d.subclasses.empty? } end