Please review pull request #775: Set node_terminus in device application opened by (pcarlisle)

Description:

This was set in the agent application so that an ENC can be properly used, but
not in device. I also refactored these settings slightly to use the new
app_defaults method.

  • Opened: Mon May 14 20:34:00 UTC 2012
  • Based on: puppetlabs:master (34ad902015afbd3f8d7597207a1cb4d5cd4cc011)
  • Requested merge: pcarlisle:maint/master/network-device-node_terminus (83a7b803322f2b3ab824f5fbf7152c5de8d553ae)

Diff follows:

diff --git a/lib/puppet/application/agent.rb b/lib/puppet/application/agent.rb
index 857a554..5a7a311 100644
--- a/lib/puppet/application/agent.rb
+++ b/lib/puppet/application/agent.rb
@@ -6,6 +6,14 @@ class Puppet::Application::Agent < Puppet::Application
 
   attr_accessor :args, :agent, :daemon, :host
 
+  def app_defaults
+    super.merge({
+      :catalog_terminus => :rest,
+      :node_terminus => :rest,
+      :facts_terminus => :facter,
+    })
+  end
+
   def preinit
     # Do an initial trap, so that cancels don't get a stack trace.
     Signal.trap(:INT) do
@@ -450,14 +458,6 @@ def setup
     # we want the last report to be persisted locally
     Puppet::Transaction::Report.indirection.cache_class = :yaml
 
-    # Override the default; puppet agent needs this, usually.
-    # You can still override this on the command-line with, e.g., :compiler.
-    Puppet[:catalog_terminus] = :rest
-    Puppet[:node_terminus] = :rest
-
-    # Override the default.
-    Puppet[:facts_terminus] = :facter
-
     Puppet::Resource::Catalog.indirection.cache_class = :yaml
 
     unless options[:fingerprint]
diff --git a/lib/puppet/application/device.rb b/lib/puppet/application/device.rb
index 1361b36..7e87c2e 100644
--- a/lib/puppet/application/device.rb
+++ b/lib/puppet/application/device.rb
@@ -8,6 +8,14 @@ class Puppet::Application::Device < Puppet::Application
 
   attr_accessor :args, :agent, :host
 
+  def app_defaults
+    super.merge({
+      :catalog_terminus => :rest,
+      :node_terminus => :rest,
+      :facts_terminus => :network_device,
+    })
+  end
+
   def preinit
     # Do an initial trap, so that cancels don't get a stack trace.
     Signal.trap(:INT) do
@@ -228,12 +236,6 @@ def setup
 
     Puppet::Transaction::Report.indirection.terminus_class = :rest
 
-    # Override the default; the agent needs this, usually.
-    # You can still override this on the command-line with, e.g., :compiler.
-    Puppet[:catalog_terminus] = :rest
-
-    Puppet[:facts_terminus] = :network_device
-
     Puppet::Resource::Catalog.indirection.cache_class = :yaml
   end
 end
diff --git a/spec/unit/application/agent_spec.rb b/spec/unit/application/agent_spec.rb
index 60061b3..746cf33 100755
--- a/spec/unit/application/agent_spec.rb
+++ b/spec/unit/application/agent_spec.rb
@@ -327,22 +327,24 @@
       @puppetd.setup
     end
 
-    it "should change the catalog_terminus setting to 'rest'" do
-      Puppet[:catalog_terminus] = :foo
-      @puppetd.setup
+    it "should default catalog_terminus setting to 'rest'" do
+      @puppetd.initialize_app_defaults
       Puppet[:catalog_terminus].should ==  :rest
     end
 
+    it "should default node_terminus setting to 'rest'" do
+      @puppetd.initialize_app_defaults
+      Puppet[:node_terminus].should ==  :rest
+    end
+
     it "should tell the catalog handler to use cache" do
       Puppet::Resource::Catalog.indirection.expects(:cache_class=).with(:yaml)
 
       @puppetd.setup
     end
 
-    it "should change the facts_terminus setting to 'facter'" do
-      Puppet[:facts_terminus] = :foo
-
-      @puppetd.setup
+    it "should default facts_terminus setting to 'facter'" do
+      @puppetd.initialize_app_defaults
       Puppet[:facts_terminus].should == :facter
     end
 
diff --git a/spec/unit/application/device_spec.rb b/spec/unit/application/device_spec.rb
index 76856d7..0fa90d5 100755
--- a/spec/unit/application/device_spec.rb
+++ b/spec/unit/application/device_spec.rb
@@ -209,22 +209,24 @@
       @device.setup
     end
 
-    it "should change the catalog_terminus setting to 'rest'" do
-      Puppet[:catalog_terminus] = :foo
-      @device.setup
+    it "should default the catalog_terminus setting to 'rest'" do
+      @device.initialize_app_defaults
       Puppet[:catalog_terminus].should ==  :rest
     end
 
+    it "should default the node_terminus setting to 'rest'" do
+      @device.initialize_app_defaults
+      Puppet[:node_terminus].should ==  :rest
+    end
+
     it "should tell the catalog handler to use cache" do
       Puppet::Resource::Catalog.indirection.expects(:cache_class=).with(:yaml)
 
       @device.setup
     end
 
-    it "should change the facts_terminus setting to 'network_device'" do
-      Puppet[:facts_terminus] = :foo
-
-      @device.setup
+    it "should default the facts_terminus setting to 'network_device'" do
+      @device.initialize_app_defaults
       Puppet[:facts_terminus].should == :network_device
     end
   end

    

--
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