summaryrefslogtreecommitdiffstats
path: root/lib/puppet/server
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2005-08-23 23:08:41 +0000
committerLuke Kanies <luke@madstop.com>2005-08-23 23:08:41 +0000
commit583a9c6e2a7469e4ae3b72264010a5d8d0dab867 (patch)
tree8cc76790c5c22516bff75f0aa821d1d3be128692 /lib/puppet/server
parent5b20c92ff322ba1886209f788ce6a7df05315cf5 (diff)
downloadpuppet-583a9c6e2a7469e4ae3b72264010a5d8d0dab867.tar.gz
puppet-583a9c6e2a7469e4ae3b72264010a5d8d0dab867.tar.xz
puppet-583a9c6e2a7469e4ae3b72264010a5d8d0dab867.zip
remote filecopying now works
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@586 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/server')
-rwxr-xr-xlib/puppet/server/fileserver.rb93
-rw-r--r--lib/puppet/server/servlet.rb8
2 files changed, 57 insertions, 44 deletions
diff --git a/lib/puppet/server/fileserver.rb b/lib/puppet/server/fileserver.rb
index f13c3285f..96080920d 100755
--- a/lib/puppet/server/fileserver.rb
+++ b/lib/puppet/server/fileserver.rb
@@ -38,7 +38,7 @@ class Server
return obj
end
- def describe(file)
+ def describe(file, request = nil)
mount, path = splitpath(file)
subdir = nil
@@ -82,9 +82,22 @@ class Server
else
@local = false
end
+
+ if hash.include?(:Mount)
+ unless hash[:Mount].is_a?(Hash)
+ raise Puppet::DevError, "Invalid mount hash %s" %
+ hash[:Mount].inspect
+ end
+
+ hash[:Mount].each { |dir, name|
+ if FileTest.exists?(dir)
+ self.mount(dir, name)
+ end
+ }
+ end
end
- def list(dir, recurse = false, sum = "md5")
+ def list(dir, recurse = false, sum = "md5", request = nil)
mount, path = splitpath(dir)
subdir = nil
@@ -101,7 +114,7 @@ class Server
#rmdir = File.dirname(File.join(@mounts[mount], path))
rmdir = nameswap(dir, mount)
- desc = self.reclist(rmdir, subdir, recurse)
+ desc = reclist(rmdir, subdir, recurse)
if desc.length == 0
Puppet.notice "Got no information on //%s/%s" %
@@ -145,43 +158,7 @@ class Server
end
end
- # recursive listing function
- def reclist(root, path, recurse)
- #desc = [obj.name.sub(%r{#{root}/?}, '')]
- name = path.sub(root, '')
- if name == ""
- name = "/"
- end
-
- if name == path
- raise Puppet::FileServerError, "Could not match %s in %s" %
- [root, path]
- end
-
- desc = [name]
- ftype = File.stat(path).ftype
-
- desc << ftype
- if recurse.is_a?(Integer)
- recurse -= 1
- end
-
- ary = [desc]
- if recurse == true or (recurse.is_a?(Integer) and recurse > -1)
- if ftype == "directory"
- Dir.entries(path).each { |child|
- next if child =~ /^\.\.?$/
- self.reclist(root, File.join(path, child), recurse).each { |cobj|
- ary << cobj
- }
- }
- end
- end
-
- return ary.reject { |c| c.nil? }
- end
-
- def retrieve(file)
+ def retrieve(file, request = nil)
mount, path = splitpath(file)
unless (@mounts.include?(mount))
@@ -219,6 +196,42 @@ class Server
#newname
end
+ # recursive listing function
+ def reclist(root, path, recurse)
+ #desc = [obj.name.sub(%r{#{root}/?}, '')]
+ name = path.sub(root, '')
+ if name == ""
+ name = "/"
+ end
+
+ if name == path
+ raise Puppet::FileServerError, "Could not match %s in %s" %
+ [root, path]
+ end
+
+ desc = [name]
+ ftype = File.stat(path).ftype
+
+ desc << ftype
+ if recurse.is_a?(Integer)
+ recurse -= 1
+ end
+
+ ary = [desc]
+ if recurse == true or (recurse.is_a?(Integer) and recurse > -1)
+ if ftype == "directory"
+ Dir.entries(path).each { |child|
+ next if child =~ /^\.\.?$/
+ reclist(root, File.join(path, child), recurse).each { |cobj|
+ ary << cobj
+ }
+ }
+ end
+ end
+
+ return ary.reject { |c| c.nil? }
+ end
+
def splitpath(dir)
# the dir is based on one of the mounts
# so first retrieve the mount path
diff --git a/lib/puppet/server/servlet.rb b/lib/puppet/server/servlet.rb
index 70f47a069..b14efe645 100644
--- a/lib/puppet/server/servlet.rb
+++ b/lib/puppet/server/servlet.rb
@@ -72,17 +72,17 @@ class Server
for name, obj in @handler
if obj.kind_of? Proc
unless methodname == name
- Puppet.debug "obj is proc but %s != %s" %
- [methodname, name]
+ #Puppet.debug "obj is proc but %s != %s" %
+ # [methodname, name]
next
end
else
unless methodname =~ /^#{name}(.+)$/
- Puppet.debug "methodname did not match"
+ #Puppet.debug "methodname did not match"
next
end
unless obj.respond_to? $1
- Puppet.debug "methodname does not respond to %s" % $1
+ #Puppet.debug "methodname does not respond to %s" % $1
next
end
obj = obj.method($1)