Project

General

Profile

Download (687 Bytes) Statistics
| Branch: | Tag: | Revision:
086ec942 Ohad Levy
class Hostgroup < ActiveRecord::Base
has_and_belongs_to_many :puppetclasses
validates_uniqueness_of :name
9d5bb4fd Lucas Tolchinsky
validates_format_of :name, :with => /\A(\S+\s?)+\Z/, :message => "can't be blank or contain trailing white spaces."
086ec942 Ohad Levy
has_many :group_parameters, :dependent => :destroy
bd46fa41 Ohad Levy
accepts_nested_attributes_for :group_parameters, :reject_if => lambda { |a| a[:value].blank? }, :allow_destroy => true
086ec942 Ohad Levy
has_many :hosts
17a015c2 Ohad Levy
before_destroy Ensure_not_used_by.new(:hosts)
b09b4515 Ohad Levy
default_scope :order => 'name'
086ec942 Ohad Levy
611397af Ohad Levy
acts_as_audited
086ec942 Ohad Levy
#TODO: add a method that returns the valid os for a hostgroup

72e65b31 Ohad Levy
def to_s
name
end
b09b4515 Ohad Levy
def all_puppetclasses
puppetclasses
end

def hostgroup
self
end

086ec942 Ohad Levy
end