summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-04-11 16:12:38 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-04-11 16:12:38 +0000
commitde0d1ddf13a8486ee6fe253e8c5a242aeca38c6a (patch)
tree966abd3ddee38fb78ffe3786c16b0f081e397afe
parentbca4f5ea9df7c7374686fdee0ee672ed470ef91c (diff)
downloadpuppet-de0d1ddf13a8486ee6fe253e8c5a242aeca38c6a.tar.gz
puppet-de0d1ddf13a8486ee6fe253e8c5a242aeca38c6a.tar.xz
puppet-de0d1ddf13a8486ee6fe253e8c5a242aeca38c6a.zip
Adding a few informative facts on the server side: serverversion, servername, serverip. And only printing the parse time in the interpreter if it is not a local connection.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1102 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r--lib/puppet/parser/interpreter.rb8
-rw-r--r--lib/puppet/server/master.rb16
-rw-r--r--test/server/master.rb23
3 files changed, 44 insertions, 3 deletions
diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb
index 5f5ecbe1f..f443ee3cd 100644
--- a/lib/puppet/parser/interpreter.rb
+++ b/lib/puppet/parser/interpreter.rb
@@ -77,6 +77,8 @@ module Puppet
# by the cfengine module.
@classes = hash[:Classes] || []
+ @local = hash[:Local] || false
+
# Create our parser object
parsefiles
end
@@ -292,8 +294,12 @@ module Puppet
@parser.file = @file
end
- @ast = benchmark(:info, "Parsed manifest") do
+ if @local
@parser.parse
+ else
+ @ast = benchmark(:info, "Parsed manifest") do
+ @parser.parse
+ end
end
# Mark when we parsed, so we can check freshness
diff --git a/lib/puppet/server/master.rb b/lib/puppet/server/master.rb
index bdae877a9..95d81cdf6 100644
--- a/lib/puppet/server/master.rb
+++ b/lib/puppet/server/master.rb
@@ -19,6 +19,16 @@ class Server
iface.add_method("int freshness()")
}
+ # FIXME At some point, this should be autodocumenting.
+ def addfacts(facts)
+ # Add our server version to the fact list
+ facts["serverversion"] = Puppet.version.to_s
+
+ # And then add the server name and IP
+ facts["servername"] = Facter["hostname"].value
+ facts["serverip"] = Facter["ipaddress"].value
+ end
+
def filetimeout
@interpreter.filetimeout
end
@@ -52,6 +62,8 @@ class Server
@local = false
end
+ args[:Local] = @local
+
if hash.include?(:CA) and hash[:CA]
@ca = Puppet::SSLCertificates::CA.new()
else
@@ -115,8 +127,8 @@ class Server
clientip = facts["ipaddress"]
end
- # Add our server version to the fact list
- facts["serverversion"] = Puppet.version.to_s
+ # Add any server-side facts to our server.
+ addfacts(facts)
retobjects = nil
diff --git a/test/server/master.rb b/test/server/master.rb
index bd097a007..e3f065087 100644
--- a/test/server/master.rb
+++ b/test/server/master.rb
@@ -173,6 +173,29 @@ class TestMaster < Test::Unit::TestCase
assert(FileTest.exists?(file2), "Second file %s does not exist" % file2)
end
+ def test_addfacts
+ master = nil
+ file = mktestmanifest()
+ # create our master
+ assert_nothing_raised() {
+ # this is the default server setup
+ master = Puppet::Server::Master.new(
+ :Manifest => file,
+ :UseNodes => false,
+ :Local => true
+ )
+ }
+
+ facts = {}
+
+ assert_nothing_raised {
+ master.addfacts(facts)
+ }
+
+ %w{serverversion servername serverip}.each do |fact|
+ assert(facts.include?(fact), "Fact %s was not set" % fact)
+ end
+ end
end
# $Id$