Sha256: f32f7b762b90ece8cd54e1a5362ef3881eff5bc79130d87b51527037b29003d9

Contents?: true

Size: 856 Bytes

Versions: 11

Compression:

Stored size: 856 Bytes

Contents

module RedhatAccess
  module Concerns
    module HostManagedExtensions
      extend ActiveSupport::Concern
      included do
        scoped_search :on => :plan_id, :complete_enabled => false,
          :only_explicit => true, :validator => ScopedSearch::Validators::INTEGER,
          :ext_method => :search_by_plan_id
      end

      module ClassMethods
        def search_by_plan_id(key, operator, value)
          insights_plan_runner = ForemanAnsible::InsightsPlanRunner.new(Organization.current, value.to_i)
          hostname_rules_relation = insights_plan_runner.hostname_rules(insights_plan_runner.playbook)
          hosts = hostname_rules_relation.keys.map do |hostname|
            Host::Managed.find_by(:name => hostname).id
          end
          { :conditions => " hosts.id IN(#{hosts.join(',')})" }
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
redhat_access-2.1.10 app/models/redhat_access/concerns/host_managed_extensions.rb
redhat_access-2.1.9 app/models/redhat_access/concerns/host_managed_extensions.rb
redhat_access-2.1.8 app/models/redhat_access/concerns/host_managed_extensions.rb
redhat_access-2.1.7 app/models/redhat_access/concerns/host_managed_extensions.rb
redhat_access-2.1.6 app/models/redhat_access/concerns/host_managed_extensions.rb
redhat_access-2.1.5 app/models/redhat_access/concerns/host_managed_extensions.rb
redhat_access-2.1.4 app/models/redhat_access/concerns/host_managed_extensions.rb
redhat_access-2.1.3 app/models/redhat_access/concerns/host_managed_extensions.rb
redhat_access-2.1.2 app/models/redhat_access/concerns/host_managed_extensions.rb
redhat_access-2.1.1 app/models/redhat_access/concerns/host_managed_extensions.rb
redhat_access-2.1.0 app/models/redhat_access/concerns/host_managed_extensions.rb