From 2c24c3ae1583c46f7844759608bdb5745fb81fa7 Mon Sep 17 00:00:00 2001 From: Marcel Hild Date: Wed, 5 Apr 2017 14:57:19 +0200 Subject: [PATCH 1/2] default blacklisted event names are sourced from settings.yml this allows providers just provide a setting in :ems -> :ems_ -> :blacklisted_event_names --- app/models/ext_management_system.rb | 4 ---- app/models/manageiq/providers/base_manager.rb | 4 ++++ .../manageiq/providers/base_manager_spec.rb | 19 +++++++++++++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 spec/models/manageiq/providers/base_manager_spec.rb diff --git a/app/models/ext_management_system.rb b/app/models/ext_management_system.rb index 9d80595e81a..9bb6a8a15e7 100644 --- a/app/models/ext_management_system.rb +++ b/app/models/ext_management_system.rb @@ -248,10 +248,6 @@ def self.provision_workflow_class self::ProvisionWorkflow end - def self.default_blacklisted_event_names - [] - end - # UI methods for determining availability of fields def supports_port? false diff --git a/app/models/manageiq/providers/base_manager.rb b/app/models/manageiq/providers/base_manager.rb index 1aa380286e5..25c078e273a 100644 --- a/app/models/manageiq/providers/base_manager.rb +++ b/app/models/manageiq/providers/base_manager.rb @@ -23,5 +23,9 @@ def refresher def http_proxy_uri VMDB::Util.http_proxy_uri(emstype.try(:to_sym)) || VMDB::Util.http_proxy_uri end + + def self.default_blacklisted_event_names + Array(::Settings.ems["ems_#{provider_name.underscore}"].try(:blacklisted_event_names)) + end end end diff --git a/spec/models/manageiq/providers/base_manager_spec.rb b/spec/models/manageiq/providers/base_manager_spec.rb new file mode 100644 index 00000000000..efb9706b28a --- /dev/null +++ b/spec/models/manageiq/providers/base_manager_spec.rb @@ -0,0 +1,19 @@ +describe ManageIQ::Providers::BaseManager do + context ".default_blacklisted_event_names" do + it 'returns an empty array for the base class' do + expect(described_class.default_blacklisted_event_names).to eq([]) + end + + it 'returns the provider event if configured' do + stub_settings_merge( + :ems => { + :ems_some_provider => { + :blacklisted_event_names => %w(ev1 ev2) + } + } + ) + allow(described_class).to receive(:provider_name).and_return('SomeProvider') + expect(described_class.default_blacklisted_event_names).to eq(%w(ev1 ev2)) + end + end +end From 7b2bd75c39bfa03ad99d41bb4eab0931903c733f Mon Sep 17 00:00:00 2001 From: Marcel Hild Date: Wed, 5 Apr 2017 15:03:32 +0200 Subject: [PATCH 2/2] add empty array of blacklisted_event_names to provider --- lib/generators/provider/templates/config/settings.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/generators/provider/templates/config/settings.yml b/lib/generators/provider/templates/config/settings.yml index e1f9d86c741..5d7f8d98341 100644 --- a/lib/generators/provider/templates/config/settings.yml +++ b/lib/generators/provider/templates/config/settings.yml @@ -1,6 +1,7 @@ --- :ems: :ems_<%= provider_name %>: + :blacklisted_event_names: [] :event_handling: :event_groups: :http_proxy: