summaryrefslogtreecommitdiffstats
path: root/lib/puppet/network
diff options
context:
space:
mode:
authorMichael V. O'Brien <michael@reductivelabs.com>2007-09-25 12:00:07 -0500
committerMichael V. O'Brien <michael@reductivelabs.com>2007-09-25 12:00:07 -0500
commitff2828f5dbe68ff1cb06a3503590a3e4bd1b59e3 (patch)
tree8c8960cac1d7b3e8b48e44163062be3b3f4c201f /lib/puppet/network
parentf8ab62b212788a4591276c95b5f67217f7517e4e (diff)
parentffaa8ce07979f4db860950fa9be08ca37964206f (diff)
downloadpuppet-ff2828f5dbe68ff1cb06a3503590a3e4bd1b59e3.tar.gz
puppet-ff2828f5dbe68ff1cb06a3503590a3e4bd1b59e3.tar.xz
puppet-ff2828f5dbe68ff1cb06a3503590a3e4bd1b59e3.zip
Merge branch 'master' of git://reductivelabs.com/puppet
Diffstat (limited to 'lib/puppet/network')
-rw-r--r--lib/puppet/network/client/ca.rb8
-rw-r--r--lib/puppet/network/client/master.rb180
-rw-r--r--lib/puppet/network/handler/ca.rb2
-rw-r--r--lib/puppet/network/handler/configuration.rb14
-rwxr-xr-xlib/puppet/network/handler/facts.rb68
-rwxr-xr-xlib/puppet/network/handler/filebucket.rb2
-rwxr-xr-xlib/puppet/network/handler/fileserver.rb15
-rw-r--r--lib/puppet/network/handler/master.rb9
-rw-r--r--lib/puppet/network/handler/node.rb242
-rwxr-xr-xlib/puppet/network/handler/report.rb4
-rwxr-xr-xlib/puppet/network/handler/resource.rb13
-rwxr-xr-xlib/puppet/network/handler/runner.rb4
-rw-r--r--lib/puppet/network/server/webrick.rb2
13 files changed, 70 insertions, 493 deletions
diff --git a/lib/puppet/network/client/ca.rb b/lib/puppet/network/client/ca.rb
index 412c9c59f..46fb9f51f 100644
--- a/lib/puppet/network/client/ca.rb
+++ b/lib/puppet/network/client/ca.rb
@@ -14,9 +14,9 @@ class Puppet::Network::Client::CA < Puppet::Network::Client
end
# This client is really only able to request certificates for the
- # current host. It uses the Puppet.config settings to figure everything out.
+ # current host. It uses the Puppet.settings settings to figure everything out.
def request_cert
- Puppet.config.use(:main, :ssl)
+ Puppet.settings.use(:main, :ssl)
if cert = read_cert
return cert
@@ -49,8 +49,8 @@ class Puppet::Network::Client::CA < Puppet::Network::Client
end
# Only write the cert out if it passes validating.
- Puppet.config.write(:hostcert) do |f| f.print cert end
- Puppet.config.write(:localcacert) do |f| f.print cacert end
+ Puppet.settings.write(:hostcert) do |f| f.print cert end
+ Puppet.settings.write(:localcacert) do |f| f.print cacert end
return @cert
end
diff --git a/lib/puppet/network/client/master.rb b/lib/puppet/network/client/master.rb
index c6d7cd75d..f950a6059 100644
--- a/lib/puppet/network/client/master.rb
+++ b/lib/puppet/network/client/master.rb
@@ -7,7 +7,7 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
@@sync = Sync.new
end
- attr_accessor :objects
+ attr_accessor :configuration
attr_reader :compile_time
class << self
@@ -46,51 +46,7 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
# Return the list of dynamic facts as an array of symbols
def self.dynamic_facts
- Puppet.config[:dynamicfacts].split(/\s*,\s*/).collect { |fact| fact.downcase }
- end
-
- # This method actually applies the configuration.
- def apply(tags = nil, ignoreschedules = false)
- unless defined? @objects
- raise Puppet::Error, "Cannot apply; objects not defined"
- end
-
- transaction = @objects.evaluate
-
- if tags
- transaction.tags = tags
- end
-
- if ignoreschedules
- transaction.ignoreschedules = true
- end
-
- transaction.addtimes :config_retrieval => @configtime
-
- begin
- transaction.evaluate
- rescue Puppet::Error => detail
- Puppet.err "Could not apply complete configuration: %s" %
- detail
- rescue => detail
- Puppet.err "Got an uncaught exception of type %s: %s" %
- [detail.class, detail]
- if Puppet[:trace]
- puts detail.backtrace
- end
- ensure
- Puppet::Util::Storage.store
- end
-
- if Puppet[:report] or Puppet[:summarize]
- report(transaction)
- end
-
- return transaction
- ensure
- if defined? transaction and transaction
- transaction.cleanup
- end
+ Puppet.settings[:dynamicfacts].split(/\s*,\s*/).collect { |fact| fact.downcase }
end
# Cache the config
@@ -111,10 +67,10 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
end
def clear
- @objects.remove(true) if @objects
+ @configuration.clear(true) if @configuration
Puppet::Type.allclear
mkdefault_objects
- @objects = nil
+ @configuration = nil
end
# Initialize and load storage
@@ -183,15 +139,15 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
facts = self.class.facts
end
- if self.objects or FileTest.exists?(self.cachefile)
+ if self.configuration or FileTest.exists?(self.cachefile)
if self.fresh?(facts)
Puppet.info "Config is up to date"
- if self.objects
+ if self.configuration
return
end
if oldtext = self.retrievecache
begin
- @objects = YAML.load(oldtext).to_type
+ @configuration = YAML.load(oldtext).to_configuration
rescue => detail
Puppet.warning "Could not load cached configuration: %s" % detail
end
@@ -213,7 +169,7 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
end
unless objects = get_actual_config(facts)
- @objects = nil
+ @configuration = nil
return
end
@@ -225,21 +181,21 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
self.setclasses(objects.classes)
# Clear all existing objects, so we can recreate our stack.
- if self.objects
+ if self.configuration
clear()
end
- # Now convert the objects to real Puppet objects
- @objects = objects.to_type
+ # Now convert the objects to a puppet configuration graph.
+ @configuration = objects.to_configuration
- if @objects.nil?
+ if @configuration.nil?
raise Puppet::Error, "Configuration could not be processed"
end
- # and perform any necessary final actions before we evaluate.
- @objects.finalize
+ # Keep the state database up to date.
+ @configuration.host_config = true
- return @objects
+ return @configuration
end
# A simple proxy method, so it's easy to test.
@@ -249,12 +205,9 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
# Just so we can specify that we are "the" instance.
def initialize(*args)
- Puppet.config.use(:main, :ssl, :puppetd)
+ Puppet.settings.use(:main, :ssl, :puppetd)
super
- # This might be nil
- @configtime = 0
-
self.class.instance = self
@running = false
@@ -297,7 +250,9 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
end
# The code that actually runs the configuration.
- def run(tags = nil, ignoreschedules = false)
+ # This just passes any options on to the configuration,
+ # which accepts :tags and :ignoreschedules.
+ def run(options = {})
got_lock = false
splay
Puppet::Util.sync(:puppetrun).synchronize(Sync::EX) do
@@ -307,19 +262,20 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
else
got_lock = true
begin
- @configtime = thinmark do
+ duration = thinmark do
self.getconfig
end
rescue => detail
Puppet.err "Could not retrieve configuration: %s" % detail
end
- if defined? @objects and @objects
+ if defined? @configuration and @configuration
+ @configuration.retrieval_duration = duration
unless @local
Puppet.notice "Starting configuration run"
end
benchmark(:notice, "Finished configuration run") do
- self.apply(tags, ignoreschedules)
+ @configuration.apply(options)
end
end
end
@@ -366,9 +322,6 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
# Download files from the remote server, returning a list of all
# changed files.
def self.download(args)
- objects = Puppet::Type.type(:component).create(
- :name => "#{args[:name]}_collector"
- )
hash = {
:path => args[:dest],
:recurse => true,
@@ -383,18 +336,23 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
if args[:ignore]
hash[:ignore] = args[:ignore].split(/\s+/)
end
- objects.push Puppet::Type.type(:file).create(hash)
+ downconfig = Puppet::Node::Configuration.new("downloading")
+ downconfig.add_resource Puppet::Type.type(:file).create(hash)
Puppet.info "Retrieving #{args[:name]}s"
noop = Puppet[:noop]
Puppet[:noop] = false
+ files = []
begin
- trans = objects.evaluate
- trans.ignoretags = true
Timeout::timeout(self.timeout) do
- trans.evaluate
+ downconfig.apply do |trans|
+ trans.changed?.find_all do |resource|
+ yield resource if block_given?
+ files << resource[:path]
+ end
+ end
end
rescue Puppet::Error, Timeout::Error => detail
if Puppet[:debug]
@@ -403,18 +361,10 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
Puppet.err "Could not retrieve #{args[:name]}s: %s" % detail
end
- # Now source all of the changed objects, but only source those
- # that are top-level.
- files = []
- trans.changed?.find_all do |object|
- yield object if block_given?
- files << object[:path]
- end
- trans.cleanup
-
# Now clean up after ourselves
- objects.remove
- files
+ downconfig.clear
+
+ return files
ensure
# I can't imagine why this is necessary, but apparently at last one person has had problems with noop
# being nil here.
@@ -427,21 +377,21 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
# Retrieve facts from the central server.
def self.getfacts
- # Clear all existing definitions.
- Facter.clear
# Download the new facts
path = Puppet[:factpath].split(":")
files = []
download(:dest => Puppet[:factdest], :source => Puppet[:factsource],
- :ignore => Puppet[:factsignore], :name => "fact") do |object|
-
- next unless path.include?(::File.dirname(object[:path]))
+ :ignore => Puppet[:factsignore], :name => "fact") do |resource|
- files << object[:path]
+ next unless path.include?(::File.dirname(resource[:path]))
+ files << resource[:path]
end
ensure
+ # Clear all existing definitions.
+ Facter.clear
+
# Reload everything.
if Facter.respond_to? :loadfacts
Facter.loadfacts
@@ -461,20 +411,20 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
# changed plugins, because Puppet::Type loads plugins on demand.
def self.getplugins
download(:dest => Puppet[:plugindest], :source => Puppet[:pluginsource],
- :ignore => Puppet[:pluginsignore], :name => "plugin") do |object|
+ :ignore => Puppet[:pluginsignore], :name => "plugin") do |resource|
- next if FileTest.directory?(object[:path])
- path = object[:path].sub(Puppet[:plugindest], '').sub(/^\/+/, '')
+ next if FileTest.directory?(resource[:path])
+ path = resource[:path].sub(Puppet[:plugindest], '').sub(/^\/+/, '')
unless Puppet::Util::Autoload.loaded?(path)
next
end
begin
Puppet.info "Reloading downloaded file %s" % path
- load object[:path]
+ load resource[:path]
rescue => detail
Puppet.warning "Could not reload downloaded file %s: %s" %
- [object[:path], detail]
+ [resource[:path], detail]
end
end
end
@@ -517,42 +467,6 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
return timeout
end
-
- # Send off the transaction report.
- def report(transaction)
- begin
- report = transaction.generate_report()
- rescue => detail
- Puppet.err "Could not generate report: %s" % detail
- return
- end
-
- if Puppet[:rrdgraph] == true
- report.graph()
- end
-
- if Puppet[:summarize]
- puts report.summary
- end
-
- if Puppet[:report]
- begin
- reportclient().report(report)
- rescue => detail
- Puppet.err "Reporting failed: %s" % detail
- end
- end
- end
-
- def reportclient
- unless defined? @reportclient
- @reportclient = Puppet::Network::Client.report.new(
- :Server => Puppet[:reportserver]
- )
- end
-
- @reportclient
- end
loadfacts()
@@ -633,7 +547,7 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
Puppet.err "Could not retrieve configuration: %s" % detail
unless Puppet[:usecacheonfailure]
- @objects = nil
+ @configuration = nil
Puppet.warning "Not using cache on failed configuration"
return
end
diff --git a/lib/puppet/network/handler/ca.rb b/lib/puppet/network/handler/ca.rb
index 422b21ae1..052eb5c19 100644
--- a/lib/puppet/network/handler/ca.rb
+++ b/lib/puppet/network/handler/ca.rb
@@ -60,7 +60,7 @@ class Puppet::Network::Handler
end
def initialize(hash = {})
- Puppet.config.use(:main, :ssl, :ca)
+ Puppet.settings.use(:main, :ssl, :ca)
if hash.include? :autosign
@autosign = hash[:autosign]
end
diff --git a/lib/puppet/network/handler/configuration.rb b/lib/puppet/network/handler/configuration.rb
index 2c72d3d2b..2df1b3ab4 100644
--- a/lib/puppet/network/handler/configuration.rb
+++ b/lib/puppet/network/handler/configuration.rb
@@ -30,7 +30,7 @@ class Puppet::Network::Handler
# Note that this is reasonable, because either their node source should actually
# know about the node, or they should be using the ``none`` node source, which
# will always return data.
- unless node = node_handler.details(key)
+ unless node = Puppet::Node.search(key)
raise Puppet::Error, "Could not find node '%s'" % key
end
@@ -64,7 +64,7 @@ class Puppet::Network::Handler
# Return the configuration version.
def version(client = nil, clientip = nil)
- if client and node = node_handler.details(client)
+ if client and node = Puppet::Node.search(client)
update_node_check(node)
return interpreter.configuration_version(node)
else
@@ -79,7 +79,7 @@ class Puppet::Network::Handler
# Add any extra data necessary to the node.
def add_node_data(node)
# Merge in our server-side facts, so they can be used during compilation.
- node.fact_merge(@server_facts)
+ node.merge(@server_facts)
# Add any specified classes to the node's class list.
if classes = @options[:Classes]
@@ -159,14 +159,6 @@ class Puppet::Network::Handler
@interpreter
end
- # Create a node handler instance for looking up our nodes.
- def node_handler
- unless defined?(@node_handler)
- @node_handler = Puppet::Network::Handler.handler(:node).create
- end
- @node_handler
- end
-
# Initialize our server fact hash; we add these to each client, and they
# won't change while we're running, so it's safe to cache the values.
def set_server_facts
diff --git a/lib/puppet/network/handler/facts.rb b/lib/puppet/network/handler/facts.rb
deleted file mode 100755
index 4767e8be4..000000000
--- a/lib/puppet/network/handler/facts.rb
+++ /dev/null
@@ -1,68 +0,0 @@
-require 'yaml'
-require 'puppet/util/fact_store'
-
-class Puppet::Network::Handler
- # Receive logs from remote hosts.
- class Facts < Handler
- desc "An interface for storing and retrieving client facts. Currently only
- used internally by Puppet."
-
- @interface = XMLRPC::Service::Interface.new("facts") { |iface|
- iface.add_method("void set(string, string)")
- iface.add_method("string get(string)")
- iface.add_method("integer store_date(string)")
- }
-
- def initialize(hash = {})
- super
-
- backend = Puppet[:factstore]
-
- unless klass = Puppet::Util::FactStore.store(backend)
- raise Puppet::Error, "Could not find fact store %s" % backend
- end
-
- @backend = klass.new
- end
-
- # Get the facts from our back end.
- def get(node)
- if facts = @backend.get(node)
- return strip_internal(facts)
- else
- return nil
- end
- end
-
- # Set the facts in the backend.
- def set(node, facts)
- @backend.set(node, add_internal(facts))
- nil
- end
-
- # Retrieve a client's storage date.
- def store_date(node)
- if facts = get(node)
- facts[:_puppet_timestamp].to_i
- else
- nil
- end
- end
-
- private
-
- # Add internal data to the facts for storage.
- def add_internal(facts)
- facts = facts.dup
- facts[:_puppet_timestamp] = Time.now
- facts
- end
-
- # Strip out that internal data.
- def strip_internal(facts)
- facts = facts.dup
- facts.find_all { |name, value| name.to_s =~ /^_puppet_/ }.each { |name, value| facts.delete(name) }
- facts
- end
- end
-end
diff --git a/lib/puppet/network/handler/filebucket.rb b/lib/puppet/network/handler/filebucket.rb
index bb6a0e6d3..1bf8da854 100755
--- a/lib/puppet/network/handler/filebucket.rb
+++ b/lib/puppet/network/handler/filebucket.rb
@@ -64,7 +64,7 @@ class Puppet::Network::Handler # :nodoc:
end
end
- Puppet.config.use(:filebucket)
+ Puppet.settings.use(:filebucket)
@name = "Filebucket[#{@path}]"
end
diff --git a/lib/puppet/network/handler/fileserver.rb b/lib/puppet/network/handler/fileserver.rb
index a429412d2..ae0e6553d 100755
--- a/lib/puppet/network/handler/fileserver.rb
+++ b/lib/puppet/network/handler/fileserver.rb
@@ -243,7 +243,10 @@ class Puppet::Network::Handler
# the modules.
def modules_mount(module_name, client)
# Find our environment, if we have one.
- if node = node_handler.details(client || Facter.value("hostname"))
+ unless hostname = (client || Facter.value("hostname"))
+ raise ArgumentError, "Could not find hostname"
+ end
+ if node = Puppet::Node.find(hostname)
env = node.environment
else
env = nil
@@ -258,14 +261,6 @@ class Puppet::Network::Handler
end
end
- # Create a node handler instance for looking up our nodes.
- def node_handler
- unless defined?(@node_handler)
- @node_handler = Puppet::Network::Handler.handler(:node).create
- end
- @node_handler
- end
-
# Read the configuration file.
def readconfig(check = true)
return if @noreadconfig
@@ -455,7 +450,7 @@ class Puppet::Network::Handler
def getfileobject(dir, links)
unless FileTest.exists?(dir)
- self.notice "File source %s does not exist" % dir
+ self.debug "File source %s does not exist" % dir
return nil
end
diff --git a/lib/puppet/network/handler/master.rb b/lib/puppet/network/handler/master.rb
index c8db277ba..030950c61 100644
--- a/lib/puppet/network/handler/master.rb
+++ b/lib/puppet/network/handler/master.rb
@@ -74,7 +74,7 @@ class Puppet::Network::Handler
client, clientip = clientname(client, clientip, facts)
# Pass the facts to the fact handler
- fact_handler.set(client, facts)
+ Puppet::Node::Facts.new(client, facts).save
# And get the configuration from the config handler
begin
@@ -134,13 +134,6 @@ class Puppet::Network::Handler
return facts
end
- def fact_handler
- unless defined? @fact_handler
- @fact_handler = Puppet::Network::Handler.handler(:facts).new :local => local?
- end
- @fact_handler
- end
-
# Translate our configuration appropriately for sending back to a client.
def translate(config)
if local?
diff --git a/lib/puppet/network/handler/node.rb b/lib/puppet/network/handler/node.rb
deleted file mode 100644
index c6ccc2eb6..000000000
--- a/lib/puppet/network/handler/node.rb
+++ /dev/null
@@ -1,242 +0,0 @@
-# Created by Luke A. Kanies on 2007-08-13.
-# 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
- desc "Retrieve information about nodes."
-
- # Create a singleton node handler
- def self.create
- unless @handler
- @handler = new
- end
- @handler
- end
-
- # Add a new node source.
- def self.newnode_source(name, options = {}, &block)
- name = symbolize(name)
-
- fact_merge = options[:fact_merge]
- mod = genmodule(name, :extend => SourceBase, :hash => instance_hash(:node_source), :block => block)
- mod.send(:define_method, :fact_merge?) do
- fact_merge
- end
- mod
- end
-
- # Collect the docs for all of our node sources.
- def self.node_source_docs
- docs = ""
-
- # Use this method so they all get loaded
- instance_loader(:node_source).loadall
- loaded_instances(:node_source).sort { |a,b| a.to_s <=> b.to_s }.each do |name|
- mod = self.node_source(name)
- docs += "%s\n%s\n" % [name, "-" * name.to_s.length]
-
- docs += Puppet::Util::Docs.scrub(mod.doc) + "\n\n"
- end
-
- docs
- end
-
- # List each of the node sources.
- def self.node_sources
- instance_loader(:node_source).loadall
- loaded_instances(:node_source)
- end
-
- # Remove a defined node source; basically only used for testing.
- def self.rm_node_source(name)
- 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.
- instance_load :node_source, 'puppet/node_source'
-
- attr_reader :source
-
- # Return a given node's classes.
- def classes(key)
- if node = details(key)
- node.classes
- else
- nil
- end
- end
-
- # Return an entire node configuration. This uses the 'nodesearch' method
- # defined in the node_source to look for the node.
- def details(key, client = nil, clientip = nil)
- return nil unless key
- if node = cached?(key)
- return node
- end
- facts = node_facts(key)
- node = nil
- names = node_names(key, facts)
- names.each do |name|
- name = name.to_s if name.is_a?(Symbol)
- if node = nodesearch(name) and @source != "none"
- Puppet.info "Found %s in %s" % [name, @source]
- break
- end
- end
-
- # If they made it this far, we haven't found anything, so look for a
- # default node.
- unless node or names.include?("default")
- if node = nodesearch("default")
- Puppet.notice "Using default node for %s" % key
- end
- end
-
- if node
- node.source = @source
- node.names = names
-
- # Merge the facts into the parameters.
- if fact_merge?
- node.fact_merge(facts)
- end
-
- cache(node)
-
- return node
- else
- return nil
- end
- end
-
- # Return a given node's environment.
- def environment(key, client = nil, clientip = nil)
- if node = details(key)
- node.environment
- else
- nil
- end
- end
-
- # Create our node lookup tool.
- def initialize(hash = {})
- @source = hash[:Source] || Puppet[:node_source]
-
- unless mod = self.class.node_source(@source)
- raise ArgumentError, "Unknown node source '%s'" % @source
- end
-
- extend(mod)
-
- super
-
- # We cache node info for speed
- @node_cache = {}
- end
-
- # Try to retrieve a given node's parameters.
- def parameters(key, client = nil, clientip = nil)
- if node = details(key)
- node.parameters
- else
- nil
- end
- end
-
- private
-
- # Store the node to make things a bit faster.
- def cache(node)
- @node_cache[node.name] = node
- end
-
- # If the node is cached, return it.
- def cached?(name)
- # Don't use cache when the filetimeout is set to 0
- return false if [0, "0"].include?(Puppet[:filetimeout])
-
- if node = @node_cache[name] and Time.now - node.time < Puppet[:filetimeout]
- return node
- else
- return false
- end
- end
-
- # Create/cache a fact handler.
- def fact_handler
- unless defined?(@fact_handler)
- @fact_handler = Puppet::Network::Handler.handler(:facts).new
- end
- @fact_handler
- end
-
- # Short-hand for creating a new node, so the node sources don't need to
- # specify the constant.
- def newnode(options)
- Puppet::Node.new(options)
- end
-
- # Look up the node facts from our fact handler.
- def node_facts(key)
- if facts = fact_handler.get(key)
- facts
- else
- {}
- end
- end
-
- # Calculate the list of node names we should use for looking
- # up our node.
- def node_names(key, facts = nil)
- facts ||= node_facts(key)
- names = []
-
- if hostname = facts["hostname"]
- unless hostname == key
- names << hostname
- end
- else
- hostname = key
- end
-
- if fqdn = facts["fqdn"]
- hostname = fqdn
- names << fqdn
- end
-
- # Make sure both the fqdn and the short name of the
- # host can be used in the manifest
- if hostname =~ /\./
- names << hostname.sub(/\..+/,'')
- elsif domain = facts['domain']
- names << hostname + "." + domain
- end
-
- # Sort the names inversely by name length.
- names.sort! { |a,b| b.length <=> a.length }
-
- # And make sure the key is first, since that's the most
- # likely usage.
- ([key] + names).uniq
- end
-end
diff --git a/lib/puppet/network/handler/report.rb b/lib/puppet/network/handler/report.rb
index 81aee6a3c..62e9cfdec 100755
--- a/lib/puppet/network/handler/report.rb
+++ b/lib/puppet/network/handler/report.rb
@@ -71,8 +71,8 @@ class Puppet::Network::Handler
def initialize(*args)
super
- Puppet.config.use(:reporting)
- Puppet.config.use(:metrics)
+ Puppet.settings.use(:reporting)
+ Puppet.settings.use(:metrics)
end
# Accept a report from a client.
diff --git a/lib/puppet/network/handler/resource.rb b/lib/puppet/network/handler/resource.rb
index ac29dce53..7709b85fe 100755
--- a/lib/puppet/network/handler/resource.rb
+++ b/lib/puppet/network/handler/resource.rb
@@ -39,21 +39,14 @@ class Puppet::Network::Handler
end
end
- component = bucket.to_type
-
- # Create a client, but specify the remote machine as the server
- # because the class requires it, even though it's unused
- client = Puppet::Network::Client.client(:Master).new(:Master => client||"localhost")
-
- # Set the objects
- client.objects = component
+ config = bucket.to_configuration
# And then apply the configuration. This way we're reusing all
# the code in there. It should probably just be separated out, though.
- transaction = client.apply
+ transaction = config.apply
# And then clean up
- component.remove
+ config.clear(true)
# It'd be nice to return some kind of report, but... at this point
# we have no such facility.
diff --git a/lib/puppet/network/handler/runner.rb b/lib/puppet/network/handler/runner.rb
index c41e83608..4b9ccab75 100755
--- a/lib/puppet/network/handler/runner.rb
+++ b/lib/puppet/network/handler/runner.rb
@@ -50,10 +50,10 @@ class Puppet::Network::Handler
# And then we need to tell it to run, with this extra info.
if fg
- master.run(tags, ignoreschedules)
+ master.run(:tags => tags, :ignoreschedules => ignoreschedules)
else
Puppet.newthread do
- master.run(tags, ignoreschedules)
+ master.run(:tags => tags, :ignoreschedules => ignoreschedules)
end
end
diff --git a/lib/puppet/network/server/webrick.rb b/lib/puppet/network/server/webrick.rb
index 3af0cfd3f..f24411ab3 100644
--- a/lib/puppet/network/server/webrick.rb
+++ b/lib/puppet/network/server/webrick.rb
@@ -48,7 +48,7 @@ module Puppet
# yuck; separate http logs
file = nil
- Puppet.config.use(:main, :ssl, Puppet[:name])
+ Puppet.settings.use(:main, :ssl, Puppet[:name])
if Puppet[:name] == "puppetmasterd"
file = Puppet[:masterhttplog]
else