summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2005-07-11 20:21:30 +0000
committerLuke Kanies <luke@madstop.com>2005-07-11 20:21:30 +0000
commit6e9975ce229f889784f45d5b5c3434db3e0da30a (patch)
tree543f176e3bc0cc0fa0c7c5ce2f4791a3b822a40e /lib/puppet
parent256b84e9fae36865ba9eae247ffceae91ce36aa3 (diff)
found a bunch of bugs in Puppet::Storage, plus some bugs in how file recursion was being tested and thus some real bugs in the system
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@357 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/client.rb8
-rw-r--r--lib/puppet/storage.rb1
-rw-r--r--lib/puppet/type.rb6
-rw-r--r--lib/puppet/type/pfile.rb19
4 files changed, 26 insertions, 8 deletions
diff --git a/lib/puppet/client.rb b/lib/puppet/client.rb
index 1768ca466..3689b2033 100644
--- a/lib/puppet/client.rb
+++ b/lib/puppet/client.rb
@@ -69,11 +69,18 @@ module Puppet
# manipulations
def config(tree)
Puppet.debug("Calling config")
+
+ # XXX this is kind of a problem; if the user changes the state file
+ # after this, then we have to reload the file and everything...
+ Puppet::Storage.init
+ Puppet::Storage.load
+
container = Marshal::load(tree).to_type
# this is a gross hack... but i don't see a good way around it
# set all of the variables to empty
Puppet::Transaction.init
+
# for now we just evaluate the top-level container, but eventually
# there will be schedules and such associated with each object,
# and probably with the container itself
@@ -87,6 +94,7 @@ module Puppet
Metric.store
Metric.graph
end
+ Puppet::Storage.store
self.shutdown
end
diff --git a/lib/puppet/storage.rb b/lib/puppet/storage.rb
index 5dac7dc35..67969c76f 100644
--- a/lib/puppet/storage.rb
+++ b/lib/puppet/storage.rb
@@ -15,6 +15,7 @@ module Puppet
end
def Storage.init
+ Puppet.debug "Initializing Storage"
@@state = Hash.new { |hash,key|
hash[key] = Hash.new(nil)
}
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index 652366dcb..bc54b31cd 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -398,6 +398,8 @@ class Type < Puppet::Element
#---------------------------------------------------------------
# this abstracts accessing parameters and states, and normalizes
# access to always be symbols, not strings
+ # XXX this returns a _value_, not an object
+ # if you want a state object, use <type>.state(<state>)
def [](name)
if name.is_a?(String)
name = name.intern
@@ -545,8 +547,6 @@ class Type < Puppet::Element
hash.delete(namevar)
# else something's screwy
else
- p hash
- p namevar
raise TypeError.new("A name must be provided to %s at initialization time" %
self.class)
end
@@ -733,7 +733,7 @@ class Type < Puppet::Element
# now record how many changes we've resulted in
Puppet::Metric.add(self.class,self,:changes,changes.length)
- return changes
+ return changes.flatten
end
#---------------------------------------------------------------
diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb
index dbd54404b..6b4ecbc5d 100644
--- a/lib/puppet/type/pfile.rb
+++ b/lib/puppet/type/pfile.rb
@@ -55,13 +55,15 @@ module Puppet
if hash = state[self.parent[:path]]
if hash.include?(@checktype)
@should = hash[@checktype]
+ Puppet.warning "Found checksum %s for %s" %
+ [@should,self.parent[:path]]
else
- Puppet.debug "Found checksum for %s but not of type %s" %
+ Puppet.warning "Found checksum for %s but not of type %s" %
[self.parent[:path],@checktype]
@should = nil
end
else
- Puppet.debug "No checksum for %s" % self.parent[:path]
+ Puppet.warning "No checksum for %s" % self.parent[:path]
end
end
@@ -101,9 +103,9 @@ module Puppet
}
end
when "timestamp","mtime":
- sum = File.stat(self.parent[:path]).mtime
+ sum = File.stat(self.parent[:path]).mtime.to_s
when "time":
- sum = File.stat(self.parent[:path]).ctime
+ sum = File.stat(self.parent[:path]).ctime.to_s
end
self.is = sum
@@ -115,6 +117,9 @@ module Puppet
# at this point, we don't actually modify the system, we just kick
# off an event if we detect a change
def sync
+ if @is.nil?
+ Puppet.err "@is is nil"
+ end
if self.updatesum
return :file_modified
else
@@ -125,16 +130,20 @@ module Puppet
def updatesum
state = Puppet::Storage.state(self)
unless state.include?(self.parent[:path])
+ Puppet.debug "Initializing state hash for %s" %
+ self.parent[:path]
+
state[self.parent[:path]] = Hash.new
end
# if we're replacing, vs. updating
if state[self.parent[:path]].include?(@checktype)
Puppet.debug "Replacing checksum %s with %s" %
[state[self.parent[:path]][@checktype],@is]
+ Puppet.debug "@is: %s; @should: %s" % [@is,@should]
result = true
else
Puppet.debug "Creating checksum %s for %s of type %s" %
- [@is,self.parent[:path],@checktype]
+ [self.is,self.parent[:path],@checktype]
result = false
end
state[self.parent[:path]][@checktype] = @is