summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorLuke Kanies <luke@reductivelabs.com>2010-01-07 13:08:50 -0800
committertest branch <puppet-dev@googlegroups.com>2010-02-17 06:50:53 -0800
commit67ef78d9f231661d0fdd6260d470cf0d06f1bac2 (patch)
tree0fd49958832f3da98476c36fb9d8e4160f95873e /lib/puppet
parentb82b4ef04282ca0006931562f60459a1591b6268 (diff)
downloadpuppet-67ef78d9f231661d0fdd6260d470cf0d06f1bac2.tar.gz
puppet-67ef78d9f231661d0fdd6260d470cf0d06f1bac2.tar.xz
puppet-67ef78d9f231661d0fdd6260d470cf0d06f1bac2.zip
Removing Interpreter class
It's no longer necessary, given the new ResourceTypeCollection class. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/application/main.rb2
-rw-r--r--lib/puppet/application/server.rb2
-rw-r--r--lib/puppet/indirector/catalog/compiler.rb17
-rw-r--r--lib/puppet/network/handler/master.rb3
-rw-r--r--lib/puppet/parser.rb4
-rw-r--r--lib/puppet/parser/compiler.rb7
-rw-r--r--lib/puppet/parser/grammar.ra1
-rw-r--r--lib/puppet/parser/interpreter.rb69
-rw-r--r--lib/puppet/parser/parser.rb5
9 files changed, 16 insertions, 94 deletions
diff --git a/lib/puppet/application/main.rb b/lib/puppet/application/main.rb
index 5eab81ae6..3813df612 100644
--- a/lib/puppet/application/main.rb
+++ b/lib/puppet/application/main.rb
@@ -72,7 +72,7 @@ Puppet::Application.new(:main) do
Puppet[:manifest] = ARGV.shift
end
begin
- Puppet::Parser::Interpreter.new.parser(Puppet[:environment])
+ Puppet::Parser::ResourceTypeCollection.new(Puppet[:environment]).perform_initial_import
rescue => detail
Puppet.err detail
exit 1
diff --git a/lib/puppet/application/server.rb b/lib/puppet/application/server.rb
index 57d29e0ee..e9253c6f9 100644
--- a/lib/puppet/application/server.rb
+++ b/lib/puppet/application/server.rb
@@ -69,7 +69,7 @@ Puppet::Application.new(:server) do
command(:parseonly) do
begin
- Puppet::Parser::Interpreter.new.parser(Puppet[:environment])
+ Puppet::Parser::ResourceTypeCollection.new(Puppet[:environment]).perform_initial_import
rescue => detail
Puppet.err detail
exit 1
diff --git a/lib/puppet/indirector/catalog/compiler.rb b/lib/puppet/indirector/catalog/compiler.rb
index ecb1c74e1..f83245a27 100644
--- a/lib/puppet/indirector/catalog/compiler.rb
+++ b/lib/puppet/indirector/catalog/compiler.rb
@@ -1,7 +1,6 @@
require 'puppet/node'
require 'puppet/resource/catalog'
require 'puppet/indirector/code'
-require 'puppet/parser/interpreter'
require 'yaml'
class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
@@ -52,14 +51,6 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
setup_database_backend if Puppet[:storeconfigs]
end
- # Create/return our interpreter.
- def interpreter
- unless defined?(@interpreter) and @interpreter
- @interpreter = create_interpreter
- end
- @interpreter
- end
-
# Is our compiler part of a network, or are we just local?
def networked?
$0 =~ /puppetmasterd/
@@ -75,7 +66,6 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
# Compile the actual catalog.
def compile(node)
- # Ask the interpreter to compile the catalog.
str = "Compiled catalog for %s" % node.name
if node.environment
str += " in environment %s" % node.environment
@@ -86,7 +76,7 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
benchmark(loglevel, "Compiled catalog for %s" % node.name) do
begin
- config = interpreter.compile(node)
+ return Puppet::Parser::Compiler.compile(node)
rescue Puppet::Error => detail
Puppet.err(detail.to_s) if networked?
raise
@@ -96,11 +86,6 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
return config
end
- # Create our interpreter object.
- def create_interpreter
- return Puppet::Parser::Interpreter.new
- end
-
# Turn our host name into a node object.
def find_node(name)
begin
diff --git a/lib/puppet/network/handler/master.rb b/lib/puppet/network/handler/master.rb
index e21e1e6e3..d123fd6fc 100644
--- a/lib/puppet/network/handler/master.rb
+++ b/lib/puppet/network/handler/master.rb
@@ -1,6 +1,5 @@
require 'openssl'
require 'puppet'
-require 'puppet/parser/interpreter'
require 'puppet/sslcertificates'
require 'xmlrpc/server'
require 'yaml'
@@ -44,8 +43,6 @@ class Puppet::Network::Handler
@ca = nil
end
- Puppet.debug("Creating interpreter")
-
# This is only used by the cfengine module, or if --loadclasses was
# specified in +puppet+.
if hash.include?(:Classes)
diff --git a/lib/puppet/parser.rb b/lib/puppet/parser.rb
new file mode 100644
index 000000000..3eda73885
--- /dev/null
+++ b/lib/puppet/parser.rb
@@ -0,0 +1,4 @@
+require 'puppet/parser/parser'
+require 'puppet/parser/compiler'
+require 'puppet/parser/resource_type_collection'
+
diff --git a/lib/puppet/parser/compiler.rb b/lib/puppet/parser/compiler.rb
index f9c8f70ae..25b064195 100644
--- a/lib/puppet/parser/compiler.rb
+++ b/lib/puppet/parser/compiler.rb
@@ -14,6 +14,13 @@ class Puppet::Parser::Compiler
include Puppet::Util::Errors
include Puppet::Parser::ResourceTypeCollectionHelper
+ def self.compile(node)
+ new(node).compile.to_resource
+ rescue => detail
+ puts detail.backtrace if Puppet[:trace]
+ raise Puppet::Error, "#{detail} on node #{node.name}"
+ end
+
attr_reader :node, :facts, :collections, :catalog, :node_scope, :resources
# Add a collection to the global list.
diff --git a/lib/puppet/parser/grammar.ra b/lib/puppet/parser/grammar.ra
index 76a82e38e..0e090187d 100644
--- a/lib/puppet/parser/grammar.ra
+++ b/lib/puppet/parser/grammar.ra
@@ -838,7 +838,6 @@ require 'puppet'
require 'puppet/util/loadedfile'
require 'puppet/parser/lexer'
require 'puppet/parser/ast'
-#require 'puppet/parser/interpreter'
module Puppet
class ParseError < Puppet::Error; end
diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb
deleted file mode 100644
index eea9afcad..000000000
--- a/lib/puppet/parser/interpreter.rb
+++ /dev/null
@@ -1,69 +0,0 @@
-require 'puppet'
-require 'timeout'
-require 'puppet/rails'
-require 'puppet/util/methodhelper'
-require 'puppet/parser/parser'
-require 'puppet/parser/compiler'
-require 'puppet/parser/scope'
-
-# The interpreter is a very simple entry-point class that
-# manages the existence of the parser (e.g., replacing it
-# when files are reparsed). You can feed it a node and
-# get the node's catalog back.
-class Puppet::Parser::Interpreter
- include Puppet::Util
-
- attr_accessor :usenodes
-
- include Puppet::Util::Errors
-
- # evaluate our whole tree
- def compile(node)
- begin
- return Puppet::Parser::Compiler.new(node).compile.to_resource
- rescue => detail
- puts detail.backtrace if Puppet[:trace]
- raise Puppet::Error, detail.to_s + " on node %s" % node.name
- end
- end
-
- # create our interpreter
- def initialize
- @parsers = {}
- end
-
- # Return the parser for a specific environment.
- def parser(environment)
- if ! @parsers[environment] or @parsers[environment].reparse?
- # This will throw an exception if it does not succeed.
- @parsers[environment] = create_parser(environment)
- end
- @parsers[environment]
- end
-
- private
-
- # Create a new parser object and pre-parse the configuration.
- def create_parser(environment)
- begin
- parser = Puppet::Parser::Parser.new(environment)
- if code = Puppet.settings.uninterpolated_value(:code, environment) and code != ""
- parser.string = code
- else
- file = Puppet.settings.value(:manifest, environment)
- parser.file = file
- end
- parser.parse
- return parser
- rescue => detail
- msg = "Could not parse"
- if environment and environment != ""
- msg += " for environment %s" % environment
- end
- msg += ": %s" % detail.to_s
- error = Puppet::Error.new(msg)
- error.set_backtrace(detail.backtrace)
- raise error
- end
- end
-end
diff --git a/lib/puppet/parser/parser.rb b/lib/puppet/parser/parser.rb
index 7e9235f66..a3dc5be9b 100644
--- a/lib/puppet/parser/parser.rb
+++ b/lib/puppet/parser/parser.rb
@@ -11,7 +11,6 @@ require 'puppet'
require 'puppet/util/loadedfile'
require 'puppet/parser/lexer'
require 'puppet/parser/ast'
-#require 'puppet/parser/interpreter'
module Puppet
class ParseError < Puppet::Error; end
@@ -29,7 +28,7 @@ module Puppet
class Parser < Racc::Parser
-module_eval <<'..end grammar.ra modeval..id884310a196', 'grammar.ra', 853
+module_eval <<'..end grammar.ra modeval..id8da59540c6', 'grammar.ra', 852
# It got too annoying having code in a file that needs to be compiled.
require 'puppet/parser/parser_support'
@@ -41,7 +40,7 @@ require 'puppet/parser/parser_support'
# $Id$
-..end grammar.ra modeval..id884310a196
+..end grammar.ra modeval..id8da59540c6
##### racc 1.4.5 generates ###