From fb4df7ab4e5aebeb2587271a916f56918431f8dd Mon Sep 17 00:00:00 2001 From: Jirka Kremser Date: Thu, 2 Feb 2017 14:38:33 +0100 Subject: [PATCH 1/4] Middelware server group power ops: adding support for server group ops - suspend,resume,restart,stop,start --- .../providers/hawkular/middleware_manager.rb | 48 ++++++++++++++++--- db/fixtures/miq_product_features.yml | 26 +++++++++- 2 files changed, 67 insertions(+), 7 deletions(-) diff --git a/app/models/manageiq/providers/hawkular/middleware_manager.rb b/app/models/manageiq/providers/hawkular/middleware_manager.rb index b491c3a4bd1..b924a19a420 100644 --- a/app/models/manageiq/providers/hawkular/middleware_manager.rb +++ b/app/models/manageiq/providers/hawkular/middleware_manager.rb @@ -175,6 +175,21 @@ def alerts_client with_provider_connection(&:alerts) end + # server ops + def shutdown_middleware_server(ems_ref, params) + timeout = params[:timeout] || 0 + run_generic_operation(:Shutdown, ems_ref, :restart => false, :timeout => timeout) + end + + def suspend_middleware_server(ems_ref, params) + timeout = params[:timeout] || 0 + run_generic_operation(:Suspend, ems_ref, :timeout => timeout) + end + + def resume_middleware_server(ems_ref) + run_generic_operation(:Resume, ems_ref) + end + def reload_middleware_server(ems_ref) run_generic_operation(:Reload, ems_ref) end @@ -195,6 +210,7 @@ def restart_middleware_server(ems_ref) run_generic_operation(:Shutdown, ems_ref, :restart => true) end + # domain server ops def restart_middleware_domain_server(ems_ref) run_generic_operation(:Restart, ems_ref) end @@ -203,24 +219,44 @@ def kill_middleware_domain_server(ems_ref) run_generic_operation(:Kill, ems_ref) end - def shutdown_middleware_server(ems_ref, params) + # server group ops + def start_middleware_server_group(ems_ref) + # blocking: boolean + run_generic_operation('Start Servers', ems_ref) + end + + def stop_middleware_server_group(ems_ref, params) + # blocking: boolean + # timeout: int timeout = params[:timeout] || 0 - run_generic_operation(:Shutdown, ems_ref, :restart => false, :timeout => timeout) + run_generic_operation('Stop Servers', ems_ref, :timeout => timeout) end - def suspend_middleware_server(ems_ref, params) + def restart_middleware_server_group(ems_ref) + # blocking: boolean + run_generic_operation('Restart Servers', ems_ref) + end + + def reload_middleware_server_group(ems_ref) + # blocking: boolean + run_generic_operation('Reload Servers', ems_ref) + end + + def suspend_middleware_server_group(ems_ref, params) + # timeout: int timeout = params[:timeout] || 0 - run_generic_operation(:Suspend, ems_ref, :timeout => timeout) + run_generic_operation('Suspend Servers', ems_ref, :timeout => timeout) end - def resume_middleware_server(ems_ref) - run_generic_operation(:Resume, ems_ref) + def resume_middleware_server_group(ems_ref) + run_generic_operation('Resume Servers', ems_ref) end def create_jdr_report(ems_ref) run_generic_operation(:JDR, ems_ref) end + def self.raw_alerts_connect(hostname, port, username, password) require 'hawkular_all' url = URI::HTTP.build(:host => hostname, :port => port.to_i, :path => '/hawkular/alerts').to_s diff --git a/db/fixtures/miq_product_features.yml b/db/fixtures/miq_product_features.yml index a811c28ebe5..4f41eb01083 100644 --- a/db/fixtures/miq_product_features.yml +++ b/db/fixtures/miq_product_features.yml @@ -4069,8 +4069,32 @@ :description: Edit Tags of Middleware Server Groups :feature_type: control :identifier: middleware_server_group_tag + - :name: Reload middleware server group + :description: Trigger reload operation for Middleware Server Group + :feature_type: admin + :identifier: middleware_server_group_reload + - :name: Stop middleware server group + :description: Stop Middleware Server Group + :feature_type: admin + :identifier: middleware_server_group_stop + - :name: Start middleware server group + :description: Start Middleware Server Group + :feature_type: admin + :identifier: middleware_server_group_start + - :name: Suspend middleware server group + :description: Suspend Middleware Server Group + :feature_type: admin + :identifier: middleware_server_group_suspend + - :name: Resume middleware server group + :description: Resume a suspended Middleware Server Group + :feature_type: admin + :identifier: middleware_server_group_resume + - :name: Restart middleware server group + :description: Restart a Middleware Server Group + :feature_type: admin + :identifier: middleware_server_group_restart - :name: Add middleware deployment - :description: Add middleware deployment + :description: Add middleware deployment for Server Group :feature_type: admin :identifier: middleware_group_deployment_add From 6ed1e340a357b70ed38ca79f0caa7063197b9427 Mon Sep 17 00:00:00 2001 From: Jirka Kremser Date: Thu, 2 Feb 2017 15:15:55 +0100 Subject: [PATCH 2/4] rubocop --- app/models/manageiq/providers/hawkular/middleware_manager.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/manageiq/providers/hawkular/middleware_manager.rb b/app/models/manageiq/providers/hawkular/middleware_manager.rb index b924a19a420..ae0d1d4d937 100644 --- a/app/models/manageiq/providers/hawkular/middleware_manager.rb +++ b/app/models/manageiq/providers/hawkular/middleware_manager.rb @@ -256,7 +256,6 @@ def create_jdr_report(ems_ref) run_generic_operation(:JDR, ems_ref) end - def self.raw_alerts_connect(hostname, port, username, password) require 'hawkular_all' url = URI::HTTP.build(:host => hostname, :port => port.to_i, :path => '/hawkular/alerts').to_s From 1233aa2768a76be3a938da5dd95d37d749b57c8a Mon Sep 17 00:00:00 2001 From: Jirka Kremser Date: Tue, 14 Feb 2017 14:44:47 +0100 Subject: [PATCH 3/4] Removing confusing comments. --- .../manageiq/providers/hawkular/middleware_manager.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/models/manageiq/providers/hawkular/middleware_manager.rb b/app/models/manageiq/providers/hawkular/middleware_manager.rb index ae0d1d4d937..99542baba54 100644 --- a/app/models/manageiq/providers/hawkular/middleware_manager.rb +++ b/app/models/manageiq/providers/hawkular/middleware_manager.rb @@ -221,29 +221,23 @@ def kill_middleware_domain_server(ems_ref) # server group ops def start_middleware_server_group(ems_ref) - # blocking: boolean run_generic_operation('Start Servers', ems_ref) end def stop_middleware_server_group(ems_ref, params) - # blocking: boolean - # timeout: int timeout = params[:timeout] || 0 run_generic_operation('Stop Servers', ems_ref, :timeout => timeout) end def restart_middleware_server_group(ems_ref) - # blocking: boolean run_generic_operation('Restart Servers', ems_ref) end def reload_middleware_server_group(ems_ref) - # blocking: boolean run_generic_operation('Reload Servers', ems_ref) end def suspend_middleware_server_group(ems_ref, params) - # timeout: int timeout = params[:timeout] || 0 run_generic_operation('Suspend Servers', ems_ref, :timeout => timeout) end From bfeba58b05f6ed595c909bb15144f7fbe76dd37d Mon Sep 17 00:00:00 2001 From: Jirka Kremser Date: Tue, 14 Feb 2017 14:50:35 +0100 Subject: [PATCH 4/4] Making params optional arg. --- .../manageiq/providers/hawkular/middleware_manager.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/manageiq/providers/hawkular/middleware_manager.rb b/app/models/manageiq/providers/hawkular/middleware_manager.rb index 99542baba54..e3843e5dfb0 100644 --- a/app/models/manageiq/providers/hawkular/middleware_manager.rb +++ b/app/models/manageiq/providers/hawkular/middleware_manager.rb @@ -176,12 +176,12 @@ def alerts_client end # server ops - def shutdown_middleware_server(ems_ref, params) + def shutdown_middleware_server(ems_ref, params = {}) timeout = params[:timeout] || 0 run_generic_operation(:Shutdown, ems_ref, :restart => false, :timeout => timeout) end - def suspend_middleware_server(ems_ref, params) + def suspend_middleware_server(ems_ref, params = {}) timeout = params[:timeout] || 0 run_generic_operation(:Suspend, ems_ref, :timeout => timeout) end @@ -224,7 +224,7 @@ def start_middleware_server_group(ems_ref) run_generic_operation('Start Servers', ems_ref) end - def stop_middleware_server_group(ems_ref, params) + def stop_middleware_server_group(ems_ref, params = {}) timeout = params[:timeout] || 0 run_generic_operation('Stop Servers', ems_ref, :timeout => timeout) end @@ -237,7 +237,7 @@ def reload_middleware_server_group(ems_ref) run_generic_operation('Reload Servers', ems_ref) end - def suspend_middleware_server_group(ems_ref, params) + def suspend_middleware_server_group(ems_ref, params = {}) timeout = params[:timeout] || 0 run_generic_operation('Suspend Servers', ems_ref, :timeout => timeout) end