From 0885f2450ff52bb457048a313523763602a77619 Mon Sep 17 00:00:00 2001 From: Keenan Brock Date: Mon, 8 Jul 2024 19:53:19 -0400 Subject: [PATCH] Remove prepend_namespace We do not use prepend namespace The feature is causing us to double the number of queries when looking up objects --- .../miq_ae_engine/miq_ae_builtin_method.rb | 12 ------------ .../engine/miq_ae_engine/miq_ae_domain_search.rb | 6 ------ .../miq_ae_engine/miq_ae_workspace_runtime.rb | 2 -- .../miq_ae_method_service/miq_ae_service.rb | 4 ---- spec/miq_ae_domain_search_spec.rb | 16 ---------------- spec/miq_ae_service_spec.rb | 14 -------------- 6 files changed, 54 deletions(-) diff --git a/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_builtin_method.rb b/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_builtin_method.rb index 860cff1ae..6f07a9bc3 100644 --- a/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_builtin_method.rb +++ b/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_builtin_method.rb @@ -56,8 +56,6 @@ def self.miq_parse_provider_category(obj, _inputs) ATTRIBUTE_LIST.detect { |attr| provider_category = category_for_key(obj, attr) } $miq_ae_logger.info("Setting provider_category to: #{provider_category}", :resource_id => obj.workspace.find_miq_request_id) obj.workspace.root["ae_provider_category"] = provider_category || UNKNOWN - - prepend_vendor(obj) end def self.miq_parse_automation_request(obj, _inputs) @@ -219,16 +217,6 @@ def self.category_for_key(obj, key) end private_class_method :category_for_key - def self.prepend_vendor(obj) - vendor = nil - ATTRIBUTE_LIST.detect { |attr| vendor = detect_vendor(obj.workspace.root[attr], attr) } - if vendor - $miq_ae_logger.info("Setting prepend_namespace to: #{vendor}", :resource_id => obj.workspace.find_miq_request_id) - obj.workspace.prepend_namespace = vendor.downcase - end - end - private_class_method :prepend_vendor - def self.detect_vendor(src_obj, attr) return unless src_obj diff --git a/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_domain_search.rb b/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_domain_search.rb index e20c996f2..0da4cdb7e 100644 --- a/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_domain_search.rb +++ b/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_domain_search.rb @@ -1,12 +1,6 @@ module MiqAeEngine class MiqAeDomainSearch def initialize - @prepend_namespace = nil - end - - def prepend_namespace=(namespace) - @prepend_namespace = namespace.chomp('/').sub(%r{^/}, '') - $miq_ae_logger.info("Prepend namespace [#{@prepend_namespace}] during domain search") end def ae_user=(obj) diff --git a/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_workspace_runtime.rb b/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_workspace_runtime.rb index 51e4a2315..89f246cf1 100644 --- a/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_workspace_runtime.rb +++ b/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_workspace_runtime.rb @@ -26,8 +26,6 @@ def initialize(options = {}) initialize_obj_entries end - delegate :prepend_namespace=, :to => :@dom_search - def readonly? @readonly end diff --git a/lib/miq_automation_engine/engine/miq_ae_method_service/miq_ae_service.rb b/lib/miq_automation_engine/engine/miq_ae_method_service/miq_ae_service.rb index e9f46825e..f90be72aa 100644 --- a/lib/miq_automation_engine/engine/miq_ae_method_service/miq_ae_service.rb +++ b/lib/miq_automation_engine/engine/miq_ae_method_service/miq_ae_service.rb @@ -123,10 +123,6 @@ def delete_service_var(name) service_object.root_service.delete_service_vars_option(name) end - def prepend_namespace=(namespace) - @workspace.prepend_namespace = namespace - end - def instantiate(uri) obj = @workspace.instantiate(uri, @workspace.ae_user, @workspace.current_object) return nil if obj.nil? diff --git a/spec/miq_ae_domain_search_spec.rb b/spec/miq_ae_domain_search_spec.rb index 5ae40dc8d..e6a130f98 100644 --- a/spec/miq_ae_domain_search_spec.rb +++ b/spec/miq_ae_domain_search_spec.rb @@ -49,20 +49,4 @@ def create_vendor_ae_methods ns = search.get_alternate_domain_method('miqaedb', '/FRED/WILMA/OBELIX', 'FRED', 'WILMA', 'OBELIX') expect(ns).to eq('BARNEY/FRED') end - - it "#get_alternate_domain with vendor" do - create_vendor_ae_instances - search.ae_user = user - search.prepend_namespace = "/AMAZON/" - ns = search.get_alternate_domain('miqaedb', '/TEST/PROV/ONE', 'TEST', 'PROV', 'ONE') - expect(ns).to eq('AMAZON/AMAZON/TEST') - end - - it "#get_alternate_domain_method with vendor" do - create_vendor_ae_methods - search.ae_user = user - search.prepend_namespace = "/OPENSTACK/" - ns = search.get_alternate_domain_method('miqaedb', '/TEST/WILMA/OBELIX', 'TEST', 'WILMA', 'OBELIX') - expect(ns).to eq('OPENSTACK/OPENSTACK/TEST') - end end diff --git a/spec/miq_ae_service_spec.rb b/spec/miq_ae_service_spec.rb index d42972b05..d82baeb91 100644 --- a/spec/miq_ae_service_spec.rb +++ b/spec/miq_ae_service_spec.rb @@ -221,20 +221,6 @@ def invoke_ae end describe MiqAeMethodService::MiqAeService do - context "#prepend_namespace=" do - let(:options) { {} } - let(:workspace) { double("MiqAeEngine::MiqAeWorkspaceRuntime", :root => options) } - let(:miq_ae_service) { described_class.new(workspace) } - let(:ns) { "fred" } - - it "set namespace" do - allow(workspace).to receive(:disable_rbac) - allow(workspace).to receive(:persist_state_hash).and_return(MiqAeEngine::StateVarHash.new) - expect(workspace).to receive(:prepend_namespace=).with(ns) - - miq_ae_service.prepend_namespace = ns - end - end context "create notifications" do before do NotificationType.seed