Skip to content

Commit

Permalink
Added get_targets_for base class methods
Browse files Browse the repository at this point in the history
1. Turns on RBAC filtering by default at the base class level for all allowed_ methods in the CloudManager class

https://bugzilla.redhat.com/show_bug.cgi?id=1514237
  • Loading branch information
syncrou committed Dec 20, 2017
1 parent 997f6d4 commit e1e206d
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ def allowed_cloud_subnets(_options = {})

az_id = src[:availability_zone_id].to_i
if (cn = CloudNetwork.find_by(:id => src[:cloud_network_id]))
cn.cloud_subnets.each_with_object({}) do |cs, hash|

targets = get_targets_for_source(cn, :cloud_filter, CloudNetwork, 'cloud_subnets')
targets.each_with_object({}) do |cs, hash|
next if !az_id.zero? && az_id != cs.availability_zone_id
hash[cs.id] = "#{cs.name} (#{cs.cidr}) | #{cs.availability_zone.try(:name)}"
end
Expand All @@ -33,10 +35,8 @@ def allowed_cloud_subnets(_options = {})

def allowed_guest_access_key_pairs(_options = {})
source = load_ar_obj(get_source_vm)
ems = source.try(:ext_management_system)

return {} if ems.nil?
ems.key_pairs.each_with_object({}) { |kp, h| h[kp.id] = kp.name }
targets = get_targets_for_ems(source, :cloud_filter, ManageIQ::Providers, 'key_pairs')
targets.each_with_object({}) { |kp, h| h[kp.id] = kp.name }
end

def allowed_security_groups(_options = {})
Expand All @@ -51,8 +51,8 @@ def allowed_security_groups(_options = {})

def allowed_floating_ip_addresses(_options = {})
return {} unless (src_obj = provider_or_tenant_object)

src_obj.floating_ips.available.each_with_object({}) do |ip, h|
targets = get_targets_for_source(src_obj, :cloud_filter, FloatingIp, 'floating_ips.available')
targets.each_with_object({}) do |ip, h|
h[ip.id] = ip.address
end
end
Expand Down

0 comments on commit e1e206d

Please sign in to comment.