Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subclass CinderManagers under Openstack #553

Merged
merged 2 commits into from
Jan 21, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions db/migrate/20210118185402_subclass_cinder_manager_openstack.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class SubclassCinderManagerOpenstack < ActiveRecord::Migration[6.0]
class ExtManagementSystem < ActiveRecord::Base
self.inheritance_column = :_type_disabled
end

def up
say_with_time("Subclass CinderManager under Openstack") do
ExtManagementSystem.where(:type => "ManageIQ::Providers::StorageManager::CinderManager")
.update_all(:type => "ManageIQ::Providers::Openstack::StorageManager::CinderManager")
end
end

def down
say_with_time("Move CinderManager from Openstack") do
ExtManagementSystem.where(:type => "ManageIQ::Providers::Openstack::StorageManager::CinderManager")
Fryguy marked this conversation as resolved.
Show resolved Hide resolved
.update_all(:type => "ManageIQ::Providers::StorageManager::CinderManager")
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
require_migration

RSpec.describe SubclassCinderManagerOpenstack do
let(:ems_stub) { migration_stub(:ExtManagementSystem) }

migration_context :up do
it "Updates the CinderManager :type" do
ems = ems_stub.create!(:type => "ManageIQ::Providers::StorageManager::CinderManager")

migrate

expect(ems.reload.type).to eq("ManageIQ::Providers::Openstack::StorageManager::CinderManager")
end

it "Doesn't update other managers' types" do
ems = ems_stub.create!(:type => "ManageIQ::Providers::Vmware::InfraManager")

migrate

expect(ems.reload.type).to eq("ManageIQ::Providers::Vmware::InfraManager")
end
end

migration_context :down do
it "Updates the CinderManager :type" do
ems = ems_stub.create!(:type => "ManageIQ::Providers::Openstack::StorageManager::CinderManager")

migrate

expect(ems.reload.type).to eq("ManageIQ::Providers::StorageManager::CinderManager")
end

it "Doesn't update other managers' types" do
ems = ems_stub.create!(:type => "ManageIQ::Providers::Vmware::InfraManager")

migrate

expect(ems.reload.type).to eq("ManageIQ::Providers::Vmware::InfraManager")
end
end
end