summaryrefslogtreecommitdiffstats
path: root/lib/puppet
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
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')
-rw-r--r--lib/puppet/client.rb4
-rwxr-xr-xlib/puppet/daemon.rb11
-rwxr-xr-xlib/puppet/server/fileserver.rb93
-rw-r--r--lib/puppet/server/servlet.rb8
-rw-r--r--lib/puppet/type/pfile.rb6
5 files changed, 73 insertions, 49 deletions
diff --git a/lib/puppet/client.rb b/lib/puppet/client.rb
index ee2645852..67307e621 100644
--- a/lib/puppet/client.rb
+++ b/lib/puppet/client.rb
@@ -111,6 +111,10 @@ module Puppet
# from here, i need to add the key, cert, and ca cert
# and reorgize how i start the client
end
+
+ def local
+ false
+ end
end
end
diff --git a/lib/puppet/daemon.rb b/lib/puppet/daemon.rb
index 1cbb35ce5..837debd79 100755
--- a/lib/puppet/daemon.rb
+++ b/lib/puppet/daemon.rb
@@ -41,14 +41,21 @@ module Puppet
def httplog
args = []
# yuck; separate http logs
+ file = nil
if self.is_a?(Puppet::Server)
- args << Puppet[:masterhttplog]
+ file = Puppet[:masterhttplog]
else
- args << Puppet[:httplog]
+ file = Puppet[:httplog]
end
+
+ unless FileTest.exists?(File.dirname(file))
+ Puppet.recmkdir(File.dirname(file))
+ end
+ args << file
if Puppet[:debug]
args << WEBrick::Log::DEBUG
end
+
log = WEBrick::Log.new(*args)
return log
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)
diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb
index cb68ee347..cffa6a890 100644
--- a/lib/puppet/type/pfile.rb
+++ b/lib/puppet/type/pfile.rb
@@ -642,9 +642,8 @@ module Puppet
def describe
source = @source
-
- sourceobj, path = @parent.uri2obj(source)
+ sourceobj, path = @parent.uri2obj(source)
server = sourceobj.server
desc = server.describe(path)
@@ -1300,7 +1299,8 @@ module Puppet
tmp = uri.path
if tmp =~ %r{^/(\w+)}
sourceobj.mount = $1
- path = tmp.sub(%r{^/\w+},'') || "/"
+ path = tmp
+ #path = tmp.sub(%r{^/\w+},'') || "/"
else
raise Puppet::Error, "Invalid source path %s" % tmp
end