Skip to content

Commit

Permalink
Merge pull request #17190 from lpichler/fix_establishing_relations_in…
Browse files Browse the repository at this point in the history
…_tenant_sync

Fix establishing relations of tenants and cloud tenants between different cloud tenant -> tenant sync
(cherry picked from commit d03161f)

https://bugzilla.redhat.com/show_bug.cgi?id=1562773
  • Loading branch information
gtanzillo authored and simaishi committed Apr 9, 2018
1 parent 1f6387c commit 8622b69
Show file tree
Hide file tree
Showing 2 changed files with 456 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/models/manageiq/providers/cloud_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def sync_tenants
elsif existing_source_tenant = Tenant.descendants_of(tenant_parent).find_by(:name => tenant_params[:name])
_log.info("CloudTenant #{cloud_tenant.name} has orphaned tenant #{existing_source_tenant.name}")
cloud_tenant.source_tenant = existing_source_tenant
tenant_params[:parent] = tenant_parent
cloud_tenant.update_source_tenant(tenant_params)
else
_log.info("CloudTenant #{cloud_tenant.name} has no tenant")
Expand Down Expand Up @@ -110,11 +111,16 @@ def sync_deleted_cloud_tenants

source_tenant.descendants.each do |tenant|
next if tenant.source
next if tenant.parent == source_tenant # tenant is already under provider's tenant

if tenant.parent == source_tenant # tenant is already under provider's tenant
_log.info("Setting source_id and source_type to nil for #{tenant.name} under provider's tenant #{source_tenant.name}")
tenant.update_attributes(:source_id => nil, :source_type => nil)
next
end

# move tenant under the provider's tenant
_log.info("Moving out #{tenant.name} under provider's tenant #{source_tenant.name}")
tenant.update_attributes(:parent => source_tenant)
tenant.update_attributes(:parent => source_tenant, :source_id => nil, :source_type => nil)
end
end

Expand Down
Loading

0 comments on commit 8622b69

Please sign in to comment.