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

Fix establishing relations of tenants and cloud tenants between different cloud tenant -> tenant sync #17190

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
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