Skip to content

Commit

Permalink
Add evm_owner, tenant, group to orch stacks
Browse files Browse the repository at this point in the history
  • Loading branch information
d-m-u committed Oct 16, 2018
1 parent af11356 commit 019f44f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class AddEvmOwnerToOrchestrationStacks < ActiveRecord::Migration[5.0]
def change
add_reference :orchestration_stacks, :evm_owner_id, :bigint
add_reference :orchestration_stacks, :miq_group_id, :bigint
add_reference :orchestration_stacks, :tenant_id, :bigint
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class MigrateOrchStacksToHaveOwnershipConcept < ActiveRecord::Migration[5.0]
def up
say_with_time("Migrating existing orchestration stacks to have direct owners, groups, tenant") do
OrchestrationStack.where.not(:ems_id => nil).find_each do |os|
os.evm_owner_id = os.ext_management_system.tenant_identity
os.tenant_id = os.ext_management_system.tenant_identity.current_tenant.id
os.group_id = os.ext_management_system.tenant_identity.current_group.id
os.save
end
OrchestrationStack.where(:ems_id => nil).find_each do |os|
# if orch stack has no ems, can we even set any of this stuff?
end
end
end

def down
OrchestrationStack.update_all(:evm_owner_id => nil, :tenant_id => nil, :group_id => nil)
end
end

0 comments on commit 019f44f

Please sign in to comment.