summaryrefslogtreecommitdiffstats
path: root/lib/puppet/network/handler
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-03-31 23:56:09 -0500
committerLuke Kanies <luke@madstop.com>2008-03-31 23:56:09 -0500
commit88dc49cb7b0efe757c92ce28c807b91335acb07a (patch)
tree13fe4561f1f524f97a8bb2c1ff84c1ef981d0241 /lib/puppet/network/handler
parent4165edaeb71ee2883b1bb85ff39a52d5628b259f (diff)
parenta8592f1009040ebf30a98268610915cc33bb3f63 (diff)
downloadpuppet-88dc49cb7b0efe757c92ce28c807b91335acb07a.tar.gz
puppet-88dc49cb7b0efe757c92ce28c807b91335acb07a.tar.xz
puppet-88dc49cb7b0efe757c92ce28c807b91335acb07a.zip
Merge branch 'master' into master_no_global_resources
Conflicts: lib/puppet/node/catalog.rb lib/puppet/type/pfile.rb lib/puppet/type/pfilebucket.rb lib/puppet/util/filetype.rb spec/unit/node/catalog.rb spec/unit/other/transbucket.rb spec/unit/ral/provider/mount/parsed.rb spec/unit/ral/types/file.rb spec/unit/ral/types/interface.rb spec/unit/ral/types/mount.rb spec/unit/ral/types/package.rb spec/unit/ral/types/schedule.rb spec/unit/ral/types/service.rb test/language/compile.rb test/language/lexer.rb test/language/snippets.rb test/lib/puppettest.rb test/ral/types/basic.rb test/ral/types/cron.rb test/ral/types/exec.rb test/ral/types/file.rb test/ral/types/file/target.rb test/ral/types/filebucket.rb test/ral/types/fileignoresource.rb test/ral/types/filesources.rb test/ral/types/group.rb test/ral/types/host.rb test/ral/types/parameter.rb test/ral/types/sshkey.rb test/ral/types/tidy.rb test/ral/types/user.rb test/ral/types/yumrepo.rb
Diffstat (limited to 'lib/puppet/network/handler')
-rwxr-xr-xlib/puppet/network/handler/fileserver.rb116
-rw-r--r--lib/puppet/network/handler/master.rb2
-rwxr-xr-xlib/puppet/network/handler/report.rb3
3 files changed, 26 insertions, 95 deletions
diff --git a/lib/puppet/network/handler/fileserver.rb b/lib/puppet/network/handler/fileserver.rb
index 3ee4721f3..183979429 100755
--- a/lib/puppet/network/handler/fileserver.rb
+++ b/lib/puppet/network/handler/fileserver.rb
@@ -5,6 +5,9 @@ require 'cgi'
require 'delegate'
require 'sync'
+require 'puppet/file_serving'
+require 'puppet/file_serving/metadata'
+
class Puppet::Network::Handler
AuthStoreError = Puppet::AuthStoreError
class FileServerError < Puppet::Error; end
@@ -59,40 +62,27 @@ class Puppet::Network::Handler
# Describe a given file. This returns all of the manageable aspects
# of that file.
- def describe(url, links = :ignore, client = nil, clientip = nil)
+ def describe(url, links = :follow, client = nil, clientip = nil)
links = links.intern if links.is_a? String
- if links == :manage
- raise Puppet::Network::Handler::FileServerError, "Cannot currently copy links"
- end
-
mount, path = convert(url, client, clientip)
- if client
- mount.debug "Describing %s for %s" % [url, client]
- end
+ mount.debug("Describing %s for %s" % [url, client]) if client
- obj = nil
- unless obj = mount.getfileobject(path, links, client)
+ # use the mount to resolve the path for us.
+ metadata = Puppet::FileServing::Metadata.new(url, :path => mount.file_path(path, client), :links => links)
+
+ return "" unless metadata.exist?
+
+ begin
+ metadata.collect_attributes
+ rescue => detail
+ puts detail.backtrace if Puppet[:trace]
+ Puppet.err detail
return ""
end
- currentvalues = mount.check(obj)
-
- desc = []
- CHECKPARAMS.each { |check|
- if value = currentvalues[check]
- desc << value
- else
- if check == "checksum" and currentvalues[:type] == "file"
- mount.notice "File %s does not have data for %s" %
- [obj.name, check]
- end
- desc << nil
- end
- }
-
- return desc.join("\t")
+ return metadata.attributes_with_tabs
end
# Create a new fileserving module.
@@ -140,26 +130,18 @@ class Puppet::Network::Handler
def list(url, links = :ignore, recurse = false, ignore = false, client = nil, clientip = nil)
mount, path = convert(url, client, clientip)
- if client
- mount.debug "Listing %s for %s" % [url, client]
- end
+ mount.debug "Listing %s for %s" % [url, client] if client
- obj = nil
- unless mount.path_exists?(path, client)
- return ""
- end
+ return "" unless mount.path_exists?(path, client)
desc = mount.list(path, recurse, ignore, client)
if desc.length == 0
- mount.notice "Got no information on //%s/%s" %
- [mount, path]
+ mount.notice "Got no information on //%s/%s" % [mount, path]
return ""
end
-
- desc.collect { |sub|
- sub.join("\t")
- }.join("\n")
+
+ desc.collect { |sub| sub.join("\t") }.join("\n")
end
def local?
@@ -213,12 +195,7 @@ class Puppet::Network::Handler
return ""
end
- str = nil
- if links == :manage
- raise Puppet::Error, "Cannot copy links yet."
- else
- str = mount.read_file(path, client)
- end
+ str = mount.read_file(path, client)
if @local
return str
@@ -452,55 +429,6 @@ class Puppet::Network::Handler
Puppet::Util.logmethods(self, true)
- def getfileobject(dir, links, client = nil)
- unless path_exists?(dir, client)
- self.debug "File source %s does not exist" % dir
- return nil
- end
-
- return fileobj(dir, links, client)
- end
-
- # Run 'retrieve' on a file. This gets the actual parameters, so
- # we can pass them to the client.
- def check(obj)
- # Retrieval is enough here, because we don't want to cache
- # any information in the state file, and we don't want to generate
- # any state changes or anything. We don't even need to sync
- # the checksum, because we're always going to hit the disk
- # directly.
-
- # We're now caching file data, using the LoadedFile to check the
- # disk no more frequently than the :filetimeout.
- path = obj[:path]
- sync = sync(path)
- unless data = @@files[path]
- data = {}
- sync.synchronize(Sync::EX) do
- @@files[path] = data
- data[:loaded_obj] = Puppet::Util::LoadedFile.new(path)
- data[:values] = properties(obj)
- return data[:values]
- end
- end
-
- changed = nil
- sync.synchronize(Sync::SH) do
- changed = data[:loaded_obj].changed?
- end
-
- if changed
- sync.synchronize(Sync::EX) do
- data[:values] = properties(obj)
- return data[:values]
- end
- else
- sync.synchronize(Sync::SH) do
- return data[:values]
- end
- end
- end
-
# Create a map for a specific client.
def clientmap(client)
{
diff --git a/lib/puppet/network/handler/master.rb b/lib/puppet/network/handler/master.rb
index 8d84fe8b8..dabfaca50 100644
--- a/lib/puppet/network/handler/master.rb
+++ b/lib/puppet/network/handler/master.rb
@@ -82,6 +82,8 @@ class Puppet::Network::Handler
if Puppet[:node_name] == 'cert'
if name
client = name
+ facts["fqdn"] = client
+ facts["hostname"], facts["domain"] = client.split('.', 2)
end
if ip
clientip = ip
diff --git a/lib/puppet/network/handler/report.rb b/lib/puppet/network/handler/report.rb
index 8ddeed9f6..b92b77ea5 100755
--- a/lib/puppet/network/handler/report.rb
+++ b/lib/puppet/network/handler/report.rb
@@ -79,7 +79,8 @@ class Puppet::Network::Handler
# Handle the parsing of the reports attribute.
def reports
- Puppet[:reports].gsub(/(^\s+)|(\s+$)/, '').split(/\s*,\s*/)
+ # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com]
+ x = Puppet[:reports].gsub(/(^\s+)|(\s+$)/, '').split(/\s*,\s*/)
end
end
end