Skip to content

Commit

Permalink
Remove prepend_namespace
Browse files Browse the repository at this point in the history
We do not use prepend namespace
The feature is causing us to double the number of queries when
looking up objects
  • Loading branch information
kbrock committed Jul 8, 2024
1 parent 7707684 commit 0885f24
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ def initialize(options = {})
initialize_obj_entries
end

delegate :prepend_namespace=, :to => :@dom_search

def readonly?
@readonly
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
16 changes: 0 additions & 16 deletions spec/miq_ae_domain_search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 0 additions & 14 deletions spec/miq_ae_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0885f24

Please sign in to comment.