summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorshafer <shafer@980ebf18-57e1-0310-9a29-db15c13687c0>2005-09-14 22:30:32 +0000
committershafer <shafer@980ebf18-57e1-0310-9a29-db15c13687c0>2005-09-14 22:30:32 +0000
commitec6603468abad8e0fac3960d778b44019dd63644 (patch)
tree20843b45bca09a38bfde173ea76b59ab9441a288 /lib
parent3d5f5a1c9777b2d0adbf74bdddaad83b7d633f54 (diff)
downloadpuppet-ec6603468abad8e0fac3960d778b44019dd63644.tar.gz
puppet-ec6603468abad8e0fac3960d778b44019dd63644.tar.xz
puppet-ec6603468abad8e0fac3960d778b44019dd63644.zip
added ignore to fileserver and pfile
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@659 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-rwxr-xr-xlib/puppet/server/fileserver.rb24
-rw-r--r--lib/puppet/type/pfile.rb68
2 files changed, 63 insertions, 29 deletions
diff --git a/lib/puppet/server/fileserver.rb b/lib/puppet/server/fileserver.rb
index 4deeea46c..a486874b6 100755
--- a/lib/puppet/server/fileserver.rb
+++ b/lib/puppet/server/fileserver.rb
@@ -15,7 +15,7 @@ class Server
@interface = XMLRPC::Service::Interface.new("fileserver") { |iface|
iface.add_method("string describe(string)")
- iface.add_method("string list(string, boolean)")
+ iface.add_method("string list(string, boolean, array)")
iface.add_method("string retrieve(string)")
}
@@ -81,6 +81,14 @@ class Server
return desc.join("\t")
end
+ def handleignore(children, path, ignore)
+ ignore.each { |ignore|
+ ignored = Dir.glob(File.join(path,ignore), File::FNM_DOTMATCH)
+ children = children - ignored
+ }
+ return children
+ end
+
def initialize(hash = {})
@mounts = {}
@files = {}
@@ -120,7 +128,7 @@ class Server
end
end
- def list(dir, recurse = false, client = nil, clientip = nil)
+ def list(dir, recurse = false, ignore = false, client = nil, clientip = nil)
readconfig
mount, path = splitpath(dir)
@@ -142,7 +150,7 @@ class Server
#rmdir = File.dirname(File.join(@mounts[mount], path))
rmdir = nameswap(dir, mount)
- desc = reclist(rmdir, subdir, recurse)
+ desc = reclist(rmdir, subdir, recurse, ignore)
if desc.length == 0
Puppet.notice "Got no information on //%s/%s" %
@@ -312,7 +320,7 @@ class Server
end
# recursive listing function
- def reclist(root, path, recurse)
+ def reclist(root, path, recurse, ignore)
#desc = [obj.name.sub(%r{#{root}/?}, '')]
name = path.sub(root, '')
if name == ""
@@ -335,9 +343,13 @@ class Server
ary = [desc]
if recurse == true or (recurse.is_a?(Integer) and recurse > -1)
if ftype == "directory"
- Dir.entries(path).each { |child|
+ children = Dir.entries(path)
+ if ignore
+ children = handleignore(children, path, ignore)
+ end
+ children.each { |child|
next if child =~ /^\.\.?$/
- reclist(root, File.join(path, child), recurse).each { |cobj|
+ reclist(root, File.join(path, child), recurse, ignore).each { |cobj|
ary << cobj
}
}
diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb
index a2dc0a89e..07b6699db 100644
--- a/lib/puppet/type/pfile.rb
+++ b/lib/puppet/type/pfile.rb
@@ -23,7 +23,7 @@ module Puppet
def should=(value)
raise Puppet::Error, ":type is read-only"
end
-
+
def retrieve
if stat = @parent.stat(true)
@is = stat.ftype
@@ -815,6 +815,7 @@ module Puppet
end
end
end
+
class Type
class PFile < Type
# FIXME i don't think these are used
@@ -857,11 +858,12 @@ module Puppet
@paramdoc[:ignore] = "A parameter which omits action on files matching specified
patterns during recursion i.e. .svn, *.ini"
- @paramdoc[:source] = "Where to retrieve the contents of the files.
- Currently only supports local copying, but will eventually
- support multiple protocols for copying. Arguments are specified
- using either a full local path or using a URI (currently only
- *file* is supported as a protocol)."
+ #no longer a parameter
+ # @paramdoc[:source] = "Where to retrieve the contents of the files.
+ # Currently only supports local copying, but will eventually
+ # support multiple protocols for copying. Arguments are specified
+ # using either a full local path or using a URI (currently only
+ # *file* is supported as a protocol)."
@@ -933,7 +935,15 @@ module Puppet
return false
end
end
-
+
+ def handleignore(children)
+ @parameters[:ignore].each { |ignore|
+ ignored = Dir.glob(File.join(self.name,ignore), File::FNM_DOTMATCH)
+ children = children - ignored
+ }
+ return children
+ end
+
def initialize(hash)
# clean out as many references to any file paths as possible
# this was the source of many, many bugs
@@ -953,7 +963,7 @@ module Puppet
@srcbase = nil
super
end
-
+
def path
if defined? @parent
if @parent.is_a?(self.class)
@@ -992,10 +1002,19 @@ module Puppet
value.inspect
end
end
+
+ def paramignore=(value)
- def newchild(path, hash = {})
+ #Make sure the value of ignore is in correct type
+ unless value.is_a?(Array) or value.is_a?(String)
+ raise Puppet::DevError.new("Ignore must be a string or an Array")
+ end
+
+ end
- #make local copy of arguments
+ def newchild(path, hash = {})
+
+ #make local copy of arguments
args = @arghash.dup
#check if ignored
@@ -1003,16 +1022,7 @@ module Puppet
if args.include?(:ignore)
ignore = args[:ignore]
- #Make sure the value of ignore is in correct type
- unless ignore.is_a?(Array) | ignore.is_a?(String)
- raise Puppet::DevError.new("Ignore must be a string or an Array")
- end
-
- if ignore.is_a?(String)
- ignore = Array.new(1,ignore)
- end
-
- ignore.each{|pattern|
+ ignore.each { |pattern|
#make sure we got strings
unless pattern.is_a?(String)
@@ -1047,6 +1057,7 @@ module Puppet
args[:path] = path
+=begin
# FIXME I think this is obviated now
unless hash.include?(:source) # it's being manually overridden
if args.include?(:source)
@@ -1063,6 +1074,7 @@ module Puppet
end
end
+=end
unless hash.include?(:recurse)
if args.include?(:recurse)
@@ -1183,9 +1195,17 @@ module Puppet
return
end
+ children = Dir.entries(self.name)
+
+ #Get rid of ignored children
+ if @parameters.include?(:ignore)
+ children = handleignore(children)
+ end
+
added = []
- Dir.foreach(self.name) { |file|
- next if file =~ /^\.\.?/ # skip . and ..
+ children.each { |file|
+ file = File.basename(file)
+ next if file =~ /^\.\.?/ # skip . and ..
if child = self.newchild(file, :recurse => recurse)
unless @children.include?(child)
self.push child
@@ -1222,8 +1242,10 @@ module Puppet
end
end
+ ignore = @parameters[:ignore]
+
#Puppet.warning "Listing path %s" % path.inspect
- desc = server.list(path, r)
+ desc = server.list(path, r, ignore)
desc.split("\n").each { |line|
file, type = line.split("\t")