Skip to content

Commit

Permalink
Fix CloudTenant Vm targeted refresh
Browse files Browse the repository at this point in the history
Vm tagreted refresh queued related Cloud Tenant refresh, that could fail due to
keystone v3 backend in fog or an issue in fog/openstack method get_project_by_id.

Adding custom method to get_project derived from list_project.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1538741
  • Loading branch information
aufi committed Jan 29, 2018
1 parent 912647a commit 34de6c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Expand Up @@ -124,7 +124,7 @@ def tenants
def memoized_get_tenant(tenant_id)
return nil if tenant_id.blank?
@tenant_memo ||= Hash.new do |h, key|
h[key] = safe_get { identity_service.tenants.find_by_id(key) }
h[key] = safe_get { identity_service.respond_to?(:projects) ? identity_service.projects_get_by_id(key) : identity_service.tenants.find_by_id(key) }
end
@tenant_memo[tenant_id]
end
Expand Down Expand Up @@ -254,7 +254,7 @@ def infer_related_cloud_tenant_ems_refs_db!

def infer_related_cloud_tenant_ems_refs_api!
tenants.each do |tenant|
add_simple_target(:cloud_tenants, tenant.try(:parent_id)) unless tenant.try(:parent_id).blank?
add_simple_target!(:cloud_tenants, tenant.try(:parent_id)) unless tenant.try(:parent_id).blank?
end
end

Expand Down
Expand Up @@ -144,5 +144,11 @@ def list_project_tenant_user_roles(project_id, user_id)
list_roles_for_user_on_tenant(project_id, user_id).body["roles"]
end
end

# Remove this method once fog/openstack allows get_project correctly
def projects_get_by_id(id)
@all_projects ||= projects.all
@all_projects.find { |project| project.id == id }
end
end
end

0 comments on commit 34de6c3

Please sign in to comment.