summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-01-04 06:44:01 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-01-04 06:44:01 +0000
commitf4b2e13dfbfa00c40400d979275b6b98bff05f4f (patch)
treecc408a1ce448d65b492d3902988b2f3349b606c5 /lib
parent098081d88fe17b221bad00c17ccff42324823a7a (diff)
downloadpuppet-f4b2e13dfbfa00c40400d979275b6b98bff05f4f.tar.gz
puppet-f4b2e13dfbfa00c40400d979275b6b98bff05f4f.tar.xz
puppet-f4b2e13dfbfa00c40400d979275b6b98bff05f4f.zip
Fixing #391. Keeping track of times of compile and freshness checks.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2034 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/parser/resource.rb2
-rw-r--r--lib/puppet/rails/database/schema.rb4
-rw-r--r--lib/puppet/rails/host.rb9
-rw-r--r--lib/puppet/server/master.rb8
4 files changed, 20 insertions, 3 deletions
diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb
index 4a1b2d12a..31d43bd18 100644
--- a/lib/puppet/parser/resource.rb
+++ b/lib/puppet/parser/resource.rb
@@ -191,7 +191,7 @@ class Puppet::Parser::Resource
true
elsif paramcheck?
self.fail Puppet::ParseError, "Invalid parameter '%s' for type '%s'" %
- [param.inspect, @ref.type]
+ [param, @ref.type]
end
end
diff --git a/lib/puppet/rails/database/schema.rb b/lib/puppet/rails/database/schema.rb
index 878d93825..9397916c2 100644
--- a/lib/puppet/rails/database/schema.rb
+++ b/lib/puppet/rails/database/schema.rb
@@ -32,7 +32,9 @@ class Puppet::Rails::Schema
create_table :hosts do |t|
t.column :name, :string, :null => false
t.column :ip, :string
- t.column :connect, :date
+ t.column :last_compile, :date
+ t.column :last_freshcheck, :date
+ t.column :last_report, :date
#Use updated_at to automatically add timestamp on save.
t.column :updated_at, :date
t.column :source_file_id, :integer
diff --git a/lib/puppet/rails/host.rb b/lib/puppet/rails/host.rb
index 0b88afe62..3efdfa9df 100644
--- a/lib/puppet/rails/host.rb
+++ b/lib/puppet/rails/host.rb
@@ -48,6 +48,8 @@ class Puppet::Rails::Host < ActiveRecord::Base
host.setresources(hash[:resources])
+ host.last_compile = Time.now
+
host.save
return host
@@ -56,7 +58,7 @@ class Puppet::Rails::Host < ActiveRecord::Base
def tags=(tags)
tags.each do |tag|
self.tag_with tag
- end
+ end
end
# Return the value of a fact.
@@ -87,6 +89,11 @@ class Puppet::Rails::Host < ActiveRecord::Base
resource.to_rails(self)
end
end
+
+ def update_connect_time
+ self.last_connect = Time.now
+ save
+ end
end
# $Id$
diff --git a/lib/puppet/server/master.rb b/lib/puppet/server/master.rb
index 79fe53da0..cda6027d0 100644
--- a/lib/puppet/server/master.rb
+++ b/lib/puppet/server/master.rb
@@ -55,6 +55,14 @@ class Server
# Tell a client whether there's a fresh config for it
def freshness(client = nil, clientip = nil)
+ if Puppet.features.rails? and Puppet[:storeconfigs]
+ host = Puppet::Rails::Host.find_or_create_by_name(client)
+ host.last_freshcheck = Time.now
+ if clientip and (! host.ip or host.ip == "")
+ host.ip = clientip
+ end
+ host.save
+ end
if defined? @interpreter
return @interpreter.parsedate
else