From 99efe4b801709bda4255474d664bbff4c9bdda05 Mon Sep 17 00:00:00 2001 From: Gregor Berginc Date: Tue, 17 Jan 2017 21:27:37 +0100 Subject: [PATCH 1/3] Rename Amazon BlockStorageManager to StorageManager::Ebs Initial implementation of the block storage manager presumed that Amazon provider would only have a single block storage manager and consequently used the generic class name `Amazon::BlockStorageManager`. @rolivery suggested to change the name to indicate the actual type of the manager, which in this case is EBS. This patch thus replaces all occurrences where `BlockStorageManager` was used before with `StorageManager::Ebs`. Signed-off-by: Gregor Berginc --- .../providers/amazon/block_storage_manager/cloud_volume.rb | 2 -- .../amazon/block_storage_manager/cloud_volume_snapshot.rb | 2 -- app/models/manageiq/providers/amazon/cloud_manager.rb | 2 +- app/models/manageiq/providers/amazon/inventory/factory.rb | 4 ++-- .../inventory/inventory_collection_default_init_data.rb | 4 ++-- .../{block_storage_manager.rb => storage_manager/ebs.rb} | 2 +- .../{block_storage_manager.rb => storage_manager/ebs.rb} | 2 +- .../providers/amazon/storage_manager/ebs/cloud_volume.rb | 2 ++ .../amazon/storage_manager/ebs/cloud_volume_snapshot.rb | 2 ++ .../ebs}/refresh_parser.rb | 6 +++--- .../ebs}/refresh_parser_inventory_object.rb | 6 +++--- .../ebs}/refresh_worker.rb | 4 ++-- .../ebs}/refresh_worker/runner.rb | 2 +- .../ebs}/refresher.rb | 6 +++--- .../ebs}/stubbed_refresher_spec.rb | 6 +++--- 15 files changed, 26 insertions(+), 26 deletions(-) delete mode 100644 app/models/manageiq/providers/amazon/block_storage_manager/cloud_volume.rb delete mode 100644 app/models/manageiq/providers/amazon/block_storage_manager/cloud_volume_snapshot.rb rename app/models/manageiq/providers/amazon/inventory/targets/{block_storage_manager.rb => storage_manager/ebs.rb} (73%) rename app/models/manageiq/providers/amazon/{block_storage_manager.rb => storage_manager/ebs.rb} (93%) create mode 100644 app/models/manageiq/providers/amazon/storage_manager/ebs/cloud_volume.rb create mode 100644 app/models/manageiq/providers/amazon/storage_manager/ebs/cloud_volume_snapshot.rb rename app/models/manageiq/providers/amazon/{block_storage_manager => storage_manager/ebs}/refresh_parser.rb (90%) rename app/models/manageiq/providers/amazon/{block_storage_manager => storage_manager/ebs}/refresh_parser_inventory_object.rb (89%) rename app/models/manageiq/providers/amazon/{block_storage_manager => storage_manager/ebs}/refresh_worker.rb (58%) rename app/models/manageiq/providers/amazon/{block_storage_manager => storage_manager/ebs}/refresh_worker/runner.rb (54%) rename app/models/manageiq/providers/amazon/{block_storage_manager => storage_manager/ebs}/refresher.rb (87%) rename spec/models/manageiq/providers/amazon/{block_storage_manager => storage_manager/ebs}/stubbed_refresher_spec.rb (98%) diff --git a/app/models/manageiq/providers/amazon/block_storage_manager/cloud_volume.rb b/app/models/manageiq/providers/amazon/block_storage_manager/cloud_volume.rb deleted file mode 100644 index b2b4d577c..000000000 --- a/app/models/manageiq/providers/amazon/block_storage_manager/cloud_volume.rb +++ /dev/null @@ -1,2 +0,0 @@ -class ManageIQ::Providers::Amazon::BlockStorageManager::CloudVolume < ::CloudVolume -end diff --git a/app/models/manageiq/providers/amazon/block_storage_manager/cloud_volume_snapshot.rb b/app/models/manageiq/providers/amazon/block_storage_manager/cloud_volume_snapshot.rb deleted file mode 100644 index a80c4a4ef..000000000 --- a/app/models/manageiq/providers/amazon/block_storage_manager/cloud_volume_snapshot.rb +++ /dev/null @@ -1,2 +0,0 @@ -class ManageIQ::Providers::Amazon::BlockStorageManager::CloudVolumeSnapshot < ::CloudVolumeSnapshot -end diff --git a/app/models/manageiq/providers/amazon/cloud_manager.rb b/app/models/manageiq/providers/amazon/cloud_manager.rb index 08d37a349..47e9af27c 100644 --- a/app/models/manageiq/providers/amazon/cloud_manager.rb +++ b/app/models/manageiq/providers/amazon/cloud_manager.rb @@ -49,7 +49,7 @@ class ManageIQ::Providers::Amazon::CloudManager < ManageIQ::Providers::CloudMana has_one :block_storage_manager, :foreign_key => :parent_ems_id, - :class_name => "ManageIQ::Providers::Amazon::BlockStorageManager", + :class_name => "ManageIQ::Providers::Amazon::StorageManager::Ebs", :autosave => true, :dependent => :destroy diff --git a/app/models/manageiq/providers/amazon/inventory/factory.rb b/app/models/manageiq/providers/amazon/inventory/factory.rb index 78324f7d4..bce1d7c99 100644 --- a/app/models/manageiq/providers/amazon/inventory/factory.rb +++ b/app/models/manageiq/providers/amazon/inventory/factory.rb @@ -14,8 +14,8 @@ def target(ems, target) ManageIQ::Providers::Amazon::Inventory::Targets::CloudManager.new(ems, target) when ManageIQ::Providers::Amazon::NetworkManager ManageIQ::Providers::Amazon::Inventory::Targets::NetworkManager.new(ems, target) - when ManageIQ::Providers::Amazon::BlockStorageManager - ManageIQ::Providers::Amazon::Inventory::Targets::BlockStorageManager.new(ems, target) + when ManageIQ::Providers::Amazon::StorageManager::Ebs + ManageIQ::Providers::Amazon::Inventory::Targets::StorageManager::Ebs.new(ems, target) else ManageIQ::Providers::Amazon::Inventory::Targets::CloudManager.new(ems, target) end diff --git a/app/models/manageiq/providers/amazon/inventory/inventory_collection_default_init_data.rb b/app/models/manageiq/providers/amazon/inventory/inventory_collection_default_init_data.rb index a5a1df12b..38b1e2fc4 100644 --- a/app/models/manageiq/providers/amazon/inventory/inventory_collection_default_init_data.rb +++ b/app/models/manageiq/providers/amazon/inventory/inventory_collection_default_init_data.rb @@ -284,7 +284,7 @@ def cloud_volumes_init_data(extra_attributes = {}) :association => :cloud_volumes, } - init_data(::ManageIQ::Providers::Amazon::BlockStorageManager::CloudVolume, attributes, extra_attributes) + init_data(::ManageIQ::Providers::Amazon::StorageManager::Ebs::CloudVolume, attributes, extra_attributes) end def cloud_volume_snapshots_init_data(extra_attributes = {}) @@ -292,6 +292,6 @@ def cloud_volume_snapshots_init_data(extra_attributes = {}) :association => :cloud_volume_snapshots, } - init_data(::ManageIQ::Providers::Amazon::BlockStorageManager::CloudVolumeSnapshot, attributes, extra_attributes) + init_data(::ManageIQ::Providers::Amazon::StorageManager::Ebs::CloudVolumeSnapshot, attributes, extra_attributes) end end diff --git a/app/models/manageiq/providers/amazon/inventory/targets/block_storage_manager.rb b/app/models/manageiq/providers/amazon/inventory/targets/storage_manager/ebs.rb similarity index 73% rename from app/models/manageiq/providers/amazon/inventory/targets/block_storage_manager.rb rename to app/models/manageiq/providers/amazon/inventory/targets/storage_manager/ebs.rb index 525c4a4f2..fe955e31c 100644 --- a/app/models/manageiq/providers/amazon/inventory/targets/block_storage_manager.rb +++ b/app/models/manageiq/providers/amazon/inventory/targets/storage_manager/ebs.rb @@ -1,4 +1,4 @@ -class ManageIQ::Providers::Amazon::Inventory::Targets::BlockStorageManager < ManageIQ::Providers::Amazon::Inventory::Targets +class ManageIQ::Providers::Amazon::Inventory::Targets::StorageManager::Ebs < ManageIQ::Providers::Amazon::Inventory::Targets def initialize_inventory_collections add_inventory_collections(%i(cloud_volumes cloud_volume_snapshots)) end diff --git a/app/models/manageiq/providers/amazon/block_storage_manager.rb b/app/models/manageiq/providers/amazon/storage_manager/ebs.rb similarity index 93% rename from app/models/manageiq/providers/amazon/block_storage_manager.rb rename to app/models/manageiq/providers/amazon/storage_manager/ebs.rb index bab81deed..3d1b24ee7 100644 --- a/app/models/manageiq/providers/amazon/block_storage_manager.rb +++ b/app/models/manageiq/providers/amazon/storage_manager/ebs.rb @@ -1,4 +1,4 @@ -class ManageIQ::Providers::Amazon::BlockStorageManager < ManageIQ::Providers::StorageManager +class ManageIQ::Providers::Amazon::StorageManager::Ebs < ManageIQ::Providers::StorageManager require_nested :RefreshParser require_nested :RefreshWorker require_nested :Refresher diff --git a/app/models/manageiq/providers/amazon/storage_manager/ebs/cloud_volume.rb b/app/models/manageiq/providers/amazon/storage_manager/ebs/cloud_volume.rb new file mode 100644 index 000000000..27532c4db --- /dev/null +++ b/app/models/manageiq/providers/amazon/storage_manager/ebs/cloud_volume.rb @@ -0,0 +1,2 @@ +class ManageIQ::Providers::Amazon::StorageManager::Ebs::CloudVolume < ::CloudVolume +end diff --git a/app/models/manageiq/providers/amazon/storage_manager/ebs/cloud_volume_snapshot.rb b/app/models/manageiq/providers/amazon/storage_manager/ebs/cloud_volume_snapshot.rb new file mode 100644 index 000000000..1b250a1ef --- /dev/null +++ b/app/models/manageiq/providers/amazon/storage_manager/ebs/cloud_volume_snapshot.rb @@ -0,0 +1,2 @@ +class ManageIQ::Providers::Amazon::StorageManager::Ebs::CloudVolumeSnapshot < ::CloudVolumeSnapshot +end diff --git a/app/models/manageiq/providers/amazon/block_storage_manager/refresh_parser.rb b/app/models/manageiq/providers/amazon/storage_manager/ebs/refresh_parser.rb similarity index 90% rename from app/models/manageiq/providers/amazon/block_storage_manager/refresh_parser.rb rename to app/models/manageiq/providers/amazon/storage_manager/ebs/refresh_parser.rb index e3df8be74..a48da7e38 100644 --- a/app/models/manageiq/providers/amazon/block_storage_manager/refresh_parser.rb +++ b/app/models/manageiq/providers/amazon/storage_manager/ebs/refresh_parser.rb @@ -1,4 +1,4 @@ -class ManageIQ::Providers::Amazon::BlockStorageManager::RefreshParser +class ManageIQ::Providers::Amazon::StorageManager::Ebs::RefreshParser include ManageIQ::Providers::Amazon::RefreshHelperMethods def initialize(ems, options = nil) @@ -66,11 +66,11 @@ def parse_snapshot(snap) class << self def volume_type - "ManageIQ::Providers::Amazon::BlockStorageManager::CloudVolume" + "ManageIQ::Providers::Amazon::StorageManager::Ebs::CloudVolume" end def volume_snapshot_type - "ManageIQ::Providers::Amazon::BlockStorageManager::CloudVolumeSnapshot" + "ManageIQ::Providers::Amazon::StorageManager::Ebs::CloudVolumeSnapshot" end end end diff --git a/app/models/manageiq/providers/amazon/block_storage_manager/refresh_parser_inventory_object.rb b/app/models/manageiq/providers/amazon/storage_manager/ebs/refresh_parser_inventory_object.rb similarity index 89% rename from app/models/manageiq/providers/amazon/block_storage_manager/refresh_parser_inventory_object.rb rename to app/models/manageiq/providers/amazon/storage_manager/ebs/refresh_parser_inventory_object.rb index 4aecde69b..304516d9b 100644 --- a/app/models/manageiq/providers/amazon/block_storage_manager/refresh_parser_inventory_object.rb +++ b/app/models/manageiq/providers/amazon/storage_manager/ebs/refresh_parser_inventory_object.rb @@ -1,4 +1,4 @@ -class ManageIQ::Providers::Amazon::BlockStorageManager::RefreshParserInventoryObject < ::ManagerRefresh::RefreshParserInventoryObject +class ManageIQ::Providers::Amazon::StorageManager::Ebs::RefreshParserInventoryObject < ::ManagerRefresh::RefreshParserInventoryObject include ManageIQ::Providers::Amazon::RefreshHelperMethods def populate_inventory_collections @@ -53,11 +53,11 @@ def parse_snapshot(snap) class << self def volume_type - "ManageIQ::Providers::Amazon::BlockStorageManager::CloudVolume" + "ManageIQ::Providers::Amazon::StorageManager::Ebs::CloudVolume" end def volume_snapshot_type - "ManageIQ::Providers::Amazon::BlockStorageManager::CloudVolumeSnapshot" + "ManageIQ::Providers::Amazon::StorageManager::Ebs::CloudVolumeSnapshot" end end end diff --git a/app/models/manageiq/providers/amazon/block_storage_manager/refresh_worker.rb b/app/models/manageiq/providers/amazon/storage_manager/ebs/refresh_worker.rb similarity index 58% rename from app/models/manageiq/providers/amazon/block_storage_manager/refresh_worker.rb rename to app/models/manageiq/providers/amazon/storage_manager/ebs/refresh_worker.rb index d67317aae..a8e825c6e 100644 --- a/app/models/manageiq/providers/amazon/block_storage_manager/refresh_worker.rb +++ b/app/models/manageiq/providers/amazon/storage_manager/ebs/refresh_worker.rb @@ -1,8 +1,8 @@ -class ManageIQ::Providers::Amazon::BlockStorageManager::RefreshWorker < ::MiqEmsRefreshWorker +class ManageIQ::Providers::Amazon::StorageManager::Ebs::RefreshWorker < ::MiqEmsRefreshWorker require_nested :Runner def self.ems_class - ManageIQ::Providers::Amazon::BlockStorageManager + ManageIQ::Providers::Amazon::StorageManager::Ebs end def self.settings_name diff --git a/app/models/manageiq/providers/amazon/block_storage_manager/refresh_worker/runner.rb b/app/models/manageiq/providers/amazon/storage_manager/ebs/refresh_worker/runner.rb similarity index 54% rename from app/models/manageiq/providers/amazon/block_storage_manager/refresh_worker/runner.rb rename to app/models/manageiq/providers/amazon/storage_manager/ebs/refresh_worker/runner.rb index 50ff2e8bb..38cc38e21 100644 --- a/app/models/manageiq/providers/amazon/block_storage_manager/refresh_worker/runner.rb +++ b/app/models/manageiq/providers/amazon/storage_manager/ebs/refresh_worker/runner.rb @@ -1,3 +1,3 @@ -class ManageIQ::Providers::Amazon::BlockStorageManager::RefreshWorker::Runner < +class ManageIQ::Providers::Amazon::StorageManager::Ebs::RefreshWorker::Runner < ManageIQ::Providers::BaseManager::RefreshWorker::Runner end diff --git a/app/models/manageiq/providers/amazon/block_storage_manager/refresher.rb b/app/models/manageiq/providers/amazon/storage_manager/ebs/refresher.rb similarity index 87% rename from app/models/manageiq/providers/amazon/block_storage_manager/refresher.rb rename to app/models/manageiq/providers/amazon/storage_manager/ebs/refresher.rb index 38ed4a3f7..90cec72cd 100644 --- a/app/models/manageiq/providers/amazon/block_storage_manager/refresher.rb +++ b/app/models/manageiq/providers/amazon/storage_manager/ebs/refresher.rb @@ -1,5 +1,5 @@ module ManageIQ::Providers - class Amazon::BlockStorageManager::Refresher < ManageIQ::Providers::BaseManager::Refresher + class Amazon::StorageManager::Ebs::Refresher < ManageIQ::Providers::BaseManager::Refresher include ::EmsRefresh::Refreshers::EmsRefresherMixin def collect_inventory_for_targets(ems, targets) @@ -26,9 +26,9 @@ def parse_targeted_inventory(ems, _target, inventory) _log.debug "#{log_header} Parsing inventory..." hashes, = Benchmark.realtime_block(:parse_inventory) do if refresher_options.try(:[], :inventory_object_refresh) - ManageIQ::Providers::Amazon::BlockStorageManager::RefreshParserInventoryObject.new(inventory).populate_inventory_collections + ManageIQ::Providers::Amazon::StorageManager::Ebs::RefreshParserInventoryObject.new(inventory).populate_inventory_collections else - ManageIQ::Providers::Amazon::BlockStorageManager::RefreshParser.ems_inv_to_hashes(ems, refresher_options) + ManageIQ::Providers::Amazon::StorageManager::Ebs::RefreshParser.ems_inv_to_hashes(ems, refresher_options) end end _log.debug "#{log_header} Parsing inventory...Complete" diff --git a/spec/models/manageiq/providers/amazon/block_storage_manager/stubbed_refresher_spec.rb b/spec/models/manageiq/providers/amazon/storage_manager/ebs/stubbed_refresher_spec.rb similarity index 98% rename from spec/models/manageiq/providers/amazon/block_storage_manager/stubbed_refresher_spec.rb rename to spec/models/manageiq/providers/amazon/storage_manager/ebs/stubbed_refresher_spec.rb index 2e3c3b24d..67ed848ed 100644 --- a/spec/models/manageiq/providers/amazon/block_storage_manager/stubbed_refresher_spec.rb +++ b/spec/models/manageiq/providers/amazon/storage_manager/ebs/stubbed_refresher_spec.rb @@ -1,7 +1,7 @@ -require_relative '../aws_helper' -require_relative '../aws_stubs' +require_relative '../../aws_helper' +require_relative '../../aws_stubs' -describe ManageIQ::Providers::Amazon::BlockStorageManager::Refresher do +describe ManageIQ::Providers::Amazon::StorageManager::Ebs::Refresher do include AwsStubs describe "refresh" do From b8f8ba15e94b3dd659cdd11f0605c16c51521470 Mon Sep 17 00:00:00 2001 From: Gregor Berginc Date: Tue, 17 Jan 2017 21:44:53 +0100 Subject: [PATCH 2/3] Replace `ec2_block_storage` with specific `ec2_ebs_storage` Since we are now explicitly adding EBS provider, this patch changes the name of the corresponding dependent block storage manager. Signed-off-by: Gregor Berginc --- .../manageiq/providers/amazon/cloud_manager.rb | 12 ++++++------ .../manageiq/providers/amazon/storage_manager/ebs.rb | 2 +- .../storage_manager/ebs/stubbed_refresher_spec.rb | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/models/manageiq/providers/amazon/cloud_manager.rb b/app/models/manageiq/providers/amazon/cloud_manager.rb index 47e9af27c..0000df75a 100644 --- a/app/models/manageiq/providers/amazon/cloud_manager.rb +++ b/app/models/manageiq/providers/amazon/cloud_manager.rb @@ -47,7 +47,7 @@ class ManageIQ::Providers::Amazon::CloudManager < ManageIQ::Providers::CloudMana :to => :network_manager, :allow_nil => true - has_one :block_storage_manager, + has_one :ebs_storage_manager, :foreign_key => :parent_ems_id, :class_name => "ManageIQ::Providers::Amazon::StorageManager::Ebs", :autosave => true, @@ -55,7 +55,7 @@ class ManageIQ::Providers::Amazon::CloudManager < ManageIQ::Providers::CloudMana delegate :cloud_volumes, :cloud_volume_snapshots, - :to => :block_storage_manager, + :to => :ebs_storage_manager, :allow_nil => true before_create :ensure_managers @@ -70,10 +70,10 @@ def ensure_managers network_manager.zone_id = zone_id network_manager.provider_region = provider_region - build_block_storage_manager unless block_storage_manager - block_storage_manager.name = "#{name} Block Storage Manager" - block_storage_manager.zone_id = zone_id - block_storage_manager.provider_region = provider_region + build_ebs_storage_manager unless ebs_storage_manager + ebs_storage_manager.name = "#{name} EBS Storage Manager" + ebs_storage_manager.zone_id = zone_id + ebs_storage_manager.provider_region = provider_region end def self.ems_type diff --git a/app/models/manageiq/providers/amazon/storage_manager/ebs.rb b/app/models/manageiq/providers/amazon/storage_manager/ebs.rb index 3d1b24ee7..01d8b78b8 100644 --- a/app/models/manageiq/providers/amazon/storage_manager/ebs.rb +++ b/app/models/manageiq/providers/amazon/storage_manager/ebs.rb @@ -24,7 +24,7 @@ class ManageIQ::Providers::Amazon::StorageManager::Ebs < ManageIQ::Providers::St :allow_nil => true def self.ems_type - @ems_type ||= "ec2_block_storage".freeze + @ems_type ||= "ec2_ebs_storage".freeze end def self.description diff --git a/spec/models/manageiq/providers/amazon/storage_manager/ebs/stubbed_refresher_spec.rb b/spec/models/manageiq/providers/amazon/storage_manager/ebs/stubbed_refresher_spec.rb index 67ed848ed..1553c110b 100644 --- a/spec/models/manageiq/providers/amazon/storage_manager/ebs/stubbed_refresher_spec.rb +++ b/spec/models/manageiq/providers/amazon/storage_manager/ebs/stubbed_refresher_spec.rb @@ -19,7 +19,7 @@ ].each do |settings| context "with settings #{settings}" do before :each do - allow(Settings.ems_refresh).to receive(:ec2_block_storage).and_return(settings) + allow(Settings.ems_refresh).to receive(:ec2_ebs_storage).and_return(settings) end it "2 refreshes, first creates all entities, second updates all entitites" do @@ -65,7 +65,7 @@ def refresh_spec @ems.reload with_aws_stubbed(stub_responses) do - EmsRefresh.refresh(@ems.block_storage_manager) + EmsRefresh.refresh(@ems.ebs_storage_manager) end @ems.reload @@ -174,7 +174,7 @@ def assert_table_counts end def assert_ems - ems = @ems.block_storage_manager + ems = @ems.ebs_storage_manager expect(ems).to have_attributes(:api_version => nil, # TODO: Should be 3.0 :uid_ems => nil) From 7cf078306c12abf12a851f9323f3cb773692756e Mon Sep 17 00:00:00 2001 From: Gregor Berginc Date: Wed, 18 Jan 2017 15:05:41 +0100 Subject: [PATCH 3/3] Rename EBS storage config key Following the renaming of the EBS storage manager, this patch also changes the EBS storage key in the `config/settings.yml` file. Signed-off-by: Gregor Berginc --- .../providers/amazon/storage_manager/ebs/refresh_worker.rb | 2 +- config/settings.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/manageiq/providers/amazon/storage_manager/ebs/refresh_worker.rb b/app/models/manageiq/providers/amazon/storage_manager/ebs/refresh_worker.rb index a8e825c6e..61230e3fa 100644 --- a/app/models/manageiq/providers/amazon/storage_manager/ebs/refresh_worker.rb +++ b/app/models/manageiq/providers/amazon/storage_manager/ebs/refresh_worker.rb @@ -6,6 +6,6 @@ def self.ems_class end def self.settings_name - :ems_refresh_worker_amazon_block_storage + :ems_refresh_worker_amazon_ebs_storage end end diff --git a/config/settings.yml b/config/settings.yml index b921fcfbd..9be5b2859 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -43,4 +43,4 @@ :ems_refresh_worker: :ems_refresh_worker_amazon: {} :ems_refresh_worker_amazon_network: {} - :ems_refresh_worker_amazon_block_storage: {} + :ems_refresh_worker_amazon_ebs_storage: {}