summaryrefslogtreecommitdiffstats
path: root/lib/puppet/network/handler
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-10-09 10:54:21 -0500
committerLuke Kanies <luke@madstop.com>2007-10-09 10:54:21 -0500
commit32753e11d9cd731760ec8ba3c4f1ad2e3402535e (patch)
tree0b6375bdefa041a7d4fbab9745ed084fb025bc30 /lib/puppet/network/handler
parentafa1dee5eb3a8b5249715e61f9894b04ab34a6ae (diff)
parent01f132d8b88467dfd314ad355f1cdf9f546945b3 (diff)
Merge branch 'master' of git://michaelobrien.info/puppet into michael
Diffstat (limited to 'lib/puppet/network/handler')
-rw-r--r--lib/puppet/network/handler/configuration.rb51
-rw-r--r--lib/puppet/network/handler/master.rb15
2 files changed, 14 insertions, 52 deletions
diff --git a/lib/puppet/network/handler/configuration.rb b/lib/puppet/network/handler/configuration.rb
index 353693bdc..680304e2a 100644
--- a/lib/puppet/network/handler/configuration.rb
+++ b/lib/puppet/network/handler/configuration.rb
@@ -13,7 +13,7 @@ class Puppet::Network::Handler
include Puppet::Util
- attr_accessor :local
+ attr_accessor :local, :classes
@interface = XMLRPC::Service::Interface.new("configuration") { |iface|
iface.add_method("string configuration(string)")
@@ -43,17 +43,15 @@ class Puppet::Network::Handler
end
def initialize(options = {})
- if options[:Local]
- @local = options[:Local]
- else
- @local = false
+ options.each do |param, value|
+ case param
+ when :Classes: @classes = value
+ when :Local: self.local = value
+ else
+ raise ArgumentError, "Configuration handler does not accept %s" % param
+ end
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
-
set_server_facts
end
@@ -82,8 +80,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 +119,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)