From bfcd62638365b1e6f4e63ea8ae1be4dfc724e5da Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Tue, 22 Jul 2008 16:13:48 +1000 Subject: Fixes #1445 and #1426 --- lib/puppet/provider/service/redhat.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/puppet/provider/service/redhat.rb b/lib/puppet/provider/service/redhat.rb index 48da577ec..d26f76ebd 100755 --- a/lib/puppet/provider/service/redhat.rb +++ b/lib/puppet/provider/service/redhat.rb @@ -59,7 +59,12 @@ Puppet::Type.type(:service).provide :redhat, :parent => :init do def status if @resource[:hasstatus] == :true - service(@resource[:name], "status") + begin + service(@resource[:name], "status") + return :running + rescue + return :stopped + end else super end -- cgit From aac7dd1cc2da1d90218b54ca06a5703923b63fa9 Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Tue, 22 Jul 2008 18:21:34 +1000 Subject: Incremented versions --- lib/puppet.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/puppet.rb b/lib/puppet.rb index 83e5da68f..21e27147f 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.4' + PUPPETVERSION = '0.24.5' def Puppet.version return PUPPETVERSION -- cgit From fe99828511afbf701aa03f8dbf6d725020539602 Mon Sep 17 00:00:00 2001 From: Nigel Kersten Date: Thu, 24 Jul 2008 19:40:50 -0700 Subject: Bug #1448: Puppet CA incorrectly writes out all certs to inventory .txt on each certificate signing --- lib/puppet/sslcertificates/inventory.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/puppet/sslcertificates/inventory.rb b/lib/puppet/sslcertificates/inventory.rb index da959aa3b..295c416cb 100644 --- a/lib/puppet/sslcertificates/inventory.rb +++ b/lib/puppet/sslcertificates/inventory.rb @@ -7,8 +7,9 @@ module Puppet::SSLCertificates # If no inventory exists yet, build an inventory and list all the # certificates that have been signed so far def self.add(cert) - unless FileTest.exists?(Puppet[:cert_inventory]) - inited = false + inited = false + if FileTest.exists?(Puppet[:cert_inventory]) + inited = true end Puppet.settings.write(:cert_inventory, "a") do |f| -- cgit From 97987a705da7b8126569b1f5b7c3676ad0220f66 Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Tue, 29 Jul 2008 08:07:56 +1000 Subject: Feature #1241 : Improve performance of group lookups --- lib/puppet/util/posix.rb | 81 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 67 insertions(+), 14 deletions(-) (limited to 'lib') diff --git a/lib/puppet/util/posix.rb b/lib/puppet/util/posix.rb index cc0340ef7..9281169ea 100755 --- a/lib/puppet/util/posix.rb +++ b/lib/puppet/util/posix.rb @@ -3,23 +3,22 @@ module Puppet::Util::POSIX # Retrieve a field from a POSIX Etc object. The id can be either an integer # or a name. This only works for users and groups. It's also broken on - # some platforms, unfortunately. - def old_get_posix_field(space, field, id) + # some platforms, unfortunately, which is why we fall back to the other + # method search_posix_field in the gid and uid methods if a sanity check + # fails + def get_posix_field(space, field, id) unless id raise ArgumentError, "Did not get id" end - if id =~ /^\d+$/ - id = Integer(id) - end prefix = "get" + space.to_s if id.is_a?(Integer) if id > Puppet[:maximum_uid].to_i Puppet.err "Tried to get %s field for silly id %s" % [field, id] return nil end - method = (prefix + idfield(space).to_s).intern + method = methodbyid(space) else - method = (prefix + "nam").intern + method = methodbyname(space) end begin @@ -31,13 +30,11 @@ module Puppet::Util::POSIX end # A degenerate method of retrieving name/id mappings. The job of this method is - # to find a specific entry and then return a given field from that entry. - def get_posix_field(type, field, id) + # to retrieve all objects of a certain type, search for a specific entry + # and then return a given field from that entry. + def search_posix_field(type, field, id) idmethod = idfield(type) integer = false - if id =~ /^\d+$/ - id = Integer(id) - end if id.is_a?(Integer) integer = true if id > Puppet[:maximum_uid].to_i @@ -112,14 +109,70 @@ module Puppet::Util::POSIX end end + # Determine what the method is to get users and groups by id + def methodbyid(space) + case Puppet::Util.symbolize(space) + when :gr, :group: return :getgrgid + when :pw, :user, :passwd: return :getpwuid + else + raise ArgumentError.new("Can only handle users and groups") + end + end + + # Determine what the method is to get users and groups by name + def methodbyname(space) + case Puppet::Util.symbolize(space) + when :gr, :group: return :getgrnam + when :pw, :user, :passwd: return :getpwnam + else + raise ArgumentError.new("Can only handle users and groups") + end + end + # Get the GID of a given group, provided either a GID or a name def gid(group) - get_posix_field(:group, :gid, group) + begin + group = Integer(group) + rescue ArgumentError + # pass + end + if group.is_a?(Integer) + name = get_posix_field(:group, :name, group) + gid = get_posix_field(:group, :gid, name) + check_value = gid + else + gid = get_posix_field(:group, :gid, group) + name = get_posix_field(:group, :name, gid) + check_value = name + end + if check_value != group + return search_posix_field(:group, :gid, group) + else + return gid + end end # Get the UID of a given user, whether a UID or name is provided def uid(user) - get_posix_field(:passwd, :uid, user) + begin + user = Integer(user) + rescue ArgumentError + # pass + end + if user.is_a?(Integer) + name = get_posix_field(:passwd, :name, user) + uid = get_posix_field(:passwd, :uid, name) + check_value = uid + else + uid = get_posix_field(:passwd, :uid, user) + name = get_posix_field(:passwd, :name, uid) + check_value = name + end + if check_value != user + return search_posix_field(:passwd, :uid, user) + else + return uid + end end end -- cgit From 0bbac8dda9342b28782ae1218cdb891f5a5bfa54 Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Wed, 30 Jul 2008 22:03:58 +1000 Subject: Fixes #1417 - whitespace in ssh_auth_key provider --- lib/puppet/provider/ssh_authorized_key/parsed.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/puppet/provider/ssh_authorized_key/parsed.rb b/lib/puppet/provider/ssh_authorized_key/parsed.rb index 3bd22c06b..602e6dd1b 100644 --- a/lib/puppet/provider/ssh_authorized_key/parsed.rb +++ b/lib/puppet/provider/ssh_authorized_key/parsed.rb @@ -14,7 +14,7 @@ Puppet::Type.type(:ssh_authorized_key).provide(:parsed, :fields => %w{options type key name}, :optional => %w{options}, :rts => /^\s+/, - :match => /^(?:([^ ]+) )?(ssh-dss|ssh-rsa) ([^ ]+)(?: (.+))?$/, + :match => /^(?:(.+) )?(ssh-dss|ssh-rsa) ([^ ]+)(?: (.+))?$/, :post_parse => proc { |record| if record[:options].nil? record[:options] = [:absent] -- cgit From 5c53617aba31abaa7becd9725155b570fac2a90d Mon Sep 17 00:00:00 2001 From: AJ Christensen Date: Wed, 30 Jul 2008 11:33:18 +1200 Subject: Added a search method to the YAML indirector. This performs a glob on the YAML directory, and instances everything it finds --- lib/puppet/indirector/yaml.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/puppet/indirector/yaml.rb b/lib/puppet/indirector/yaml.rb index 3573ba560..3f05ce618 100644 --- a/lib/puppet/indirector/yaml.rb +++ b/lib/puppet/indirector/yaml.rb @@ -34,11 +34,20 @@ class Puppet::Indirector::Yaml < Puppet::Indirector::Terminus end end + # Get the yaml directory + def base + (Puppet[:name] == "puppetmasterd") ? Puppet[:yamldir] : Puppet[:clientyamldir] + end + # Return the path to a given node's file. def path(name) - base = (Puppet[:name] == "puppetmasterd") ? Puppet[:yamldir] : Puppet[:clientyamldir] File.join(base, self.class.indirection_name.to_s, name.to_s + ".yaml") end + + # Do a glob on the yaml directory, loading each file found + def search(request) + Dir.glob(File.join(base, self.class.indirection_name.to_s, request.key)).collect { |f| YAML.load_file(f) } + end private -- cgit From 13069eca1a3e2b08f5201462021d83e2e0a81018 Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Tue, 29 Jul 2008 15:52:23 +1000 Subject: Ensure that we consistently use either string #{} interpolation or String.% interpolation, not both, to avoid issues where a #{} interpolated value contains a % character. Signed-off-by: Daniel Pittman --- lib/puppet/indirector/facts/facter.rb | 5 +++-- lib/puppet/metatype/metaparams.rb | 3 ++- lib/puppet/network/client/master.rb | 7 ++++--- lib/puppet/reports/rrdgraph.rb | 5 +++-- lib/puppet/transportable.rb | 17 ++++++++++------- lib/puppet/util/ldap/manager.rb | 2 +- 6 files changed, 23 insertions(+), 16 deletions(-) (limited to 'lib') diff --git a/lib/puppet/indirector/facts/facter.rb b/lib/puppet/indirector/facts/facter.rb index 465d90c13..6ed89dac1 100644 --- a/lib/puppet/indirector/facts/facter.rb +++ b/lib/puppet/indirector/facts/facter.rb @@ -12,12 +12,13 @@ class Puppet::Node::Facts::Facter < Puppet::Indirector::Code Dir.entries(dir).find_all { |e| e =~ /\.rb$/ }.each do |file| fqfile = ::File.join(dir, file) begin - Puppet.info "Loading #{type} %s" % ::File.basename(file.sub(".rb",'')) + Puppet.info "Loading %s %s" % + [type, ::File.basename(file.sub(".rb",''))] Timeout::timeout(self.timeout) do load fqfile end rescue => detail - Puppet.warning "Could not load #{type} %s: %s" % [fqfile, detail] + Puppet.warning "Could not load %s %s: %s" % [type, fqfile, detail] end end end diff --git a/lib/puppet/metatype/metaparams.rb b/lib/puppet/metatype/metaparams.rb index edd594114..df96733c2 100644 --- a/lib/puppet/metatype/metaparams.rb +++ b/lib/puppet/metatype/metaparams.rb @@ -258,7 +258,8 @@ class Puppet::Type @value.each do |value| unless @resource.catalog.resource(*value) description = self.class.direction == :in ? "dependency" : "dependent" - fail Puppet::Error, "Could not find #{description} %s[%s] for %s" % [value[0].to_s.capitalize, value[1], resource.ref] + fail Puppet::Error, "Could not find %s %s[%s] for %s" % + [description, value[0].to_s.capitalize, value[1], resource.ref] end end end diff --git a/lib/puppet/network/client/master.rb b/lib/puppet/network/client/master.rb index 2da6cf890..6f8e2770f 100644 --- a/lib/puppet/network/client/master.rb +++ b/lib/puppet/network/client/master.rb @@ -338,7 +338,7 @@ class Puppet::Network::Client::Master < Puppet::Network::Client if Puppet[:debug] puts detail.backtrace end - Puppet.err "Could not retrieve #{args[:name]}s: %s" % detail + Puppet.err "Could not retrieve %ss: %s" % [args[:name], detail] end # Now clean up after ourselves @@ -389,12 +389,13 @@ class Puppet::Network::Client::Master < Puppet::Network::Client Dir.entries(dir).find_all { |e| e =~ /\.rb$/ }.each do |file| fqfile = ::File.join(dir, file) begin - Puppet.info "Loading #{type} %s" % ::File.basename(file.sub(".rb",'')) + Puppet.info "Loading %s %s" % + [type, ::File.basename(file.sub(".rb",''))] Timeout::timeout(self.timeout) do load fqfile end rescue => detail - Puppet.warning "Could not load #{type} %s: %s" % [fqfile, detail] + Puppet.warning "Could not load %s %s: %s" % [type, fqfile, detail] end end end diff --git a/lib/puppet/reports/rrdgraph.rb b/lib/puppet/reports/rrdgraph.rb index 03d8a5bdd..5889750dd 100644 --- a/lib/puppet/reports/rrdgraph.rb +++ b/lib/puppet/reports/rrdgraph.rb @@ -90,8 +90,9 @@ Puppet::Reports.register_report(:rrdgraph) do of.puts "Report graphs for %s" % host files.each do |file| - of.puts "%s
" % - File.basename(file).sub(".html",'').capitalize + of.puts "%s
" % + [File.basename(file), + File.basename(file).sub(".html",'').capitalize] end of.puts "" end diff --git a/lib/puppet/transportable.rb b/lib/puppet/transportable.rb index 3ad084b3b..d203b5928 100644 --- a/lib/puppet/transportable.rb +++ b/lib/puppet/transportable.rb @@ -65,13 +65,16 @@ module Puppet end def to_manifest - "#{self.type.to_s} { \'#{self.name}\':\n%s\n}" % @params.collect { |p, v| - if v.is_a? Array - " #{p} => [\'#{v.join("','")}\']" - else - " #{p} => \'#{v}\'" - end - }.join(",\n") + "%s { '%s':\n%s\n}" % + [self.type.to_s, self.name, + @params.collect { |p, v| + if v.is_a? Array + " #{p} => [\'#{v.join("','")}\']" + else + " #{p} => \'#{v}\'" + end + }.join(",\n") + ] end def to_yaml_properties diff --git a/lib/puppet/util/ldap/manager.rb b/lib/puppet/util/ldap/manager.rb index 9761fc753..8d444195e 100644 --- a/lib/puppet/util/ldap/manager.rb +++ b/lib/puppet/util/ldap/manager.rb @@ -80,7 +80,7 @@ class Puppet::Util::Ldap::Manager # Calculate the dn for a given resource. def dn(name) - ["#{rdn.to_s}=%s" % name, base].join(",") + ["%s=%s" % [rdn, name], base].join(",") end # Convert an ldap-style entry hash to a provider-style hash. -- cgit From 03c76deb60927375e9b35c74a903130930ffddf2 Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Fri, 18 Jul 2008 15:21:57 +1000 Subject: Expose all puppet variables as instance member variables of the template wrapper. This helps resolve redmine #1427, by providing a safe mechanism to access variables. * Implement Puppet::Parser::Scope#to_hash, which returns a hash containing all the variable bindings in the current and, optionally, parent scope. * Use that to set instance member variables into Puppet::Parser::Templatewrapper * Report the time taken for variable binding at debug level, to help identify any performance regression that is encountered in the real world. * Rename the @scope and @file members of the template wrapper, to avoid clashing with a scope variable exposed within puppet. Signed-off-by: Daniel Pittman (cherry picked from commit ba220b41e4f509f2632e2664d332e49b20a70ea7) --- lib/puppet/parser/scope.rb | 19 +++++++++++++ lib/puppet/parser/templatewrapper.rb | 53 +++++++++++++++++++++++++++--------- 2 files changed, 59 insertions(+), 13 deletions(-) (limited to 'lib') diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb index a6e43e7b3..32b127a6b 100644 --- a/lib/puppet/parser/scope.rb +++ b/lib/puppet/parser/scope.rb @@ -183,6 +183,25 @@ class Puppet::Parser::Scope end end + # Return a hash containing our variables and their values, optionally (and + # by default) including the values defined in our parent. Local values + # shadow parent values. + def to_hash(recursive = true) + if recursive and parent then + target = parent.to_hash(recursive) + end + target ||= Hash.new + @symtable.keys.each { |name| + value = @symtable[name] + if value == :undef then + target.delete(name) + else + target[name] = value + end + } + return target + end + def namespaces @namespaces.dup end diff --git a/lib/puppet/parser/templatewrapper.rb b/lib/puppet/parser/templatewrapper.rb index 4790cea30..298428f63 100644 --- a/lib/puppet/parser/templatewrapper.rb +++ b/lib/puppet/parser/templatewrapper.rb @@ -5,36 +5,63 @@ class Puppet::Parser::TemplateWrapper include Puppet::Util Puppet::Util.logmethods(self) - def initialize(scope, file) - @scope = scope - @file = Puppet::Module::find_template(file, @scope.compiler.environment) + def initialize(scope, filename) + @__scope__ = scope + @__file__ = Puppet::Module::find_template(filename, scope.compiler.environment) - unless FileTest.exists?(@file) + unless FileTest.exists?(file) raise Puppet::ParseError, "Could not find template %s" % file end # We'll only ever not have a parser in testing, but, eh. - if @scope.parser - @scope.parser.watch_file(@file) + if scope.parser + scope.parser.watch_file(file) end + + # Expose all the variables in our scope as instance variables of the + # current object, making it possible to access them without conflict + # to the regular methods. + benchmark(:debug, "Bound template variables for #{file}") do + scope.to_hash.each { |name, value| + instance_variable_set("@#{name}", value) + } + end + end + + def scope + @__scope__ + end + + def file + @__file__ end # Should return true if a variable is defined, false if it is not def has_variable?(name) - if @scope.lookupvar(name.to_s, false) != :undefined + if scope.lookupvar(name.to_s, false) != :undefined true else false end end - # Ruby treats variables like methods, so we can cheat here and - # trap missing vars like they were missing methods. + # Ruby treats variables like methods, so we used to expose variables + # within scope to the ERB code via method_missing. As per RedMine #1427, + # though, this means that conflicts between methods in our inheritance + # tree (Kernel#fork) and variable names (fork => "yes/no") could arise. + # + # Worse, /new/ conflicts could pop up when a new kernel or object method + # was added to Ruby, causing templates to suddenly fail mysteriously when + # Ruby was upgraded. + # + # To ensure that legacy templates using unqualified names work we retain + # the missing_method definition here until we declare the syntax finally + # dead. def method_missing(name, *args) # We have to tell lookupvar to return :undefined to us when # appropriate; otherwise it converts to "". - value = @scope.lookupvar(name.to_s, false) + value = scope.lookupvar(name.to_s, false) if value != :undefined return value else @@ -47,8 +74,8 @@ class Puppet::Parser::TemplateWrapper def result result = nil - benchmark(:debug, "Interpolated template #{@file}") do - template = ERB.new(File.read(@file), 0, "-") + benchmark(:debug, "Interpolated template #{file}") do + template = ERB.new(File.read(file), 0, "-") result = template.result(binding) end @@ -56,7 +83,7 @@ class Puppet::Parser::TemplateWrapper end def to_s - "template[%s]" % @file + "template[%s]" % file end end -- cgit From 6a2e71dd5fe16abaa64a92255a1bc8b592d2500f Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Fri, 1 Aug 2008 09:04:23 +1000 Subject: Fixed #1441 - Updated console colours --- lib/puppet/util/log.rb | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'lib') diff --git a/lib/puppet/util/log.rb b/lib/puppet/util/log.rb index 22f4f3233..8824a8b50 100644 --- a/lib/puppet/util/log.rb +++ b/lib/puppet/util/log.rb @@ -244,23 +244,31 @@ class Puppet::Util::Log newdesttype :console do - PINK = {:console => "", :html => "FFA0A0"} - GREEN = {:console => "", :html => "00CD00"} - YELLOW = {:console => "", :html => "FFFF60"} - SLATE = {:console => "", :html => "80A0FF"} - ORANGE = {:console => "", :html => "FFA500"} - BLUE = {:console => "", :html => "40FFFF"} - RESET = {:console => "", :html => ""} + RED = {:console => "", :html => "FFA0A0"} + GREEN = {:console => "", :html => "00CD00"} + YELLOW = {:console => "", :html => "FFFF60"} + BLUE = {:console => "", :html => "80A0FF"} + PURPLE = {:console => "", :html => "FFA500"} + CYAN = {:console => "", :html => "40FFFF"} + WHITE = {:console => "", :html => "FFFFFF"} + HRED = {:console => "", :html => "FFA0A0"} + HGREEN = {:console => "", :html => "00CD00"} + HYELLOW = {:console => "", :html => "FFFF60"} + HBLUE = {:console => "", :html => "80A0FF"} + HPURPLE = {:console => "", :html => "FFA500"} + HCYAN = {:console => "", :html => "40FFFF"} + HWHITE = {:console => "", :html => "FFFFFF"} + RESET = {:console => "", :html => ""} @@colormap = { - :debug => SLATE, + :debug => WHITE, :info => GREEN, - :notice => PINK, - :warning => ORANGE, - :err => YELLOW, - :alert => BLUE, - :emerg => RESET, - :crit => RESET + :notice => CYAN, + :warning => YELLOW, + :err => HPURPLE, + :alert => RED, + :emerg => HRED, + :crit => HRED } def colorize(level, str) -- cgit From 014757047f23b85bb0e35d7a0c79efcec9178077 Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Wed, 6 Aug 2008 05:26:27 +1000 Subject: Fixed #1457 - removed confine warning --- lib/puppet/provider/confine.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/puppet/provider/confine.rb b/lib/puppet/provider/confine.rb index 35b80fdcf..e15adcd0e 100644 --- a/lib/puppet/provider/confine.rb +++ b/lib/puppet/provider/confine.rb @@ -25,7 +25,7 @@ class Puppet::Provider::Confine begin require "puppet/provider/confine/%s" % name rescue LoadError => detail - unless detail.to_s.include?("no such file") + unless detail.to_s.include?("No such file") warn "Could not load confine test '%s': %s" % [name, detail] end # Could not find file -- cgit From 8a0cb16abd4c6a9cbf27d88593aa2b42a7375b94 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Thu, 7 Aug 2008 18:53:02 -0700 Subject: Added tests for TemplateWrapper's use of Scope#to_hash. We should deprecate the method_missing stuff in 0.25. Signed-off-by: Luke Kanies --- lib/puppet/parser/templatewrapper.rb | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'lib') diff --git a/lib/puppet/parser/templatewrapper.rb b/lib/puppet/parser/templatewrapper.rb index 298428f63..3b74e62d4 100644 --- a/lib/puppet/parser/templatewrapper.rb +++ b/lib/puppet/parser/templatewrapper.rb @@ -18,15 +18,6 @@ class Puppet::Parser::TemplateWrapper if scope.parser scope.parser.watch_file(file) end - - # Expose all the variables in our scope as instance variables of the - # current object, making it possible to access them without conflict - # to the regular methods. - benchmark(:debug, "Bound template variables for #{file}") do - scope.to_hash.each { |name, value| - instance_variable_set("@#{name}", value) - } - end end def scope @@ -67,12 +58,20 @@ class Puppet::Parser::TemplateWrapper else # Just throw an error immediately, instead of searching for # other missingmethod things or whatever. - raise Puppet::ParseError, - "Could not find value for '%s'" % name + raise Puppet::ParseError, "Could not find value for '%s'" % name end end def result + # Expose all the variables in our scope as instance variables of the + # current object, making it possible to access them without conflict + # to the regular methods. + benchmark(:debug, "Bound template variables for #{file}") do + scope.to_hash.each { |name, value| + instance_variable_set("@#{name}", value) + } + end + result = nil benchmark(:debug, "Interpolated template #{file}") do template = ERB.new(File.read(file), 0, "-") -- cgit From ab4cb6a6acaa6f045bdceb93eb105617d42b23b2 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Tue, 12 Aug 2008 13:24:35 -0500 Subject: Fixing #1447 -- Replacing Puppet::PackageError with Puppet::Error. Signed-off-by: Luke Kanies --- lib/puppet/provider/package/dpkg.rb | 2 +- lib/puppet/provider/package/ports.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/puppet/provider/package/dpkg.rb b/lib/puppet/provider/package/dpkg.rb index b67cd2b76..ae79f714c 100755 --- a/lib/puppet/provider/package/dpkg.rb +++ b/lib/puppet/provider/package/dpkg.rb @@ -121,7 +121,7 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package end if hash[:error] != "ok" - raise Puppet::PackageError.new( + raise Puppet::Error.new( "Package %s, version %s is in error state: %s" % [hash[:name], hash[:ensure], hash[:error]] ) diff --git a/lib/puppet/provider/package/ports.rb b/lib/puppet/provider/package/ports.rb index 99e26ef23..96ef3f042 100755 --- a/lib/puppet/provider/package/ports.rb +++ b/lib/puppet/provider/package/ports.rb @@ -33,7 +33,7 @@ Puppet::Type.type(:package).provide :ports, :parent => :freebsd, :source => :fre begin output = portversion(*cmd) rescue Puppet::ExecutionFailure - raise Puppet::PackageError.new(output) + raise Puppet::Error.new(output) end line = output.split("\n").pop @@ -47,7 +47,7 @@ Puppet::Type.type(:package).provide :ports, :parent => :freebsd, :source => :fre info = $3 unless pkgstuff =~ /^(\S+)-([^-\s]+)$/ - raise Puppet::PackageError, + raise Puppet::Error, "Could not match package info '%s'" % pkgstuff end @@ -61,7 +61,7 @@ Puppet::Type.type(:package).provide :ports, :parent => :freebsd, :source => :fre # Else, we need to be updated; we need to pull out the new version unless info =~ /\((\w+) has (.+)\)/ - raise Puppet::PackageError, + raise Puppet::Error, "Could not match version info '%s'" % info end -- cgit From 18dda20b4167cb24ecd0d8b2029aaabb60b79936 Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Wed, 13 Aug 2008 10:06:28 +1000 Subject: Fixed $1456 - add proxy configuration to yum repo --- lib/puppet/type/yumrepo.rb | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/puppet/type/yumrepo.rb b/lib/puppet/type/yumrepo.rb index d19b5a470..15e031945 100644 --- a/lib/puppet/type/yumrepo.rb +++ b/lib/puppet/type/yumrepo.rb @@ -346,7 +346,23 @@ module Puppet newvalue(%r{[1-9][0-9]?}) { } end - - + newproperty(:proxy, :parent => Puppet::IniProperty) do + desc "URL to the proxy server for this repository.\n#{ABSENT_DOC}" + newvalue(:absent) { self.should = :absent } + # Should really check that it's a valid URL + newvalue(/.*/) { } + end + + newproperty(:proxy_username, :parent => Puppet::IniProperty) do + desc "Username for this proxy.\n#{ABSENT_DOC}" + newvalue(:absent) { self.should = :absent } + newvalue(/.*/) { } + end + + newproperty(:proxy_password, :parent => Puppet::IniProperty) do + desc "Password for this proxy.\n#{ABSENT_DOC}" + newvalue(:absent) { self.should = :absent } + newvalue(/.*/) { } + end end end -- cgit From fb8cc533ad1da65de0b4769ab3b44112c9ff68c6 Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Sat, 16 Aug 2008 02:01:41 +1000 Subject: Fixed #1442 - replaced use of Facter for report titling with certname --- lib/puppet/transaction/report.rb | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/puppet/transaction/report.rb b/lib/puppet/transaction/report.rb index bd62ebbe6..89da7ed9c 100644 --- a/lib/puppet/transaction/report.rb +++ b/lib/puppet/transaction/report.rb @@ -25,13 +25,7 @@ class Puppet::Transaction::Report hash[key] = [] end - domain = Facter.value("domain") - hostname = Facter.value("hostname") - if !domain || domain.empty? then - @host = hostname - else - @host = [hostname, domain].join(".") - end + @host = Puppet[:certname] end def name -- cgit From 6676b6b104e3f60dd14be18cbfb91b4cd96ec06e Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Thu, 14 Aug 2008 00:32:30 +1000 Subject: Fixes #1274 - allow class names to start with numbers --- lib/puppet/parser/lexer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/puppet/parser/lexer.rb b/lib/puppet/parser/lexer.rb index 51026ea1b..2c5f66e5a 100644 --- a/lib/puppet/parser/lexer.rb +++ b/lib/puppet/parser/lexer.rb @@ -131,7 +131,7 @@ class Puppet::Parser::Lexer TOKENS.add_tokens "Whatever" => :DQTEXT, "Nomatter" => :SQTEXT, "alsonomatter" => :BOOLEAN - TOKENS.add_token :NAME, %r{[a-z][-\w]*} do |lexer, value| + TOKENS.add_token :NAME, %r{[a-z0-9][-\w]*} do |lexer, value| string_token = self # we're looking for keywords here if tmp = KEYWORDS.lookup(value) -- cgit From f48a0ae140661dc14934c0a192c71687929b0624 Mon Sep 17 00:00:00 2001 From: Brice Figureau Date: Wed, 13 Aug 2008 17:02:35 +0200 Subject: Fix #1510 - storeconfig fails with rails 2.1 This is a workaround. Since rails seems to have difficulties to map associations to Puppet classes, we explain it carefully what to expect. Changelog --- lib/puppet/rails/resource.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/puppet/rails/resource.rb b/lib/puppet/rails/resource.rb index 0053dc28d..eabc873df 100644 --- a/lib/puppet/rails/resource.rb +++ b/lib/puppet/rails/resource.rb @@ -6,12 +6,12 @@ require 'puppet/util/rails/collection_merger' class Puppet::Rails::Resource < ActiveRecord::Base include Puppet::Util::CollectionMerger - has_many :param_values, :dependent => :destroy - has_many :param_names, :through => :param_values + has_many :param_values, :dependent => :destroy, :class_name => "Puppet::Rails::ParamValue" + has_many :param_names, :through => :param_values, :class_name => "Puppet::Rails::ParamName" + + has_many :resource_tags, :dependent => :destroy, :class_name => "Puppet::Rails::ResourceTag" + has_many :puppet_tags, :through => :resource_tags, :class_name => "Puppet::Rails::PuppetTag" - has_many :resource_tags, :dependent => :destroy - has_many :puppet_tags, :through => :resource_tags - belongs_to :source_file belongs_to :host -- cgit From 9272df437c3cee6070f4e765bf61511cd85cb3a7 Mon Sep 17 00:00:00 2001 From: Brice Figureau Date: Mon, 11 Aug 2008 10:49:20 +0200 Subject: Fix #1052 - abysmal storeconfig performance - part1 Resources whose references are of the form: Main::Sub1::Sub2 are extracted from the database under the form: Main::sub1::sub2 Puppet then fails to match them against compiled resources of same references which are capitalized as they should, and tries to overwrite them on every storeconfig run, leading to tons of cascading DELETE/INSERT, hurting performance. Signed-off-by: Brice Figureau --- lib/puppet/rails/resource.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/puppet/rails/resource.rb b/lib/puppet/rails/resource.rb index eabc873df..255b0e788 100644 --- a/lib/puppet/rails/resource.rb +++ b/lib/puppet/rails/resource.rb @@ -82,7 +82,7 @@ class Puppet::Rails::Resource < ActiveRecord::Base end def ref - "%s[%s]" % [self[:restype].capitalize, self[:title]] + "%s[%s]" % [self[:restype].split("::").collect { |s| s.capitalize }.join("::"), self[:title]] end # Convert our object to a resource. Do not retain whether the object -- cgit From 2ec4e298c3274abc8eaad4230bca8d39a48d2e35 Mon Sep 17 00:00:00 2001 From: Brice Figureau Date: Mon, 11 Aug 2008 10:52:50 +0200 Subject: Fix #1502 - abysmal storeconfig performance - part2 Resource parameters whose values are a resource reference (ie require, notify...) where always DELETEd/INSERTed because the code comparing resource reference compared object instances instead of their values (since Puppet::Parser::Resource::Reference doesn't override == ), leading to storeconfig performance issues. The correct fix would have been to define == in Puppet::Parser::Resource::Reference but that might introduce some side effects I don't know. Hence, the fix introduces a local compare() method that knows how to compare Puppet::Parser::Resource::Reference. Signed-off-by: Brice Figureau --- lib/puppet/parser/resource/param.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/puppet/parser/resource/param.rb b/lib/puppet/parser/resource/param.rb index 9dd3f26d2..c8dd78a26 100644 --- a/lib/puppet/parser/resource/param.rb +++ b/lib/puppet/parser/resource/param.rb @@ -66,6 +66,14 @@ class Puppet::Parser::Resource::Param def to_s "%s => %s" % [self.name, self.value] end + + def compare(v,db_value) + if (v.is_a?(Puppet::Parser::Resource::Reference)) + return v.to_s == db_value.to_s + else + return v == db_value + end + end def values_to_remove(db_values) values = munge_for_rails(value) @@ -73,7 +81,7 @@ class Puppet::Parser::Resource::Param db_values.collect do |db| db unless (db.line == line_number && values.find { |v| - v == db.value + compare(v,db.value) } ) end.compact end @@ -82,7 +90,7 @@ class Puppet::Parser::Resource::Param values = munge_for_rails(value) line_number = line_to_i() values.collect do |v| - v unless db_values.find { |db| (v == db.value && + v unless db_values.find { |db| (compare(v,db.value) && line_number == db.line) } end.compact end -- cgit