summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-10-05 14:25:29 -0500
committerLuke Kanies <luke@madstop.com>2007-10-05 14:25:29 -0500
commitf084d83df1abf51766e2dd390e118f1189864346 (patch)
treecbff216064768461dac362abab515c3f1ba6e349 /lib
parent9c58c476c2ffcf9613f14e5881b1177f01d413a7 (diff)
downloadpuppet-f084d83df1abf51766e2dd390e118f1189864346.tar.gz
puppet-f084d83df1abf51766e2dd390e118f1189864346.tar.xz
puppet-f084d83df1abf51766e2dd390e118f1189864346.zip
Another round of test-fixing around the changes I made
to the configuration system. 'puppet' itself still works, even with -e, but I expect that puppetd and puppetmasterd are broken, and there are still quite a few broken tests because the default fact store can't write but that's the default behaviour for a networked configuration master.
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/dsl.rb11
-rw-r--r--lib/puppet/network/client/master.rb1
-rw-r--r--lib/puppet/network/handler/configuration.rb45
-rw-r--r--lib/puppet/network/handler/master.rb15
4 files changed, 23 insertions, 49 deletions
diff --git a/lib/puppet/dsl.rb b/lib/puppet/dsl.rb
index 75bc81b2b..97d06a4ec 100644
--- a/lib/puppet/dsl.rb
+++ b/lib/puppet/dsl.rb
@@ -251,12 +251,17 @@ module Puppet
def scope
unless defined?(@scope)
- @interp = Puppet::Parser::Interpreter.new :Code => ""
+ # Set the code to something innocuous; we just need the
+ # scopes, not the interpreter. Hackish, but true.
+ Puppet[:code] = " "
+ @interp = Puppet::Parser::Interpreter.new
require 'puppet/node'
@node = Puppet::Node.new(Facter.value(:hostname))
+ if env = Puppet[:environment] and env == ""
+ env = nil
+ end
@node.parameters = Facter.to_hash
- @interp = Puppet::Parser::Interpreter.new :Code => ""
- @compile = Puppet::Parser::Compile.new(@node, @interp.send(:parser, Puppet[:environment]))
+ @compile = Puppet::Parser::Compile.new(@node, @interp.send(:parser, env))
@scope = @compile.topscope
end
@scope
diff --git a/lib/puppet/network/client/master.rb b/lib/puppet/network/client/master.rb
index 989d6dca2..5408cabe4 100644
--- a/lib/puppet/network/client/master.rb
+++ b/lib/puppet/network/client/master.rb
@@ -266,6 +266,7 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
self.getconfig
end
rescue => detail
+ puts detail.backtrace if Puppet[:trace]
Puppet.err "Could not retrieve configuration: %s" % detail
end
diff --git a/lib/puppet/network/handler/configuration.rb b/lib/puppet/network/handler/configuration.rb
index 353693bdc..09c4b971a 100644
--- a/lib/puppet/network/handler/configuration.rb
+++ b/lib/puppet/network/handler/configuration.rb
@@ -49,10 +49,14 @@ class Puppet::Network::Handler
@local = false
end
- # Just store the options, rather than creating the interpreter
- # immediately. Mostly, this is so we can create the interpreter
- # on-demand, which is easier for testing.
- @options = options
+ options.each do |param, value|
+ case param
+ when :Classes: @classes = value
+ when :Local: self.local = true
+ else
+ raise ArgumentError, "Configuration handler does not accept %s" % param
+ end
+ end
set_server_facts
end
@@ -82,8 +86,8 @@ class Puppet::Network::Handler
node.merge(@server_facts)
# Add any specified classes to the node's class list.
- if classes = @options[:Classes]
- classes.each do |klass|
+ if @classes
+ @classes.each do |klass|
node.classes << klass
end
end
@@ -121,37 +125,14 @@ class Puppet::Network::Handler
end
# Create our interpreter object.
- def create_interpreter(options)
- args = {}
-
- # Allow specification of a code snippet or of a file
- if code = options[:Code]
- args[:Code] = code
- elsif options[:Manifest]
- args[:Manifest] = options[:Manifest]
- end
-
- args[:Local] = local?
-
- if options.include?(:UseNodes)
- args[:UseNodes] = options[:UseNodes]
- elsif @local
- args[:UseNodes] = false
- end
-
- # This is only used by the cfengine module, or if --loadclasses was
- # specified in +puppet+.
- if options.include?(:Classes)
- args[:Classes] = options[:Classes]
- end
-
- return Puppet::Parser::Interpreter.new(args)
+ def create_interpreter
+ return Puppet::Parser::Interpreter.new
end
# Create/return our interpreter.
def interpreter
unless defined?(@interpreter) and @interpreter
- @interpreter = create_interpreter(@options)
+ @interpreter = create_interpreter
end
@interpreter
end
diff --git a/lib/puppet/network/handler/master.rb b/lib/puppet/network/handler/master.rb
index 25c4318b8..1c7f7310e 100644
--- a/lib/puppet/network/handler/master.rb
+++ b/lib/puppet/network/handler/master.rb
@@ -30,13 +30,6 @@ class Puppet::Network::Handler
def initialize(hash = {})
args = {}
- # Allow specification of a code snippet or of a file
- if code = hash[:Code]
- args[:Code] = code
- elsif man = hash[:Manifest]
- args[:Manifest] = man
- end
-
if hash[:Local]
@local = hash[:Local]
else
@@ -53,12 +46,6 @@ class Puppet::Network::Handler
Puppet.debug("Creating interpreter")
- if hash.include?(:UseNodes)
- args[:UseNodes] = hash[:UseNodes]
- elsif @local
- args[:UseNodes] = false
- end
-
# This is only used by the cfengine module, or if --loadclasses was
# specified in +puppet+.
if hash.include?(:Classes)
@@ -74,7 +61,7 @@ class Puppet::Network::Handler
client, clientip = clientname(client, clientip, facts)
# Pass the facts to the fact handler
- Puppet::Node::Facts.new(client, facts).save
+ Puppet::Node::Facts.new(client, facts).save unless local?
# And get the configuration from the config handler
config = config_handler.configuration(client)