From 257b0f9ae7bbdf2cf9e212c79cbce8f736e419e0 Mon Sep 17 00:00:00 2001 From: felipedf Date: Fri, 11 May 2018 14:30:18 -0300 Subject: [PATCH] Add a method to process the refesh action for a PhysicalRack --- app/models/physical_rack.rb | 19 +++++++++++++++++++ db/fixtures/miq_product_features.yml | 9 +++++++++ db/fixtures/miq_user_roles.yml | 1 + 3 files changed, 29 insertions(+) diff --git a/app/models/physical_rack.rb b/app/models/physical_rack.rb index 7a81c38b7fa..a37026d113b 100644 --- a/app/models/physical_rack.rb +++ b/app/models/physical_rack.rb @@ -6,4 +6,23 @@ class PhysicalRack < ApplicationRecord has_many :physical_chassis, :dependent => :nullify, :inverse_of => :physical_rack has_many :physical_servers, :dependent => :nullify, :inverse_of => :physical_rack + + 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 diff --git a/db/fixtures/miq_product_features.yml b/db/fixtures/miq_product_features.yml index 244a00b45d7..944c76dfe82 100644 --- a/db/fixtures/miq_product_features.yml +++ b/db/fixtures/miq_product_features.yml @@ -5867,6 +5867,15 @@ :description: Display Individual Physical Rack :feature_type: view :identifier: physical_rack_show + - :name: Operate + :description: Perform Operations on Physical Racks + :feature_type: control + :identifier: physical_rack_control + :children: + - :name: Refresh + :description: Refresh relationships and power states for all items related to Physical Rack + :feature_type: control + :identifier: physical_rack_refresh # Physical Chassis - :name: Physical Chassis diff --git a/db/fixtures/miq_user_roles.yml b/db/fixtures/miq_user_roles.yml index 23c2bd8c71e..bf2e5d84784 100644 --- a/db/fixtures/miq_user_roles.yml +++ b/db/fixtures/miq_user_roles.yml @@ -383,6 +383,7 @@ - ems_physical_infra_refresh - ems_physical_infra_tag - ems_physical_infra_view + - physical_rack_control - physical_rack_view - physical_switch_view - physical_server_view