diff options
author | Luke Kanies <luke@madstop.com> | 2005-08-17 19:04:37 +0000 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2005-08-17 19:04:37 +0000 |
commit | f02688442098f68016022289e7cf504732c872ba (patch) | |
tree | 69aeab760fb2511e10cbe0c19c9fd138e1030532 /lib/puppet | |
parent | 78939cc0ae05e21887f3a297dc5cd718f9cb5502 (diff) | |
download | puppet-f02688442098f68016022289e7cf504732c872ba.tar.gz puppet-f02688442098f68016022289e7cf504732c872ba.tar.xz puppet-f02688442098f68016022289e7cf504732c872ba.zip |
just fixed an incredibly ugly bug where @parent meant both parent array and parent class
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@559 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/client.rb | 57 | ||||
-rw-r--r-- | lib/puppet/transportable.rb | 6 |
2 files changed, 45 insertions, 18 deletions
diff --git a/lib/puppet/client.rb b/lib/puppet/client.rb index 4b2c57232..6f9b21cbf 100644 --- a/lib/puppet/client.rb +++ b/lib/puppet/client.rb @@ -138,6 +138,12 @@ module Puppet self.fqdn end + if hash.include?(:Cache) + @cache = hash[:Cache] + else + @cache = true + end + if hash.include?(:Server) case hash[:Server] when String: @@ -188,27 +194,46 @@ module Puppet objects = nil if @local objects = @driver.getconfig(facts) + + if objects == "" + raise Puppet::Error, "Could not retrieve configuration" + end else textfacts = CGI.escape(Marshal::dump(facts)) - textobjects = nil - if textobjects = CGI.unescape(@driver.getconfig(textfacts)) - # we store the config so that if we can't connect next time, we - # can just run against the most recently acquired copy - confdir = File.dirname(Puppet[:localconfig]) - unless FileTest.exists?(confdir) - Puppet.recmkdir(confdir, 0770) + + # error handling for this is done in the network client + textobjects = @driver.getconfig(textfacts) + + unless textobjects == "" + begin + textobjects = CGI.unescape(textobjects) + rescue => detail + raise Puppet::Error, "Could not CGI.unescape configuration" end - File.open(Puppet[:localconfig], "w", 0660) { |f| - f.print textobjects - } - else - if FileTest.exists?(Puppet[:localconfig]) - textobjects = File.read(Puppet[:localconfig]) + end + + if @cache + if textobjects == "" + if FileTest.exists?(Puppet[:localconfig]) + textobjects = File.read(Puppet[:localconfig]) + else + raise Puppet::Error.new( + "Cannot connect to server and there is no cached configuration" + ) + end else - raise Puppet::Error.new( - "Cannot connect to server and there is no cached configuration" - ) + # we store the config so that if we can't connect next time, we + # can just run against the most recently acquired copy + confdir = File.dirname(Puppet[:localconfig]) + unless FileTest.exists?(confdir) + Puppet.recmkdir(confdir, 0770) + end + File.open(Puppet[:localconfig], "w", 0660) { |f| + f.print textobjects + } end + elsif textobjects == "" + raise Puppet::Error, "Could not retrieve configuration" end begin diff --git a/lib/puppet/transportable.rb b/lib/puppet/transportable.rb index ebabf3a27..cf4a4629c 100644 --- a/lib/puppet/transportable.rb +++ b/lib/puppet/transportable.rb @@ -7,7 +7,7 @@ require 'puppet' module Puppet #------------------------------------------------------------ class TransObject < Hash - attr_accessor :type, :name + attr_accessor :type, :name, :file, :line @@ohash = {} @@oarray = [] @@ -53,6 +53,8 @@ module Puppet retobj = nil if type = Puppet::Type.type(self.type) retobj = type.new(self) + retobj.file = @file + retobj.line = @line else raise Puppet::Error.new("Could not find object type %s" % self.type) end @@ -65,7 +67,7 @@ module Puppet #------------------------------------------------------------ # just a linear container for objects class TransBucket < Array - attr_accessor :name, :type + attr_accessor :name, :type, :file, :line def push(*args) args.each { |arg| |