Skip to content

Commit

Permalink
Merge pull request ManageIQ#17190 from lpichler/fix_establishing_rela…
Browse files Browse the repository at this point in the history
…tions_in_tenant_sync

Fix establishing relations of tenants and cloud tenants between different cloud tenant -> tenant sync
  • Loading branch information
gtanzillo authored Mar 28, 2018
2 parents 1c45ec3 + 59d8272 commit d03161f
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 @@ -85,6 +85,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 @@ -112,11 +113,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 d03161f

Please sign in to comment.