summaryrefslogtreecommitdiffstats
path: root/lib/puppet/network/handler
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-08-22 17:57:28 -0500
committerLuke Kanies <luke@madstop.com>2007-08-22 17:57:28 -0500
commit8b3361afae35cfb65754d7bd9aff5b820ed714f0 (patch)
tree0a6fe8ce4029a8ea8bb82ab80dfb57cb5b6c20cc /lib/puppet/network/handler
parentf1727f18ab933df9ecbecc2da8fad72eb441e0d5 (diff)
downloadpuppet-8b3361afae35cfb65754d7bd9aff5b820ed714f0.tar.gz
puppet-8b3361afae35cfb65754d7bd9aff5b820ed714f0.tar.xz
puppet-8b3361afae35cfb65754d7bd9aff5b820ed714f0.zip
The last commits before I actually start on the multi-environment support. There are still failing tests, but apparently only those that are also failing in trunk.
Diffstat (limited to 'lib/puppet/network/handler')
-rw-r--r--lib/puppet/network/handler/configuration.rb2
-rw-r--r--lib/puppet/network/handler/node.rb84
2 files changed, 23 insertions, 63 deletions
diff --git a/lib/puppet/network/handler/configuration.rb b/lib/puppet/network/handler/configuration.rb
index 3539ab9a4..7e91d74d6 100644
--- a/lib/puppet/network/handler/configuration.rb
+++ b/lib/puppet/network/handler/configuration.rb
@@ -193,7 +193,7 @@ class Puppet::Network::Handler
end
# Mark that the node has checked in. FIXME this needs to be moved into
- # the SimpleNode class, or somewhere that's got abstract backends.
+ # the Node class, or somewhere that's got abstract backends.
def update_node_check(node)
if Puppet.features.rails? and Puppet[:storeconfigs]
Puppet::Rails.connect
diff --git a/lib/puppet/network/handler/node.rb b/lib/puppet/network/handler/node.rb
index a21d571b0..2c4d3e1b5 100644
--- a/lib/puppet/network/handler/node.rb
+++ b/lib/puppet/network/handler/node.rb
@@ -2,74 +2,14 @@
# Copyright (c) 2007. All rights reserved.
require 'puppet/util'
+require 'puppet/node'
require 'puppet/util/classgen'
require 'puppet/util/instance_loader'
# Look up a node, along with all the details about it.
class Puppet::Network::Handler::Node < Puppet::Network::Handler
- # A simplistic class for managing the node information itself.
- class SimpleNode
- attr_accessor :name, :classes, :parameters, :environment, :source, :ipaddress, :names
- attr_reader :time
-
- def initialize(name, options = {})
- @name = name
-
- # Provide a default value.
- @names = [name]
-
- if classes = options[:classes]
- if classes.is_a?(String)
- @classes = [classes]
- else
- @classes = classes
- end
- else
- @classes = []
- end
-
- @parameters = options[:parameters] || {}
-
- unless @environment = options[:environment]
- if env = Puppet[:environment] and env != ""
- @environment = env
- end
- end
-
- @time = Time.now
- end
-
- # Merge the node facts with parameters from the node source.
- # This is only called if the node source has 'fact_merge' set to true.
- def fact_merge(facts)
- facts.each do |name, value|
- @parameters[name] = value unless @parameters.include?(name)
- end
- end
- end
-
desc "Retrieve information about nodes."
- extend Puppet::Util::ClassGen
- extend Puppet::Util::InstanceLoader
-
- # A simple base module we can use for modifying how our node sources work.
- module SourceBase
- include Puppet::Util::Docs
- end
-
- @interface = XMLRPC::Service::Interface.new("nodes") { |iface|
- iface.add_method("string details(key)")
- iface.add_method("string parameters(key)")
- iface.add_method("string environment(key)")
- iface.add_method("string classes(key)")
- }
-
- # Set up autoloading and retrieving of reports.
- autoload :node_source, 'puppet/node_source'
-
- attr_reader :source
-
# Add a new node source.
def self.newnode_source(name, options = {}, &block)
name = symbolize(name)
@@ -109,6 +49,26 @@ class Puppet::Network::Handler::Node < Puppet::Network::Handler
rmclass(name, :hash => instance_hash(:node_source))
end
+ extend Puppet::Util::ClassGen
+ extend Puppet::Util::InstanceLoader
+
+ # A simple base module we can use for modifying how our node sources work.
+ module SourceBase
+ include Puppet::Util::Docs
+ end
+
+ @interface = XMLRPC::Service::Interface.new("nodes") { |iface|
+ iface.add_method("string details(key)")
+ iface.add_method("string parameters(key)")
+ iface.add_method("string environment(key)")
+ iface.add_method("string classes(key)")
+ }
+
+ # Set up autoloading and retrieving of reports.
+ autoload :node_source, 'puppet/node_source'
+
+ attr_reader :source
+
# Return a given node's classes.
def classes(key)
if node = details(key)
@@ -218,7 +178,7 @@ class Puppet::Network::Handler::Node < Puppet::Network::Handler
# Short-hand for creating a new node, so the node sources don't need to
# specify the constant.
def newnode(options)
- SimpleNode.new(options)
+ Puppet::Node.new(options)
end
# Look up the node facts from our fact handler.