summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-01-13 22:47:22 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-01-13 22:47:22 +0000
commit1d4638a03df6821c16c00db3084f89889f19ac33 (patch)
tree7fcc1306648893d78090eb04492e108a9347e0d5 /lib/puppet
parenta6e367e5989d0646c2f53c2de839893be76988cb (diff)
downloadpuppet-1d4638a03df6821c16c00db3084f89889f19ac33.tar.gz
puppet-1d4638a03df6821c16c00db3084f89889f19ac33.tar.xz
puppet-1d4638a03df6821c16c00db3084f89889f19ac33.zip
Added "finish" method, using it in Type.finalize, and moved autorequire and setdefaults to it.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@824 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/type.rb20
-rwxr-xr-xlib/puppet/type/pfile/create.rb26
2 files changed, 39 insertions, 7 deletions
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index 0e4c1425d..74c163338 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -294,6 +294,16 @@ class Type < Puppet::Element
# Perform any operations that need to be done between instance creation
# and instance evaluation.
def self.finalize
+ finished = {}
+ self.eachtype do |type|
+ type.each do |object|
+ unless finished.has_key?(object)
+ Puppet.debug "Finishing %s" % object.name
+ object.finish
+ finished[object] = true
+ end
+ end
+ end
self.mkdepends
@finalized = true
@@ -1103,7 +1113,7 @@ class Type < Puppet::Element
end
}
- self.setdefaults
+ #self.setdefaults
if hash.length > 0
self.debug hash.inspect
@@ -1118,8 +1128,6 @@ class Type < Puppet::Element
if self.respond_to?(:validate)
self.validate
end
-
- self.autorequire
end
# Figure out of there are any objects we can automatically add as
@@ -1152,6 +1160,12 @@ class Type < Puppet::Element
}
end
+ # Set up all of our autorequires.
+ def finish
+ self.setdefaults
+ self.autorequire
+ end
+
# Is the specified parameter set?
def attrset?(type, attr)
case type
diff --git a/lib/puppet/type/pfile/create.rb b/lib/puppet/type/pfile/create.rb
index 449978de7..4b7ee1e15 100755
--- a/lib/puppet/type/pfile/create.rb
+++ b/lib/puppet/type/pfile/create.rb
@@ -10,14 +10,14 @@ module Puppet
# default to just about anything meaning 'true'
case value
when "false", false, nil:
- return false
+ false
when "true", true, "file", "plain", /^f/:
- return "file"
+ "file"
when "directory", /^d/:
- return "directory"
+ "directory"
when :notfound:
# this is where a creation is being rolled back
- return :notfound
+ :notfound
else
raise Puppet::Error, "Cannot create files of type %s" % value
end
@@ -36,6 +36,24 @@ module Puppet
def sync
event = nil
+ basedir = File.dirname(@parent.name)
+
+ if ! FileTest.exists?(basedir)
+ raise Puppet::Error,
+ "Can not create %s; parent directory does not exist" %
+ @parent.name
+ elsif ! FileTest.directory?(basedir)
+ raise Puppet::Error,
+ "Can not create %s; %s is not a directory" %
+ [@parent.name, dirname]
+ end
+
+ self.retrieve
+ if self.insync?
+ self.info "already in sync"
+ return nil
+ end
+
mode = @parent.should(:mode)
# First, determine if a user has been specified and if so if