diff options
author | Luke Kanies <luke@madstop.com> | 2008-03-05 12:30:45 -0600 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2008-03-05 12:30:45 -0600 |
commit | c2b33acd5c1e6fe4021d7609f806b7bd8af834f8 (patch) | |
tree | c2c725a171d02d1ac304547d23716b9524beaabf /lib | |
parent | 93a2189ef7c31bd31821eddc87f91b02b7f5a233 (diff) | |
parent | 443db2009d0f5033eb51ebd210af2a198572fad0 (diff) | |
download | puppet-c2b33acd5c1e6fe4021d7609f806b7bd8af834f8.tar.gz puppet-c2b33acd5c1e6fe4021d7609f806b7bd8af834f8.tar.xz puppet-c2b33acd5c1e6fe4021d7609f806b7bd8af834f8.zip |
Merge branch '0.24.x'
Diffstat (limited to 'lib')
35 files changed, 187 insertions, 268 deletions
diff --git a/lib/puppet.rb b/lib/puppet.rb index 2f4d6308f..fddd51c8e 100644 --- a/lib/puppet.rb +++ b/lib/puppet.rb @@ -25,7 +25,7 @@ require 'puppet/util/suidmanager' # it's also a place to find top-level commands like 'debug' module Puppet - PUPPETVERSION = '0.24.1' + PUPPETVERSION = '0.24.2' def Puppet.version return PUPPETVERSION @@ -414,6 +414,7 @@ module Puppet end require 'puppet/type' +require 'puppet/network' require 'puppet/module' require 'puppet/util/storage' require 'puppet/parser/interpreter' diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index 4fb03f164..6dbd7d043 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -140,8 +140,6 @@ module Puppet :show_diff => [false, "Whether to print a contextual diff when files are being replaced. The diff is printed on stdout, so this option is meaningless unless you are running Puppet interactively. This feature currently requires the ``diff/lcs`` Ruby library."], - :yamldir => {:default => "$vardir/yaml", :owner => "$user", :group => "$user", :mode => "750", - :desc => "The directory in which YAML data is stored, usually in a subdirectory."}, :daemonize => { :default => true, :desc => "Send the process into the background. This is the default.", :short => "D" @@ -672,5 +670,10 @@ module Puppet :rrdinterval => ["$runinterval", "How often RRD should expect data. This should match how often the hosts report back to the server."] ) + + Puppet.setdefaults(:yaml, + :yamldir => {:default => "$vardir/yaml", :owner => "$user", :group => "$user", :mode => "750", + :desc => "The directory in which YAML data is stored, usually in a subdirectory."} + ) end diff --git a/lib/puppet/file_serving/file_base.rb b/lib/puppet/file_serving/file_base.rb index 06b3ad9ef..e87d683aa 100644 --- a/lib/puppet/file_serving/file_base.rb +++ b/lib/puppet/file_serving/file_base.rb @@ -46,6 +46,7 @@ class Puppet::FileServing::FileBase # Determine how we deal with links. attr_reader :links def links=(value) + value = :manage if value == :ignore raise(ArgumentError, ":links can only be set to :manage or :follow") unless [:manage, :follow].include?(value) @links = value end diff --git a/lib/puppet/metatype/closure.rb b/lib/puppet/metatype/closure.rb index 259854411..673a2359d 100644 --- a/lib/puppet/metatype/closure.rb +++ b/lib/puppet/metatype/closure.rb @@ -20,6 +20,10 @@ class Puppet::Type end end + def isomorphic? + self.class.isomorphic? + end + # is the instance a managed instance? A 'yes' here means that # the instance was created from the language, vs. being created # in order resolve other questions, such as finding a package diff --git a/lib/puppet/network.rb b/lib/puppet/network.rb new file mode 100644 index 000000000..8993b8869 --- /dev/null +++ b/lib/puppet/network.rb @@ -0,0 +1,3 @@ +# Just a stub, so we can correctly scope other classes. +module Puppet::Network # :nodoc: +end diff --git a/lib/puppet/network/client.rb b/lib/puppet/network/client.rb index 0a0a72345..cf1782f79 100644 --- a/lib/puppet/network/client.rb +++ b/lib/puppet/network/client.rb @@ -7,6 +7,8 @@ require 'puppet/util/subclass_loader' require 'puppet/util/methodhelper' require 'puppet/sslcertificates/support' +require 'puppet/network/handler' + require 'net/http' # Some versions of ruby don't have this method defined, which basically causes diff --git a/lib/puppet/network/client/master.rb b/lib/puppet/network/client/master.rb index 390f3d4e2..913c51b3d 100644 --- a/lib/puppet/network/client/master.rb +++ b/lib/puppet/network/client/master.rb @@ -26,14 +26,15 @@ class Puppet::Network::Client::Master < Puppet::Network::Client down = Puppet[:downcasefacts] - facts = {} - Facter.each { |name,fact| + facts = Facter.to_hash.inject({}) do |newhash, array| + name, fact = array if down - facts[name] = fact.to_s.downcase + newhash[name] = fact.to_s.downcase else - facts[name] = fact.to_s + newhash[name] = fact.to_s end - } + newhash + end # Add our client version to the list of facts, so people can use it # in their manifests diff --git a/lib/puppet/network/handler/fileserver.rb b/lib/puppet/network/handler/fileserver.rb index a9a95bcfe..751a77220 100755 --- a/lib/puppet/network/handler/fileserver.rb +++ b/lib/puppet/network/handler/fileserver.rb @@ -69,8 +69,8 @@ class Puppet::Network::Handler mount.debug("Describing %s for %s" % [url, client]) if client - # Remove any leading slashes, since Metadata doesn't like them, yo. - metadata = Puppet::FileServing::Metadata.new(url, :path => mount.path(client), :relative_path => path.sub(/^\//, ''), :links => links) + # use the mount to resolve the path for us. + metadata = Puppet::FileServing::Metadata.new(url, :path => mount.file_path(path, client), :links => links) return "" unless metadata.exist? diff --git a/lib/puppet/node/catalog.rb b/lib/puppet/node/catalog.rb index d680de9a0..f885a41ee 100644 --- a/lib/puppet/node/catalog.rb +++ b/lib/puppet/node/catalog.rb @@ -73,7 +73,7 @@ class Puppet::Node::Catalog < Puppet::PGraph # If the name and title differ, set up an alias #self.alias(resource, resource.name) if resource.respond_to?(:name) and resource.respond_to?(:title) and resource.name != resource.title if resource.respond_to?(:name) and resource.respond_to?(:title) and resource.name != resource.title - self.alias(resource, resource.name) if resource.class.isomorphic? + self.alias(resource, resource.name) if resource.isomorphic? end resource.catalog = self if resource.respond_to?(:catalog=) and ! is_relationship_graph diff --git a/lib/puppet/parser/ast/astarray.rb b/lib/puppet/parser/ast/astarray.rb index b66fd6bba..8f09aa922 100644 --- a/lib/puppet/parser/ast/astarray.rb +++ b/lib/puppet/parser/ast/astarray.rb @@ -16,16 +16,6 @@ class Puppet::Parser::AST # Evaluate our children. def evaluate(scope) - rets = nil - # We basically always operate declaratively, and when we - # do we need to evaluate the settor-like statements first. This - # is basically variable and type-default declarations. - # This is such a stupid hack. I've no real idea how to make a - # "real" declarative language, so I hack it so it looks like - # one, yay. - settors = [] - others = [] - # Make a new array, so we don't have to deal with the details of # flattening and such items = [] @@ -34,22 +24,14 @@ class Puppet::Parser::AST @children.each { |child| if child.instance_of?(AST::ASTArray) child.each do |ac| - if ac.class.settor? - settors << ac - else - others << ac - end + items << ac end else - if child.class.settor? - settors << child - else - others << child - end + items << child end } - rets = [settors, others].flatten.collect { |child| + rets = items.flatten.collect { |child| child.safeevaluate(scope) } return rets.reject { |o| o.nil? } diff --git a/lib/puppet/parser/ast/definition.rb b/lib/puppet/parser/ast/definition.rb index 2b7506446..0c65c702c 100644 --- a/lib/puppet/parser/ast/definition.rb +++ b/lib/puppet/parser/ast/definition.rb @@ -24,9 +24,6 @@ class Puppet::Parser::AST::Definition < Puppet::Parser::AST::Branch # Create a resource that knows how to evaluate our actual code. def evaluate(scope) - # Do nothing if the resource already exists; this provides the singleton nature classes need. - return if scope.catalog.resource(self.class.name, self.classname) - resource = Puppet::Parser::Resource.new(:type => self.class.name, :title => self.classname, :scope => scope, :source => scope.source) scope.catalog.tag(*resource.tags) diff --git a/lib/puppet/parser/ast/hostclass.rb b/lib/puppet/parser/ast/hostclass.rb index 8d4d01660..7f89f8151 100644 --- a/lib/puppet/parser/ast/hostclass.rb +++ b/lib/puppet/parser/ast/hostclass.rb @@ -21,7 +21,14 @@ class Puppet::Parser::AST::HostClass < Puppet::Parser::AST::Definition # Make sure our parent class has been evaluated, if we have one. def evaluate(scope) if parentclass and ! scope.catalog.resource(self.class.name, parentclass) - resource = parentobj.evaluate(scope) + parent_resource = parentobj.evaluate(scope) + end + + # Do nothing if the resource already exists; this makes sure we don't + # get multiple copies of the class resource, which helps provide the + # singleton nature of classes. + if resource = scope.catalog.resource(self.class.name, self.classname) + return resource end super diff --git a/lib/puppet/parser/compiler.rb b/lib/puppet/parser/compiler.rb index 132ec15db..70cd6e11a 100644 --- a/lib/puppet/parser/compiler.rb +++ b/lib/puppet/parser/compiler.rb @@ -366,9 +366,8 @@ class Puppet::Parser::Compiler # Make sure all of our resources and such have done any last work # necessary. def finish - @catalog.resources.each do |name| - resource = @catalog.resource(name) - + #@catalog.resources.each do |name| + @catalog.vertices.each do |resource| # Add in any resource overrides. if overrides = resource_overrides(resource) overrides.each do |over| diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb index d4655c403..f27c1c5c8 100644 --- a/lib/puppet/parser/interpreter.rb +++ b/lib/puppet/parser/interpreter.rb @@ -61,7 +61,11 @@ class Puppet::Parser::Interpreter # If a parser already exists, than assume that we logged the # exception elsewhere and reuse the parser. If one doesn't # exist, then reraise. - raise detail unless @parsers[environment] + if @parsers[environment] + Puppet.err detail + else + raise detail + end end end @parsers[environment] diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb index fb0799011..b001e165b 100644 --- a/lib/puppet/parser/resource.rb +++ b/lib/puppet/parser/resource.rb @@ -82,12 +82,19 @@ class Puppet::Parser::Resource # Do any finishing work on this object, called before evaluation or # before storage/translation. def finish + return if finished? + @finished = true add_defaults() add_metaparams() add_scope_tags() validate() end + # Has this resource already been finished? + def finished? + defined?(@finished) and @finished + end + def initialize(options) # Set all of the options we can. options.each do |option, value| @@ -133,6 +140,15 @@ class Puppet::Parser::Resource tag(@ref.title) if valid_tag?(@ref.title.to_s) end + # Is this resource modeling an isomorphic resource type? + def isomorphic? + if builtin? + return @ref.builtintype.isomorphic? + else + return true + end + end + # Merge an override resource in. This will throw exceptions if # any overrides aren't allowed. def merge(resource) diff --git a/lib/puppet/provider/interface/redhat.rb b/lib/puppet/provider/interface/redhat.rb index aa217620e..4a9fcb491 100644 --- a/lib/puppet/provider/interface/redhat.rb +++ b/lib/puppet/provider/interface/redhat.rb @@ -5,7 +5,7 @@ Puppet::Type.type(:interface).provide(:redhat) do desc "Manage network interfaces on Red Hat operating systems. This provider parses and generates configuration files in ``/etc/sysconfig/network-scripts``." - INTERFACE_DIR = "/etc/sysconfig/network-scripts" + INTERFACE_DIR = "/etc/sysconfig/network-scripts" confine :exists => INTERFACE_DIR defaultfor :operatingsystem => [:fedora, :centos, :redhat] @@ -43,52 +43,52 @@ NETMASK=<%= self.netmask %> BROADCAST= LOOPBACKDUMMY - # maximum number of dummy interfaces - @max_dummies = 10 + # maximum number of dummy interfaces + @max_dummies = 10 - # maximum number of aliases per interface - @max_aliases_per_iface = 10 + # maximum number of aliases per interface + @max_aliases_per_iface = 10 - @@dummies = [] - @@aliases = Hash.new { |hash, key| hash[key] = [] } + @@dummies = [] + @@aliases = Hash.new { |hash, key| hash[key] = [] } - # calculate which dummy interfaces are currently already in - # use prior to needing to call self.next_dummy later on. - def self.instances - # parse all of the config files at once - Dir.glob("%s/ifcfg-*" % INTERFACE_DIR).collect do |file| - record = parse(file) + # calculate which dummy interfaces are currently already in + # use prior to needing to call self.next_dummy later on. + def self.instances + # parse all of the config files at once + Dir.glob("%s/ifcfg-*" % INTERFACE_DIR).collect do |file| + record = parse(file) - # store the existing dummy interfaces + # store the existing dummy interfaces @@dummies << record[:ifnum] if (record[:interface_type] == :dummy and ! @@dummies.include?(record[:ifnum])) @@aliases[record[:interface]] << record[:ifnum] if record[:interface_type] == :alias new(record) - end - end - - # return the next avaliable dummy interface number, in the case where - # ifnum is not manually specified - def self.next_dummy - @max_dummies.times do |i| - unless @@dummies.include?(i.to_s) - @@dummies << i.to_s - return i.to_s - end - end - end - - # return the next available alias on a given interface, in the case - # where ifnum if not manually specified - def self.next_alias(interface) - @max_aliases_per_iface.times do |i| - unless @@aliases[interface].include?(i.to_s) - @@aliases[interface] << i.to_s - return i.to_s - end - end - end + end + end + + # return the next avaliable dummy interface number, in the case where + # ifnum is not manually specified + def self.next_dummy + @max_dummies.times do |i| + unless @@dummies.include?(i.to_s) + @@dummies << i.to_s + return i.to_s + end + end + end + + # return the next available alias on a given interface, in the case + # where ifnum if not manually specified + def self.next_alias(interface) + @max_aliases_per_iface.times do |i| + unless @@aliases[interface].include?(i.to_s) + @@aliases[interface] << i.to_s + return i.to_s + end + end + end # base the ifnum, for dummy / loopback interface in linux # on the last octect of the IP address @@ -139,14 +139,14 @@ LOOPBACKDUMMY # on whether we are adding an alias to a real interface, or a loopback # address (also dummy) on linux. For linux it's quite involved, and we # will use an ERB template - def generate + def generate itype = self.interface_type == :alias ? :alias : :normal self.class.template(itype).result(binding) - end + end # Where should the file be written out? - # This defaults to INTERFACE_DIR/ifcfg-<namevar>, but can have a - # more symbolic name by setting interface_desc in the type. + # This defaults to INTERFACE_DIR/ifcfg-<namevar>, but can have a + # more symbolic name by setting interface_desc in the type. def file_path if resource and val = resource[:interface_desc] desc = val @@ -185,16 +185,16 @@ LOOPBACKDUMMY end end - # create the device name, so this based on the IP, and interface + type - def device - case @resource.should(:interface_type) - when :loopback - @property_hash[:ifnum] ||= self.class.next_dummy - return "dummy" + @property_hash[:ifnum] - when :alias - @property_hash[:ifnum] ||= self.class.next_alias(@resource[:interface]) - return @resource[:interface] + ":" + @property_hash[:ifnum] - end + # create the device name, so this based on the IP, and interface + type + def device + case @resource.should(:interface_type) + when :loopback + @property_hash[:ifnum] ||= self.class.next_dummy + return "dummy" + @property_hash[:ifnum] + when :alias + @property_hash[:ifnum] ||= self.class.next_alias(@resource[:interface]) + return @resource[:interface] + ":" + @property_hash[:ifnum] + end end # Set the name to our ip address. @@ -202,19 +202,19 @@ LOOPBACKDUMMY @property_hash[:name] = value end - # whether the device is to be brought up on boot or not. converts - # the true / false of the type, into yes / no values respectively - # writing out the ifcfg-* files - def on_boot - case @property_hash[:onboot].to_s - when "true" - return "yes" - when "false" - return "no" - else - return "neither" - end - end + # whether the device is to be brought up on boot or not. converts + # the true / false of the type, into yes / no values respectively + # writing out the ifcfg-* files + def on_boot + case @property_hash[:onboot].to_s + when "true" + return "yes" + when "false" + return "no" + else + return "neither" + end + end # Mark whether the interface should be started on boot. def on_boot=(value) diff --git a/lib/puppet/provider/package/yumhelper.py b/lib/puppet/provider/package/yumhelper.py index 1142401b9..962b96ce4 100644 --- a/lib/puppet/provider/package/yumhelper.py +++ b/lib/puppet/provider/package/yumhelper.py @@ -13,8 +13,7 @@ OVERRIDE_OPTS = { 'logfile': '/dev/null' } -def pkg_lists(): - my = yum.YumBase() +def pkg_lists(my): my.doConfigSetup() for k in OVERRIDE_OPTS.keys(): @@ -28,10 +27,13 @@ def pkg_lists(): return my.doPackageLists('updates') try: - ypl = pkg_lists() + try: + my = yum.YumBase() + ypl = pkg_lists(my) + for pkg in ypl.updates: + print "_pkg %s %s %s %s %s" % (pkg.name, pkg.epoch, pkg.version, pkg.release, pkg.arch) + finally: + my.closeRpmDB() except IOError, e: print "_err IOError %d %s" % (e.errno, e) sys.exit(1) - -for pkg in ypl.updates: - print "_pkg %s %s %s %s %s" % (pkg.name, pkg.epoch, pkg.version, pkg.release, pkg.arch) diff --git a/lib/puppet/rails.rb b/lib/puppet/rails.rb index a1192bf20..a021c773a 100644 --- a/lib/puppet/rails.rb +++ b/lib/puppet/rails.rb @@ -91,6 +91,10 @@ module Puppet::Rails raise Puppet::Error, "Could not find Puppet::Rails database dir" end + unless ActiveRecord::Base.connection.tables.include?("resources") + raise Puppet::Error, "Database has problems, can't migrate." + end + Puppet.notice "Migrating" begin diff --git a/lib/puppet/rails/database/001_add_created_at_to_all_tables.rb b/lib/puppet/rails/database/001_add_created_at_to_all_tables.rb new file mode 100644 index 000000000..71ee6aeed --- /dev/null +++ b/lib/puppet/rails/database/001_add_created_at_to_all_tables.rb @@ -0,0 +1,17 @@ +class AddCreatedAtToAllTables < ActiveRecord::Migration + def self.up + ActiveRecord::Base.connection.tables.each do |t| + unless ActiveRecord::Base.connection.columns(t).collect {|c| c.name}.include?("created_at") + add_column t.to_s, :created_at, :datetime + end + end + end + + def self.down + ActiveRecord::Base.connection.tables.each do |t| + unless ActiveRecord::Base.connection.columns(t).collect {|c| c.name}.include?("created_at") + remove_column t.to_s, :created_at + end + end + end +end diff --git a/lib/puppet/rails/external/tagging/README b/lib/puppet/rails/external/tagging/README deleted file mode 100644 index 8d2f90822..000000000 --- a/lib/puppet/rails/external/tagging/README +++ /dev/null @@ -1,4 +0,0 @@ -Acts As Taggable -================= - -Allows for tags to be added to multiple classes.
\ No newline at end of file diff --git a/lib/puppet/rails/external/tagging/acts_as_taggable.rb b/lib/puppet/rails/external/tagging/acts_as_taggable.rb deleted file mode 100644 index 7fd7f6b12..000000000 --- a/lib/puppet/rails/external/tagging/acts_as_taggable.rb +++ /dev/null @@ -1,62 +0,0 @@ -module ActiveRecord
- module Acts #:nodoc:
- module Taggable #:nodoc:
- def self.included(base)
- base.extend(ClassMethods)
- end
-
- module ClassMethods
- def acts_as_taggable(options = {})
- write_inheritable_attribute(:acts_as_taggable_options, {
- :taggable_type => ActiveRecord::Base.send(:class_name_of_active_record_descendant, self).to_s,
- :from => options[:from]
- })
-
- class_inheritable_reader :acts_as_taggable_options
-
- has_many :taggings, :as => :taggable, :dependent => :destroy
- has_many :tags, :through => :taggings
-
- include ActiveRecord::Acts::Taggable::InstanceMethods
- extend ActiveRecord::Acts::Taggable::SingletonMethods
- end
- end
-
- module SingletonMethods
- def find_tagged_with(list)
- find_by_sql([
- "SELECT #{table_name}.* FROM #{table_name}, tags, taggings " +
- "WHERE #{table_name}.#{primary_key} = taggings.taggable_id " +
- "AND taggings.taggable_type = ? " +
- "AND taggings.tag_id = tags.id AND tags.name IN (?)",
- acts_as_taggable_options[:taggable_type], list
- ])
- end
- def tags(options = {})
- options.merge!(:taggable_type => self.to_s)
- Tag.tags(options)
- end
- end
-
- module InstanceMethods
- def tag_with(list)
- Tag.transaction do
- taggings.destroy_all
-
- Tag.parse(list).each do |name|
- if acts_as_taggable_options[:from]
- send(acts_as_taggable_options[:from]).tags.find_or_create_by_name(name).on(self)
- else
- Tag.find_or_create_by_name(name).on(self)
- end
- end
- end
- end
-
- def tag_list
- tags.collect { |tag| tag.name.include?(" ") ? "'#{tag.name}'" : tag.name }.join(" ")
- end
- end
- end
- end
-end
diff --git a/lib/puppet/rails/external/tagging/init.rb b/lib/puppet/rails/external/tagging/init.rb deleted file mode 100644 index 5069d8040..000000000 --- a/lib/puppet/rails/external/tagging/init.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'puppet/rails/external/tagging/acts_as_taggable' -ActiveRecord::Base.send(:include, ActiveRecord::Acts::Taggable) - -require 'puppet/rails/external/tagging/tagging' -require 'puppet/rails/external/tagging/tag' diff --git a/lib/puppet/rails/external/tagging/tag.rb b/lib/puppet/rails/external/tagging/tag.rb deleted file mode 100644 index c6bf4ca78..000000000 --- a/lib/puppet/rails/external/tagging/tag.rb +++ /dev/null @@ -1,50 +0,0 @@ -class Tag < ActiveRecord::Base - has_many :taggings - - def self.tags(options = {}) - query = "select tags.id, name, count(*) as count" - query << " from taggings, tags" - query << " where tags.id = tag_id" - query << " group by tag_id" - query << " order by #{options[:order]}" if options[:order] != nil - query << " limit #{options[:limit]}" if options[:limit] != nil - tags = Tag.find_by_sql(query) - end - - def self.parse(list) - tag_names = [] - - # first, pull out the quoted tags - list.gsub!(/\"(.*?)\"\s*/ ) { tag_names << $1; "" } - - # then, replace all commas with a space - list.gsub!(/,/, " ") - - # then, get whatever's left - tag_names.concat list.split(/\s/) - - # strip whitespace from the names - tag_names = tag_names.map { |t| t.strip } - - # delete any blank tag names - tag_names = tag_names.delete_if { |t| t.empty? } - - return tag_names - end - - def tagged - @tagged ||= taggings.collect { |tagging| tagging.taggable } - end - - def on(taggable) - taggings.build :taggable => taggable - end - - def ==(comparison_object) - super || name == comparison_object.to_s - end - - def to_s - name - end -end diff --git a/lib/puppet/rails/external/tagging/tagging.rb b/lib/puppet/rails/external/tagging/tagging.rb deleted file mode 100644 index e06e88a14..000000000 --- a/lib/puppet/rails/external/tagging/tagging.rb +++ /dev/null @@ -1,12 +0,0 @@ -class Tagging < ActiveRecord::Base - belongs_to :tag - belongs_to :taggable, :polymorphic => true - - def self.tagged_class(taggable) - ActiveRecord::Base.send(:class_name_of_active_record_descendant, taggable.class).to_s - end - - def self.find_taggable(tagged_class, tagged_id) - tagged_class.constantize.find(tagged_id) - end -end
\ No newline at end of file diff --git a/lib/puppet/rails/fact_value.rb b/lib/puppet/rails/fact_value.rb index 0eb70be72..b53591d7e 100644 --- a/lib/puppet/rails/fact_value.rb +++ b/lib/puppet/rails/fact_value.rb @@ -1,6 +1,10 @@ class Puppet::Rails::FactValue < ActiveRecord::Base belongs_to :fact_name belongs_to :host + + def to_label + "#{self.fact_name.name}" + end end # $Id: fact_value.rb 1952 2006-12-19 05:47:57Z luke $ diff --git a/lib/puppet/rails/host.rb b/lib/puppet/rails/host.rb index 72898fd97..626edaa88 100644 --- a/lib/puppet/rails/host.rb +++ b/lib/puppet/rails/host.rb @@ -11,8 +11,7 @@ class Puppet::Rails::Host < ActiveRecord::Base has_many :fact_values, :dependent => :destroy has_many :fact_names, :through => :fact_values - belongs_to :puppet_classes - has_many :source_files + belongs_to :source_file has_many :resources, :include => :param_values, :dependent => :destroy diff --git a/lib/puppet/rails/param_value.rb b/lib/puppet/rails/param_value.rb index 02c29c540..fc00a43d4 100644 --- a/lib/puppet/rails/param_value.rb +++ b/lib/puppet/rails/param_value.rb @@ -20,5 +20,9 @@ class Puppet::Rails::ParamValue < ActiveRecord::Base self[:value] = val end end + + def to_label + "#{self.param_name.name}" + end end diff --git a/lib/puppet/rails/puppet_class.rb b/lib/puppet/rails/puppet_class.rb deleted file mode 100644 index 35cef8974..000000000 --- a/lib/puppet/rails/puppet_class.rb +++ /dev/null @@ -1,6 +0,0 @@ -class Puppet::Rails::PuppetClass < ActiveRecord::Base - has_many :resources - has_many :source_files - has_many :hosts -end - diff --git a/lib/puppet/rails/resource_tag.rb b/lib/puppet/rails/resource_tag.rb index d06711877..f9694e082 100644 --- a/lib/puppet/rails/resource_tag.rb +++ b/lib/puppet/rails/resource_tag.rb @@ -1,4 +1,8 @@ class Puppet::Rails::ResourceTag < ActiveRecord::Base belongs_to :puppet_tag belongs_to :resource + + def to_label + "#{self.puppet_tag.name}" + end end diff --git a/lib/puppet/rails/source_file.rb b/lib/puppet/rails/source_file.rb index 51d1b1fb5..3ccf87ac6 100644 --- a/lib/puppet/rails/source_file.rb +++ b/lib/puppet/rails/source_file.rb @@ -1,5 +1,8 @@ class Puppet::Rails::SourceFile < ActiveRecord::Base has_one :host - has_one :puppet_class has_one :resource + + def to_label + "#{self.filename}" + end end diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb index 976bf7c68..14b2037f4 100644 --- a/lib/puppet/transaction.rb +++ b/lib/puppet/transaction.rb @@ -15,8 +15,6 @@ class Transaction # The list of events generated in this transaction. attr_reader :events - attr_writer :tags - include Puppet::Util # Add some additional times for reporting @@ -636,6 +634,11 @@ class Transaction @tags end + + def tags=(tags) + tags = [tags] unless tags.is_a?(Array) + @tags = tags + end # Is this resource tagged appropriately? def missing_tags?(resource) diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb index f8049236f..2772b54a8 100755 --- a/lib/puppet/type/exec.rb +++ b/lib/puppet/type/exec.rb @@ -211,10 +211,7 @@ module Puppet log the output when the command reports an error. Values are **true**, *false*, *on_failure*, and any legal log level." - values = [:true, :false, :on_failure] - # And all of the log levels - Puppet::Util::Log.eachlevel { |level| values << level } - newvalues(*values) + newvalues(:true, :false, :on_failure) end newparam(:refresh) do diff --git a/lib/puppet/type/mailalias.rb b/lib/puppet/type/mailalias.rb index 92f609267..50ca26ef6 100755 --- a/lib/puppet/type/mailalias.rb +++ b/lib/puppet/type/mailalias.rb @@ -9,7 +9,7 @@ module Puppet end newproperty(:recipient, :array_matching => :all) do - desc "Where email should should be sent. Multiple values + desc "Where email should be sent. Multiple values should be specified as an array." def is_to_s(value) diff --git a/lib/puppet/type/package.rb b/lib/puppet/type/package.rb index ee2871ce2..f004f7c42 100644 --- a/lib/puppet/type/package.rb +++ b/lib/puppet/type/package.rb @@ -211,14 +211,6 @@ module Puppet desc "Where to find the actual package. This must be a local file (or on a network file system) or a URL that your specific packaging type understands; Puppet will not retrieve files for you." - - validate do |value| - unless value =~ /^#{File::SEPARATOR}/ or value =~ /\w+:\/\// - self.fail( - "Package sources must be fully qualified files or URLs, depending on the platform." - ) - end - end end newparam(:instance) do desc "A read-only parameter set by the package." diff --git a/lib/puppet/type/service.rb b/lib/puppet/type/service.rb index c41a7883b..1b625cc41 100644 --- a/lib/puppet/type/service.rb +++ b/lib/puppet/type/service.rb @@ -28,6 +28,8 @@ module Puppet feature :enableable, "The provider can enable and disable the service", :methods => [:disable, :enable, :enabled?] + feature :controllable, "The provider uses a control variable." + newproperty(:enable, :required_features => :enableable) do desc "Whether a service should be enabled to start at boot. This property behaves quite differently depending on the platform; @@ -163,6 +165,13 @@ module Puppet desc "Specify a *stop* command manually." end + newparam(:control) do + desc "The control variable used to manage services (originally for HP-UX). + Defaults to the upcased service name plus ``START`` replacing dots with + underscores, for those providers that support the ``controllable`` feature." + defaultto { resource.name.gsub(".","_").upcase + "_START" if resource.provider.controllable? } + end + newparam :hasrestart do desc "Specify that an init script has a ``restart`` option. Otherwise, the init script's ``stop`` and ``start`` methods are used." |