+1

On Aug 3, 2009, at 10:15 AM, Nigel Kersten wrote:

>
>
> Signed-off-by: Nigel Kersten <[email protected]>
> ---
> lib/puppet/defaults.rb               |   17 +++++++++++++++--
> lib/puppet/indirector/report/rest.rb |    2 ++
> lib/puppet/util/log.rb               |    2 +-
> spec/integration/defaults.rb         |   29 +++++++++++++++++++++++++ 
> ++++
> spec/unit/indirector/report/rest.rb  |   19 ++++++++++++++++++-
> 5 files changed, 65 insertions(+), 4 deletions(-)
> mode change 100644 => 100755 spec/unit/indirector/report/rest.rb
>
> diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb
> index b1fddc3..c45cf82 100644
> --- a/lib/puppet/defaults.rb
> +++ b/lib/puppet/defaults.rb
> @@ -542,8 +542,21 @@ module Puppet
>             before considering it a failure.  This can help reduce  
> flapping if too
>             many clients contact the server at one time."
>         ],
> -        :reportserver => ["$server",
> -            "The server to which to send transaction reports."
> +        :reportserver => {
> +            :default => "$server",
> +            :call_on_define => false,
> +            :desc => "(Deprecated for 'report_server') The server  
> to which to send transaction reports.",
> +            :hook => proc do |value|
> +              if value
> +                Puppet.settings[:report_server] = value
> +              end
> +            end
> +        },
> +        :report_server => ["$server",
> +          "The server to which to send transaction reports."
> +        ],
> +        :report_port => ["$masterport",
> +          "The port to communicate with the report_server."
>         ],
>         :report => [false,
>             "Whether to send reports after every transaction."
> diff --git a/lib/puppet/indirector/report/rest.rb b/lib/puppet/ 
> indirector/report/rest.rb
> index 905b71a..f92d1ed 100644
> --- a/lib/puppet/indirector/report/rest.rb
> +++ b/lib/puppet/indirector/report/rest.rb
> @@ -2,4 +2,6 @@ require 'puppet/indirector/rest'
>
> class Puppet::Transaction::Report::Rest < Puppet::Indirector::REST
>     desc "Get server report over HTTP via REST."
> +    use_server_setting(:report_server)
> +    use_port_setting(:report_port)
> end
> diff --git a/lib/puppet/util/log.rb b/lib/puppet/util/log.rb
> index 6edc7f4..305bd2f 100644
> --- a/lib/puppet/util/log.rb
> +++ b/lib/puppet/util/log.rb
> @@ -514,7 +514,7 @@ class Puppet::Util::Log
>         # We can't store the actual source, we just store the path.
>         # We can't just check for whether it responds to :path,  
> because
>         # plenty of providers respond to that in their normal  
> function.
> -        if (source.is_a?(Puppet::Type) or source.is_a? 
> (Puppet::Parameter)) and source.respond_to?(:path)
> +        if defined?(Puppet::Type) and (source.is_a?(Puppet::Type)  
> or source.is_a?(Puppet::Parameter)) and source.respond_to?(:path)
>             @source = source.path
>         else
>             @source = source.to_s
> diff --git a/spec/integration/defaults.rb b/spec/integration/ 
> defaults.rb
> index b2e5a82..38a4e16 100755
> --- a/spec/integration/defaults.rb
> +++ b/spec/integration/defaults.rb
> @@ -157,4 +157,33 @@ describe "Puppet defaults" do
>     it "should have a setting for determining the configuration  
> version and should default to an empty string" do
>         Puppet.settings[:config_version].should == ""
>     end
> +
> +    describe "when enabling reports" do
> +        it "should use the default server value when report server  
> is unspecified" do
> +            Puppet.settings[:server] = "server"
> +            Puppet.settings[:report_server].should == "server"
> +        end
> +
> +        it "should use the default masterport value when report  
> port is unspecified" do
> +            Puppet.settings[:masterport] = "1234"
> +            Puppet.settings[:report_port].should == "1234"
> +        end
> +
> +        it "should set report_server when reportserver is set" do
> +            Puppet.settings[:reportserver] = "reportserver"
> +            Puppet.settings[:report_server].should == "reportserver"
> +        end
> +
> +        it "should use report_port when set" do
> +            Puppet.settings[:masterport] = "1234"
> +            Puppet.settings[:report_port] = "5678"
> +            Puppet.settings[:report_port].should == "5678"
> +        end
> +
> +        it "should prefer report_server over reportserver" do
> +            Puppet.settings[:reportserver] = "reportserver"
> +            Puppet.settings[:report_server] = "report_server"
> +            Puppet.settings[:report_server].should == "report_server"
> +        end
> +    end
> end
> diff --git a/spec/unit/indirector/report/rest.rb b/spec/unit/ 
> indirector/report/rest.rb
> old mode 100644
> new mode 100755
> index a51ebca..1f71eb3
> --- a/spec/unit/indirector/report/rest.rb
> +++ b/spec/unit/indirector/report/rest.rb
> @@ -5,7 +5,24 @@ require File.dirname(__FILE__) + '/../../../ 
> spec_helper'
> require 'puppet/indirector/report/rest'
>
> describe Puppet::Transaction::Report::Rest do
> -    it "should be a sublcass of Puppet::Indirector::REST" do
> +    it "should be a subclass of Puppet::Indirector::REST" do
>         Puppet::Transaction::Report::Rest.superclass.should  
> equal(Puppet::Indirector::REST)
>     end
> +
> +    it "should use the :report_server setting in preference  
> to :reportserver" do
> +        Puppet.settings[:reportserver] = "reportserver"
> +        Puppet.settings[:report_server] = "report_server"
> +        Puppet::Transaction::Report::Rest.server.should ==  
> "report_server"
> +    end
> +
> +    it "should use the :report_server setting in preference  
> to :server" do
> +        Puppet.settings[:server] = "server"
> +        Puppet.settings[:report_server] = "report_server"
> +        Puppet::Transaction::Report::Rest.server.should ==  
> "report_server"
> +    end
> +
> +    it "should have a value for report_server and report_port" do
> +        Puppet::Transaction::Report::Rest.server.should_not be_nil
> +        Puppet::Transaction::Report::Rest.port.should_not be_nil
> +    end
> end
> -- 
> 1.6.3.3
>
>
> >


-- 
Today at work an ethernet switch decided to take the 'N' out of NVRAM
     -- Richard Letts
---------------------------------------------------------------------
Luke Kanies | http://reductivelabs.com | http://madstop.com


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to