From dad194dc9092d0cbe8888996e35651f48f31e3be Mon Sep 17 00:00:00 2001 From: "Saulo S. Toledo" Date: Fri, 11 May 2018 11:16:45 -0300 Subject: [PATCH] Add methods to process the refesh action for a PhysicalSwitch --- app/models/physical_switch.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/models/physical_switch.rb b/app/models/physical_switch.rb index e95721dd126..6d8b5bb2cd9 100644 --- a/app/models/physical_switch.rb +++ b/app/models/physical_switch.rb @@ -3,4 +3,23 @@ class PhysicalSwitch < Switch has_one :hardware, :dependent => :destroy, :foreign_key => :switch_id, :inverse_of => :physical_switch belongs_to :ext_management_system, :foreign_key => :ems_id, :inverse_of => :physical_switches + + def my_zone + ems = ext_management_system + ems ? ems.my_zone : MiqServer.my_zone + end + + def refresh_ems + unless ext_management_system + raise _("No Provider defined") + end + unless ext_management_system.has_credentials? + raise _("No Provider credentials defined") + end + unless ext_management_system.authentication_status_ok? + raise _("Provider failed last authentication check") + end + + EmsRefresh.queue_refresh(ext_management_system) + end end