Sha256: 75504a2df9d46f9e4b30419bec4f616a49a979962d96e7aee2b0e0ecc134e193
Contents?: true
Size: 1.64 KB
Versions: 2
Compression:
Stored size: 1.64 KB
Contents
module ForemanPuppet module Extensions module Hostgroup extend ActiveSupport::Concern included do class << self prepend PatchedClassMethods end env_assoc = reflect_on_association(:environment) env_assoc.instance_variable_set(:@class_name, 'ForemanPuppet::Environment') include_in_clone puppet: %i[host_config_groups config_groups hostgroup_classes] # will need through relation to work properly scoped_search relation: :environment, on: :name, complete_value: true, rename: :environment, only_explicit: true scoped_search relation: :puppetclasses, on: :name, complete_value: true, rename: :class, only_explicit: true, operators: ['= ', '~ '] scoped_search relation: :config_groups, on: :name, complete_value: true, rename: :config_group, only_explicit: true, operators: ['= ', '~ '], ext_method: :search_by_config_group end # Temporary, can be ordinary class_methods do, when removed from core module PatchedClassMethods def search_by_config_group(_key, operator, value) conditions = sanitize_sql_for_conditions(["config_groups.name #{operator} ?", value_to_sql(operator, value)]) hostgroup_ids = ::Hostgroup.unscoped.with_taxonomy_scope.joins(puppet: :config_groups).where(conditions).map(&:subtree_ids).flatten.uniq opts = 'hostgroups.id < 0' opts = "hostgroups.id IN(#{hostgroup_ids.join(',')})" if hostgroup_ids.present? { conditions: opts } end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
foreman_puppet-0.0.2 | app/models/concerns/foreman_puppet/extensions/hostgroup.rb |
foreman_puppet-0.0.1 | app/models/concerns/foreman_puppet/extensions/hostgroup.rb |