Revision f8d94608
Added by Amos Benari over 11 years ago
- ID f8d946082e58b60213a27ded3e1e5f5373d976de
app/models/puppetclass.rb | ||
---|---|---|
class Puppetclass < ActiveRecord::Base
|
||
include Authorization
|
||
has_and_belongs_to_many :environments
|
||
has_many :environment_classes, :dependent => :destroy
|
||
has_many :environments, :through => :environment_classes, :uniq => true
|
||
has_and_belongs_to_many :operatingsystems
|
||
has_and_belongs_to_many :hostgroups
|
||
has_many :host_classes, :dependent => :destroy
|
||
... | ... | |
|
||
has_many :lookup_keys, :inverse_of => :puppetclass
|
||
accepts_nested_attributes_for :lookup_keys, :reject_if => lambda { |a| a[:key].blank? }, :allow_destroy => true
|
||
|
||
# param classes
|
||
has_many :class_params, :through => :environment_classes, :uniq => true,
|
||
:class_name => 'LookupKey', :source => :lookup_key, :conditions => 'environment_classes.lookup_key_id is NOT NULL'
|
||
accepts_nested_attributes_for :class_params, :reject_if => lambda { |a| a[:key].blank? }, :allow_destroy => true
|
||
validates_uniqueness_of :name
|
||
validates_presence_of :name
|
||
validates_associated :environments
|
||
validates_format_of :name, :with => /\A(\S+\s?)+\Z/, :message => "can't be blank or contain white spaces."
|
||
audited
|
||
|
||
... | ... | |
scoped_search :in => :environments, :on => :name, :complete_value => :true, :rename => "environment"
|
||
scoped_search :in => :hostgroups, :on => :name, :complete_value => :true, :rename => "hostgroup"
|
||
scoped_search :in => :hosts, :on => :name, :complete_value => :true, :rename => "host", :ext_method => :search_by_host, :only_explicit => true
|
||
scoped_search :in => :class_params, :on => :key, :complete_value => :true
|
||
|
||
scope :not_in_any_environment, includes(:environment_classes).where(:environment_classes => {:environment_id => nil})
|
||
|
||
def to_param
|
||
name
|
||
... | ... | |
name.gsub(module_name+"::","")
|
||
end
|
||
|
||
|
||
# Populates the rdoc tree with information about all the classes in your modules.
|
||
# Firstly, we prepare the modules tree
|
||
# Secondly we run puppetdoc over the modulespath and manifestdir for all environments
|
Also available in: Unified diff
fixes #832 - adds parameterized class support
Credits:
This patch adds the following featuresThis patch is based on the original work of Olivier Favre
<olivier@yakaz.com> many many thanks!
signature - each class can have a different set of parameters per environment.
users can add regexp or class names that the importer should ignore.
common usage case for this is classes such as ::config, ::install etc.
in order to use the new ENC format for puppet 2.6.5+ you should enable the
Parametrized_Classes_in_ENC and Enable_Smart_Variables_in_ENC within Foreman Settings
This is the initial patch just to get param classes support in, follow-up patches
would include a better UI and the relevant UI updates to host edit page etc.
Signed-off-by: Ohad Levy <ohadlevy@gmail.com>