From 37396e9946fb4b9a945d9510c8c0e9626921e0bf Mon Sep 17 00:00:00 2001 From: Beni Cherniavsky-Paskin Date: Mon, 10 Jul 2017 15:25:03 +0300 Subject: [PATCH] Blacklist :namespace in several more places for convenience Tracking where it's ok to leave it in and where we must `.delete(:namespace)` is too annoying... --- .../inventory_collections.rb | 29 ++++++++++--------- .../container_manager/refresh_parser.rb | 4 +-- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/app/models/manageiq/providers/kubernetes/container_manager/inventory_collections.rb b/app/models/manageiq/providers/kubernetes/container_manager/inventory_collections.rb index 2219b145d9..82e3362a8f 100644 --- a/app/models/manageiq/providers/kubernetes/container_manager/inventory_collections.rb +++ b/app/models/manageiq/providers/kubernetes/container_manager/inventory_collections.rb @@ -10,24 +10,24 @@ def initialize_inventory_collections(ems) :secondary_refs => {:by_name => [:name]}, ) @inv_collections[:container_quotas] = ::ManagerRefresh::InventoryCollection.new( - :model_class => ContainerQuota, - :parent => ems, - :builder_params => {:ems_id => ems.id}, - :association => :container_quotas, - #:arel => ContainerQuota.joins(:container_project).where(:container_projects => {:ems_id => ems.id}), + :model_class => ContainerQuota, + :parent => ems, + :builder_params => {:ems_id => ems.id}, + :association => :container_quotas, + :attributes_blacklist => [:namespace], ) @inv_collections[:container_quota_items] = ::ManagerRefresh::InventoryCollection.new( :model_class => ContainerQuotaItem, :parent => ems, :association => :container_quota_items, - #:arel => ContainerQuotaItem.joins(:container_quota => :container_project).where(:container_projects => {:ems_id => ems.id}), :manager_ref => [:container_quota, :resource], ) @inv_collections[:container_limits] = ::ManagerRefresh::InventoryCollection.new( - :model_class => ContainerLimit, - :parent => ems, - :builder_params => {:ems_id => ems.id}, - :association => :container_limits, + :model_class => ContainerLimit, + :parent => ems, + :builder_params => {:ems_id => ems.id}, + :association => :container_limits, + :attributes_blacklist => [:namespace], ) @inv_collections[:container_limit_items] = ::ManagerRefresh::InventoryCollection.new( :model_class => ContainerLimitItem, @@ -189,10 +189,11 @@ def initialize_inventory_collections(ems) ) @inv_collections[:container_templates] = ::ManagerRefresh::InventoryCollection.new( - :model_class => ContainerTemplate, - :parent => ems, - :builder_params => {:ems_id => ems.id}, - :association => :container_templates, + :model_class => ContainerTemplate, + :parent => ems, + :builder_params => {:ems_id => ems.id}, + :association => :container_templates, + :attributes_blacklist => [:namespace], ) @inv_collections[:container_template_parameters] = ::ManagerRefresh::InventoryCollection.new( diff --git a/app/models/manageiq/providers/kubernetes/container_manager/refresh_parser.rb b/app/models/manageiq/providers/kubernetes/container_manager/refresh_parser.rb index c0fc7327f0..25069078fc 100644 --- a/app/models/manageiq/providers/kubernetes/container_manager/refresh_parser.rb +++ b/app/models/manageiq/providers/kubernetes/container_manager/refresh_parser.rb @@ -287,7 +287,7 @@ def get_resource_quotas_graph(inv) inv["resource_quota"].each do |quota| h = parse_resource_quota(quota) - h[:container_project] = lazy_find_project(:name => h.delete(:namespace)) + h[:container_project] = lazy_find_project(:name => h[:namespace]) items = h.delete(:container_quota_items) get_container_quota_items_graph(h, items) @@ -310,7 +310,7 @@ def get_limit_ranges_graph(inv) inv["limit_range"].each do |data| h = parse_range(data) - h[:container_project] = lazy_find_project(:name => h.delete(:namespace)) + h[:container_project] = lazy_find_project(:name => h[:namespace]) items = h.delete(:container_limit_items) limit = collection.build(h)