summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG6
-rw-r--r--conf/namespaceauth.conf20
-rw-r--r--lib/puppet/metatype/closure.rb4
-rw-r--r--lib/puppet/node/catalog.rb2
-rw-r--r--lib/puppet/parser/ast/definition.rb3
-rw-r--r--lib/puppet/parser/ast/hostclass.rb9
-rw-r--r--lib/puppet/parser/interpreter.rb4
-rw-r--r--lib/puppet/parser/resource.rb9
-rw-r--r--lib/puppet/provider/interface/redhat.rb130
-rwxr-xr-xlib/puppet/type/exec.rb5
-rwxr-xr-xlib/puppet/type/mailalias.rb2
-rw-r--r--lib/puppet/type/package.rb8
-rw-r--r--lib/puppet/type/service.rb9
-rwxr-xr-xspec/unit/node/catalog.rb8
-rwxr-xr-xspec/unit/parser/ast/hostclass.rb8
-rwxr-xr-xspec/unit/parser/resource.rb211
-rwxr-xr-xspec/unit/ral/types/package.rb4
-rwxr-xr-xspec/unit/ral/types/service.rb15
-rwxr-xr-xtest/ral/types/exec.rb4
19 files changed, 265 insertions, 196 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 234b24393..59dde24a2 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,9 @@
+ Removed the loglevels from the valid values for `logoutput`
+ in the Exec resource type -- the log levels are specified
+ using the `loglevel` parameter, not `logoutput`. This never
+ worked, or at least hasn`t for ages, and now the docs are
+ just correct.
+
Somewhat refactored fileserving so that it no longer caches
any objects, nor does it use Puppet's RAL resources. In the
process, I fixed #894 (you can now copy links) and refactored
diff --git a/conf/namespaceauth.conf b/conf/namespaceauth.conf
new file mode 100644
index 000000000..837235769
--- /dev/null
+++ b/conf/namespaceauth.conf
@@ -0,0 +1,20 @@
+# This is an example namespaceauth.conf file,
+# which you'll need if you want to start a client
+# in --listen mode.
+[fileserver]
+ allow *.domain.com
+
+[puppetmaster]
+ allow *.domain.com
+
+[puppetrunner]
+ allow culain.domain.com
+
+[puppetbucket]
+ allow *.domain.com
+
+[puppetreports]
+ allow *.domain.com
+
+[resource]
+ allow server.domain.com
diff --git a/lib/puppet/metatype/closure.rb b/lib/puppet/metatype/closure.rb
index 259854411..673a2359d 100644
--- a/lib/puppet/metatype/closure.rb
+++ b/lib/puppet/metatype/closure.rb
@@ -20,6 +20,10 @@ class Puppet::Type
end
end
+ def isomorphic?
+ self.class.isomorphic?
+ end
+
# is the instance a managed instance? A 'yes' here means that
# the instance was created from the language, vs. being created
# in order resolve other questions, such as finding a package
diff --git a/lib/puppet/node/catalog.rb b/lib/puppet/node/catalog.rb
index d680de9a0..f885a41ee 100644
--- a/lib/puppet/node/catalog.rb
+++ b/lib/puppet/node/catalog.rb
@@ -73,7 +73,7 @@ class Puppet::Node::Catalog < Puppet::PGraph
# If the name and title differ, set up an alias
#self.alias(resource, resource.name) if resource.respond_to?(:name) and resource.respond_to?(:title) and resource.name != resource.title
if resource.respond_to?(:name) and resource.respond_to?(:title) and resource.name != resource.title
- self.alias(resource, resource.name) if resource.class.isomorphic?
+ self.alias(resource, resource.name) if resource.isomorphic?
end
resource.catalog = self if resource.respond_to?(:catalog=) and ! is_relationship_graph
diff --git a/lib/puppet/parser/ast/definition.rb b/lib/puppet/parser/ast/definition.rb
index 2b7506446..0c65c702c 100644
--- a/lib/puppet/parser/ast/definition.rb
+++ b/lib/puppet/parser/ast/definition.rb
@@ -24,9 +24,6 @@ class Puppet::Parser::AST::Definition < Puppet::Parser::AST::Branch
# Create a resource that knows how to evaluate our actual code.
def evaluate(scope)
- # Do nothing if the resource already exists; this provides the singleton nature classes need.
- return if scope.catalog.resource(self.class.name, self.classname)
-
resource = Puppet::Parser::Resource.new(:type => self.class.name, :title => self.classname, :scope => scope, :source => scope.source)
scope.catalog.tag(*resource.tags)
diff --git a/lib/puppet/parser/ast/hostclass.rb b/lib/puppet/parser/ast/hostclass.rb
index 8d4d01660..7f89f8151 100644
--- a/lib/puppet/parser/ast/hostclass.rb
+++ b/lib/puppet/parser/ast/hostclass.rb
@@ -21,7 +21,14 @@ class Puppet::Parser::AST::HostClass < Puppet::Parser::AST::Definition
# Make sure our parent class has been evaluated, if we have one.
def evaluate(scope)
if parentclass and ! scope.catalog.resource(self.class.name, parentclass)
- resource = parentobj.evaluate(scope)
+ parent_resource = parentobj.evaluate(scope)
+ end
+
+ # Do nothing if the resource already exists; this makes sure we don't
+ # get multiple copies of the class resource, which helps provide the
+ # singleton nature of classes.
+ if resource = scope.catalog.resource(self.class.name, self.classname)
+ return resource
end
super
diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb
index 33f66e8c2..d4655c403 100644
--- a/lib/puppet/parser/interpreter.rb
+++ b/lib/puppet/parser/interpreter.rb
@@ -28,10 +28,8 @@ class Puppet::Parser::Interpreter
begin
return Puppet::Parser::Compiler.new(node, env_parser).compile
rescue => detail
+ puts detail.backtrace if Puppet[:trace]
raise Puppet::Error, detail.to_s + " on node %s" % node.name
- if Puppet[:trace]
- puts detail.backtrace
- end
end
end
diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb
index fb0799011..46be89ca2 100644
--- a/lib/puppet/parser/resource.rb
+++ b/lib/puppet/parser/resource.rb
@@ -133,6 +133,15 @@ class Puppet::Parser::Resource
tag(@ref.title) if valid_tag?(@ref.title.to_s)
end
+ # Is this resource modeling an isomorphic resource type?
+ def isomorphic?
+ if builtin?
+ return @ref.builtintype.isomorphic?
+ else
+ return true
+ end
+ end
+
# Merge an override resource in. This will throw exceptions if
# any overrides aren't allowed.
def merge(resource)
diff --git a/lib/puppet/provider/interface/redhat.rb b/lib/puppet/provider/interface/redhat.rb
index aa217620e..4a9fcb491 100644
--- a/lib/puppet/provider/interface/redhat.rb
+++ b/lib/puppet/provider/interface/redhat.rb
@@ -5,7 +5,7 @@ Puppet::Type.type(:interface).provide(:redhat) do
desc "Manage network interfaces on Red Hat operating systems. This provider
parses and generates configuration files in ``/etc/sysconfig/network-scripts``."
- INTERFACE_DIR = "/etc/sysconfig/network-scripts"
+ INTERFACE_DIR = "/etc/sysconfig/network-scripts"
confine :exists => INTERFACE_DIR
defaultfor :operatingsystem => [:fedora, :centos, :redhat]
@@ -43,52 +43,52 @@ NETMASK=<%= self.netmask %>
BROADCAST=
LOOPBACKDUMMY
- # maximum number of dummy interfaces
- @max_dummies = 10
+ # maximum number of dummy interfaces
+ @max_dummies = 10
- # maximum number of aliases per interface
- @max_aliases_per_iface = 10
+ # maximum number of aliases per interface
+ @max_aliases_per_iface = 10
- @@dummies = []
- @@aliases = Hash.new { |hash, key| hash[key] = [] }
+ @@dummies = []
+ @@aliases = Hash.new { |hash, key| hash[key] = [] }
- # calculate which dummy interfaces are currently already in
- # use prior to needing to call self.next_dummy later on.
- def self.instances
- # parse all of the config files at once
- Dir.glob("%s/ifcfg-*" % INTERFACE_DIR).collect do |file|
- record = parse(file)
+ # calculate which dummy interfaces are currently already in
+ # use prior to needing to call self.next_dummy later on.
+ def self.instances
+ # parse all of the config files at once
+ Dir.glob("%s/ifcfg-*" % INTERFACE_DIR).collect do |file|
+ record = parse(file)
- # store the existing dummy interfaces
+ # store the existing dummy interfaces
@@dummies << record[:ifnum] if (record[:interface_type] == :dummy and ! @@dummies.include?(record[:ifnum]))
@@aliases[record[:interface]] << record[:ifnum] if record[:interface_type] == :alias
new(record)
- end
- end
-
- # return the next avaliable dummy interface number, in the case where
- # ifnum is not manually specified
- def self.next_dummy
- @max_dummies.times do |i|
- unless @@dummies.include?(i.to_s)
- @@dummies << i.to_s
- return i.to_s
- end
- end
- end
-
- # return the next available alias on a given interface, in the case
- # where ifnum if not manually specified
- def self.next_alias(interface)
- @max_aliases_per_iface.times do |i|
- unless @@aliases[interface].include?(i.to_s)
- @@aliases[interface] << i.to_s
- return i.to_s
- end
- end
- end
+ end
+ end
+
+ # return the next avaliable dummy interface number, in the case where
+ # ifnum is not manually specified
+ def self.next_dummy
+ @max_dummies.times do |i|
+ unless @@dummies.include?(i.to_s)
+ @@dummies << i.to_s
+ return i.to_s
+ end
+ end
+ end
+
+ # return the next available alias on a given interface, in the case
+ # where ifnum if not manually specified
+ def self.next_alias(interface)
+ @max_aliases_per_iface.times do |i|
+ unless @@aliases[interface].include?(i.to_s)
+ @@aliases[interface] << i.to_s
+ return i.to_s
+ end
+ end
+ end
# base the ifnum, for dummy / loopback interface in linux
# on the last octect of the IP address
@@ -139,14 +139,14 @@ LOOPBACKDUMMY
# on whether we are adding an alias to a real interface, or a loopback
# address (also dummy) on linux. For linux it's quite involved, and we
# will use an ERB template
- def generate
+ def generate
itype = self.interface_type == :alias ? :alias : :normal
self.class.template(itype).result(binding)
- end
+ end
# Where should the file be written out?
- # This defaults to INTERFACE_DIR/ifcfg-<namevar>, but can have a
- # more symbolic name by setting interface_desc in the type.
+ # This defaults to INTERFACE_DIR/ifcfg-<namevar>, but can have a
+ # more symbolic name by setting interface_desc in the type.
def file_path
if resource and val = resource[:interface_desc]
desc = val
@@ -185,16 +185,16 @@ LOOPBACKDUMMY
end
end
- # create the device name, so this based on the IP, and interface + type
- def device
- case @resource.should(:interface_type)
- when :loopback
- @property_hash[:ifnum] ||= self.class.next_dummy
- return "dummy" + @property_hash[:ifnum]
- when :alias
- @property_hash[:ifnum] ||= self.class.next_alias(@resource[:interface])
- return @resource[:interface] + ":" + @property_hash[:ifnum]
- end
+ # create the device name, so this based on the IP, and interface + type
+ def device
+ case @resource.should(:interface_type)
+ when :loopback
+ @property_hash[:ifnum] ||= self.class.next_dummy
+ return "dummy" + @property_hash[:ifnum]
+ when :alias
+ @property_hash[:ifnum] ||= self.class.next_alias(@resource[:interface])
+ return @resource[:interface] + ":" + @property_hash[:ifnum]
+ end
end
# Set the name to our ip address.
@@ -202,19 +202,19 @@ LOOPBACKDUMMY
@property_hash[:name] = value
end
- # whether the device is to be brought up on boot or not. converts
- # the true / false of the type, into yes / no values respectively
- # writing out the ifcfg-* files
- def on_boot
- case @property_hash[:onboot].to_s
- when "true"
- return "yes"
- when "false"
- return "no"
- else
- return "neither"
- end
- end
+ # whether the device is to be brought up on boot or not. converts
+ # the true / false of the type, into yes / no values respectively
+ # writing out the ifcfg-* files
+ def on_boot
+ case @property_hash[:onboot].to_s
+ when "true"
+ return "yes"
+ when "false"
+ return "no"
+ else
+ return "neither"
+ end
+ end
# Mark whether the interface should be started on boot.
def on_boot=(value)
diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb
index f8049236f..2772b54a8 100755
--- a/lib/puppet/type/exec.rb
+++ b/lib/puppet/type/exec.rb
@@ -211,10 +211,7 @@ module Puppet
log the output when the command reports an error. Values are
**true**, *false*, *on_failure*, and any legal log level."
- values = [:true, :false, :on_failure]
- # And all of the log levels
- Puppet::Util::Log.eachlevel { |level| values << level }
- newvalues(*values)
+ newvalues(:true, :false, :on_failure)
end
newparam(:refresh) do
diff --git a/lib/puppet/type/mailalias.rb b/lib/puppet/type/mailalias.rb
index 92f609267..50ca26ef6 100755
--- a/lib/puppet/type/mailalias.rb
+++ b/lib/puppet/type/mailalias.rb
@@ -9,7 +9,7 @@ module Puppet
end
newproperty(:recipient, :array_matching => :all) do
- desc "Where email should should be sent. Multiple values
+ desc "Where email should be sent. Multiple values
should be specified as an array."
def is_to_s(value)
diff --git a/lib/puppet/type/package.rb b/lib/puppet/type/package.rb
index ee2871ce2..f004f7c42 100644
--- a/lib/puppet/type/package.rb
+++ b/lib/puppet/type/package.rb
@@ -211,14 +211,6 @@ module Puppet
desc "Where to find the actual package. This must be a local file
(or on a network file system) or a URL that your specific
packaging type understands; Puppet will not retrieve files for you."
-
- validate do |value|
- unless value =~ /^#{File::SEPARATOR}/ or value =~ /\w+:\/\//
- self.fail(
- "Package sources must be fully qualified files or URLs, depending on the platform."
- )
- end
- end
end
newparam(:instance) do
desc "A read-only parameter set by the package."
diff --git a/lib/puppet/type/service.rb b/lib/puppet/type/service.rb
index c41a7883b..1b625cc41 100644
--- a/lib/puppet/type/service.rb
+++ b/lib/puppet/type/service.rb
@@ -28,6 +28,8 @@ module Puppet
feature :enableable, "The provider can enable and disable the service",
:methods => [:disable, :enable, :enabled?]
+ feature :controllable, "The provider uses a control variable."
+
newproperty(:enable, :required_features => :enableable) do
desc "Whether a service should be enabled to start at boot.
This property behaves quite differently depending on the platform;
@@ -163,6 +165,13 @@ module Puppet
desc "Specify a *stop* command manually."
end
+ newparam(:control) do
+ desc "The control variable used to manage services (originally for HP-UX).
+ Defaults to the upcased service name plus ``START`` replacing dots with
+ underscores, for those providers that support the ``controllable`` feature."
+ defaultto { resource.name.gsub(".","_").upcase + "_START" if resource.provider.controllable? }
+ end
+
newparam :hasrestart do
desc "Specify that an init script has a ``restart`` option. Otherwise,
the init script's ``stop`` and ``start`` methods are used."
diff --git a/spec/unit/node/catalog.rb b/spec/unit/node/catalog.rb
index b1bf5abaa..604dabbb6 100755
--- a/spec/unit/node/catalog.rb
+++ b/spec/unit/node/catalog.rb
@@ -476,17 +476,19 @@ describe Puppet::Node::Catalog, " when functioning as a resource container" do
it "should add an alias for the namevar when the title and name differ on isomorphic resource types" do
resource = Puppet::Type.type(:file).create :path => "/something", :title => "other", :content => "blah"
+ resource.expects(:isomorphic?).returns(true)
@catalog.add_resource(resource)
@catalog.resource(:file, "other").should equal(resource)
@catalog.resource(:file, "/something").ref.should == resource.ref
end
it "should not add an alias for the namevar when the title and name differ on non-isomorphic resource types" do
- resource = Puppet::Type.type(:exec).create :command => "/bin/true", :title => "other"
+ resource = Puppet::Type.type(:file).create :path => "/something", :title => "other", :content => "blah"
+ resource.expects(:isomorphic?).returns(false)
@catalog.add_resource(resource)
- @catalog.resource(:exec, resource.title).should equal(resource)
+ @catalog.resource(:file, resource.title).should equal(resource)
# We can't use .should here, because the resources respond to that method.
- if @catalog.resource(:exec, resource.name)
+ if @catalog.resource(:file, resource.name)
raise "Aliased non-isomorphic resource"
end
end
diff --git a/spec/unit/parser/ast/hostclass.rb b/spec/unit/parser/ast/hostclass.rb
index a53c3b092..0abc174d9 100755
--- a/spec/unit/parser/ast/hostclass.rb
+++ b/spec/unit/parser/ast/hostclass.rb
@@ -42,6 +42,12 @@ describe Puppet::Parser::AST::HostClass do
@top.evaluate(@scope)
end
+ it "should return the existing resource when not creating a new one" do
+ @compiler.catalog.expects(:resource).with(:class, "top").returns("something")
+ @compiler.catalog.expects(:add_resource).never
+ @top.evaluate(@scope).should == "something"
+ end
+
it "should not create a new parent resource if one already exists and it has a parent class" do
@top.evaluate(@scope)
@@ -126,4 +132,4 @@ describe Puppet::Parser::AST::HostClass do
@compiler.class_scope(@middle).namespaces.should be_include(@top.namespace)
end
end
-end \ No newline at end of file
+end
diff --git a/spec/unit/parser/resource.rb b/spec/unit/parser/resource.rb
index a5a49e2a6..035590341 100755
--- a/spec/unit/parser/resource.rb
+++ b/spec/unit/parser/resource.rb
@@ -5,145 +5,160 @@ require File.dirname(__FILE__) + '/../../spec_helper'
# LAK: FIXME This is just new tests for resources; I have
# not moved all tests over yet.
-describe Puppet::Parser::Resource, " when evaluating" do
+describe Puppet::Parser::Resource do
before do
- @type = Puppet::Parser::Resource
-
@parser = Puppet::Parser::Parser.new :Code => ""
@source = @parser.newclass ""
- @definition = @parser.newdefine "mydefine"
- @class = @parser.newclass "myclass"
- @nodedef = @parser.newnode("mynode")[0]
@node = Puppet::Node.new("yaynode")
@compiler = Puppet::Parser::Compiler.new(@node, @parser)
@scope = @compiler.topscope
end
- it "should evaluate the associated AST definition" do
- res = @type.new(:type => "mydefine", :title => "whatever", :scope => @scope, :source => @source)
- @definition.expects(:evaluate_code).with(res)
-
- res.evaluate
+ it "should be isomorphic if it is builtin and models an isomorphic type" do
+ Puppet::Type.type(:file).expects(:isomorphic?).returns(true)
+ @resource = Puppet::Parser::Resource.new(:type => "file", :title => "whatever", :scope => @scope, :source => @source).isomorphic?.should be_true
end
- it "should evaluate the associated AST class" do
- res = @type.new(:type => "class", :title => "myclass", :scope => @scope, :source => @source)
- @class.expects(:evaluate_code).with(res)
- res.evaluate
+ it "should not be isomorphic if it is builtin and models a non-isomorphic type" do
+ Puppet::Type.type(:file).expects(:isomorphic?).returns(false)
+ @resource = Puppet::Parser::Resource.new(:type => "file", :title => "whatever", :scope => @scope, :source => @source).isomorphic?.should be_false
end
- it "should evaluate the associated AST node" do
- res = @type.new(:type => "node", :title => "mynode", :scope => @scope, :source => @source)
- @nodedef.expects(:evaluate_code).with(res)
- res.evaluate
+ it "should be isomorphic if it is not builtin" do
+ @parser.newdefine "whatever"
+ @resource = Puppet::Parser::Resource.new(:type => "whatever", :title => "whatever", :scope => @scope, :source => @source).isomorphic?.should be_true
end
-end
-describe Puppet::Parser::Resource, " when finishing" do
- before do
- @parser = Puppet::Parser::Parser.new :Code => ""
- @source = @parser.newclass ""
- @definition = @parser.newdefine "mydefine"
- @class = @parser.newclass "myclass"
- @nodedef = @parser.newnode("mynode")[0]
- @node = Puppet::Node.new("yaynode")
- @compiler = Puppet::Parser::Compiler.new(@node, @parser)
- @scope = @compiler.topscope
+ describe "when evaluating" do
+ before do
+ @type = Puppet::Parser::Resource
- @resource = Puppet::Parser::Resource.new(:type => "mydefine", :title => "whatever", :scope => @scope, :source => @source)
- end
+ @definition = @parser.newdefine "mydefine"
+ @class = @parser.newclass "myclass"
+ @nodedef = @parser.newnode("mynode")[0]
+ end
- it "should copy metaparams from its scope" do
- @scope.setvar("noop", "true")
+ it "should evaluate the associated AST definition" do
+ res = @type.new(:type => "mydefine", :title => "whatever", :scope => @scope, :source => @source)
+ @definition.expects(:evaluate_code).with(res)
- @resource.class.publicize_methods(:add_metaparams) { @resource.add_metaparams }
+ res.evaluate
+ end
- @resource["noop"].should == "true"
+ it "should evaluate the associated AST class" do
+ res = @type.new(:type => "class", :title => "myclass", :scope => @scope, :source => @source)
+ @class.expects(:evaluate_code).with(res)
+ res.evaluate
+ end
+
+ it "should evaluate the associated AST node" do
+ res = @type.new(:type => "node", :title => "mynode", :scope => @scope, :source => @source)
+ @nodedef.expects(:evaluate_code).with(res)
+ res.evaluate
+ end
end
- it "should not copy metaparams that it already has" do
- @resource.class.publicize_methods(:set_parameter) { @resource.set_parameter("noop", "false") }
- @scope.setvar("noop", "true")
+ describe "when finishing" do
+ before do
+ @definition = @parser.newdefine "mydefine"
+ @class = @parser.newclass "myclass"
+ @nodedef = @parser.newnode("mynode")[0]
- @resource.class.publicize_methods(:add_metaparams) { @resource.add_metaparams }
+ @resource = Puppet::Parser::Resource.new(:type => "mydefine", :title => "whatever", :scope => @scope, :source => @source)
+ end
- @resource["noop"].should == "false"
- end
+ it "should copy metaparams from its scope" do
+ @scope.setvar("noop", "true")
- it "should stack relationship metaparams from its container if it already has them" do
- @resource.class.publicize_methods(:set_parameter) { @resource.set_parameter("require", "resource") }
- @scope.setvar("require", "container")
+ @resource.class.publicize_methods(:add_metaparams) { @resource.add_metaparams }
- @resource.class.publicize_methods(:add_metaparams) { @resource.add_metaparams }
+ @resource["noop"].should == "true"
+ end
- @resource["require"].sort.should == %w{container resource}
- end
+ it "should not copy metaparams that it already has" do
+ @resource.class.publicize_methods(:set_parameter) { @resource.set_parameter("noop", "false") }
+ @scope.setvar("noop", "true")
- it "should flatten the array resulting from stacking relationship metaparams" do
- @resource.class.publicize_methods(:set_parameter) { @resource.set_parameter("require", ["resource1", "resource2"]) }
- @scope.setvar("require", %w{container1 container2})
+ @resource.class.publicize_methods(:add_metaparams) { @resource.add_metaparams }
- @resource.class.publicize_methods(:add_metaparams) { @resource.add_metaparams }
+ @resource["noop"].should == "false"
+ end
- @resource["require"].sort.should == %w{container1 container2 resource1 resource2}
- end
+ it "should stack relationship metaparams from its container if it already has them" do
+ @resource.class.publicize_methods(:set_parameter) { @resource.set_parameter("require", "resource") }
+ @scope.setvar("require", "container")
- it "should add any tags from the scope resource" do
- scope_resource = stub 'scope_resource', :tags => %w{one two}
- @scope.stubs(:resource).returns(scope_resource)
+ @resource.class.publicize_methods(:add_metaparams) { @resource.add_metaparams }
- @resource.class.publicize_methods(:add_scope_tags) { @resource.add_scope_tags }
+ @resource["require"].sort.should == %w{container resource}
+ end
- @resource.tags.should be_include("one")
- @resource.tags.should be_include("two")
- end
-end
+ it "should flatten the array resulting from stacking relationship metaparams" do
+ @resource.class.publicize_methods(:set_parameter) { @resource.set_parameter("require", ["resource1", "resource2"]) }
+ @scope.setvar("require", %w{container1 container2})
-describe Puppet::Parser::Resource, "when being tagged" do
- before do
- @scope_resource = stub 'scope_resource', :tags => %w{srone srtwo}
- @scope = stub 'scope', :resource => @scope_resource
- @resource = Puppet::Parser::Resource.new(:type => "file", :title => "yay", :scope => @scope, :source => mock('source'))
- end
+ @resource.class.publicize_methods(:add_metaparams) { @resource.add_metaparams }
- it "should get tagged with the resource type" do
- @resource.tags.should be_include("file")
- end
+ @resource["require"].sort.should == %w{container1 container2 resource1 resource2}
+ end
- it "should get tagged with the title" do
- @resource.tags.should be_include("yay")
- end
+ it "should add any tags from the scope resource" do
+ scope_resource = stub 'scope_resource', :tags => %w{one two}
+ @scope.stubs(:resource).returns(scope_resource)
- it "should get tagged with each name in the title if the title is a qualified class name" do
- resource = Puppet::Parser::Resource.new(:type => "file", :title => "one::two", :scope => @scope, :source => mock('source'))
- resource.tags.should be_include("one")
- resource.tags.should be_include("two")
- end
+ @resource.class.publicize_methods(:add_scope_tags) { @resource.add_scope_tags }
- it "should get tagged with each name in the type if the type is a qualified class name" do
- resource = Puppet::Parser::Resource.new(:type => "one::two", :title => "whatever", :scope => @scope, :source => mock('source'))
- resource.tags.should be_include("one")
- resource.tags.should be_include("two")
+ @resource.tags.should be_include("one")
+ @resource.tags.should be_include("two")
+ end
end
- it "should not get tagged with non-alphanumeric titles" do
- resource = Puppet::Parser::Resource.new(:type => "file", :title => "this is a test", :scope => @scope, :source => mock('source'))
- resource.tags.should_not be_include("this is a test")
- end
+ describe "when being tagged" do
+ before do
+ @scope_resource = stub 'scope_resource', :tags => %w{srone srtwo}
+ @scope = stub 'scope', :resource => @scope_resource
+ @resource = Puppet::Parser::Resource.new(:type => "file", :title => "yay", :scope => @scope, :source => mock('source'))
+ end
- it "should fail on tags containing '*' characters" do
- lambda { @resource.tag("bad*tag") }.should raise_error(Puppet::ParseError)
- end
+ it "should get tagged with the resource type" do
+ @resource.tags.should be_include("file")
+ end
- it "should fail on tags starting with '-' characters" do
- lambda { @resource.tag("-badtag") }.should raise_error(Puppet::ParseError)
- end
+ it "should get tagged with the title" do
+ @resource.tags.should be_include("yay")
+ end
- it "should fail on tags containing ' ' characters" do
- lambda { @resource.tag("bad tag") }.should raise_error(Puppet::ParseError)
- end
+ it "should get tagged with each name in the title if the title is a qualified class name" do
+ resource = Puppet::Parser::Resource.new(:type => "file", :title => "one::two", :scope => @scope, :source => mock('source'))
+ resource.tags.should be_include("one")
+ resource.tags.should be_include("two")
+ end
+
+ it "should get tagged with each name in the type if the type is a qualified class name" do
+ resource = Puppet::Parser::Resource.new(:type => "one::two", :title => "whatever", :scope => @scope, :source => mock('source'))
+ resource.tags.should be_include("one")
+ resource.tags.should be_include("two")
+ end
+
+ it "should not get tagged with non-alphanumeric titles" do
+ resource = Puppet::Parser::Resource.new(:type => "file", :title => "this is a test", :scope => @scope, :source => mock('source'))
+ resource.tags.should_not be_include("this is a test")
+ end
+
+ it "should fail on tags containing '*' characters" do
+ lambda { @resource.tag("bad*tag") }.should raise_error(Puppet::ParseError)
+ end
+
+ it "should fail on tags starting with '-' characters" do
+ lambda { @resource.tag("-badtag") }.should raise_error(Puppet::ParseError)
+ end
+
+ it "should fail on tags containing ' ' characters" do
+ lambda { @resource.tag("bad tag") }.should raise_error(Puppet::ParseError)
+ end
- it "should allow alpha tags" do
- lambda { @resource.tag("good_tag") }.should_not raise_error(Puppet::ParseError)
+ it "should allow alpha tags" do
+ lambda { @resource.tag("good_tag") }.should_not raise_error(Puppet::ParseError)
+ end
end
end
diff --git a/spec/unit/ral/types/package.rb b/spec/unit/ral/types/package.rb
index 785d2eb37..5d96dc4ae 100755
--- a/spec/unit/ral/types/package.rb
+++ b/spec/unit/ral/types/package.rb
@@ -94,8 +94,8 @@ describe Puppet::Type::Package, "when validating attribute values" do
proc { Puppet::Type::Package.create(:name => "yay", :ensure => "1.0") }.should raise_error(Puppet::Error)
end
- it "should only accept files and URLs as values to :source" do
- proc { Puppet::Type::Package.create(:name => "yay", :source => "stuff") }.should raise_error(Puppet::Error)
+ it "should accept any string as an argument to :source" do
+ proc { Puppet::Type::Package.create(:name => "yay", :source => "stuff") }.should_not raise_error(Puppet::Error)
end
after { Puppet::Type::Package.clear }
diff --git a/spec/unit/ral/types/service.rb b/spec/unit/ral/types/service.rb
index 981d38a15..0f00992fa 100755
--- a/spec/unit/ral/types/service.rb
+++ b/spec/unit/ral/types/service.rb
@@ -15,7 +15,7 @@ describe Puppet::Type::Service do
end
describe Puppet::Type::Service, "when validating attributes" do
- [:name, :binary, :hasstatus, :path, :pattern, :start, :restart, :stop, :status, :hasrestart].each do |param|
+ [:name, :binary, :hasstatus, :path, :pattern, :start, :restart, :stop, :status, :hasrestart, :control].each do |param|
it "should have a #{param} parameter" do
Puppet::Type::Service.attrtype(param).should == :param
end
@@ -30,7 +30,7 @@ end
describe Puppet::Type::Service, "when validating attribute values" do
before do
- @provider = stub 'provider', :class => Puppet::Type::Service.defaultprovider, :clear => nil
+ @provider = stub 'provider', :class => Puppet::Type::Service.defaultprovider, :clear => nil, :controllable? => false
Puppet::Type::Service.defaultprovider.stubs(:new).returns(@provider)
end
@@ -132,16 +132,23 @@ describe Puppet::Type::Service, "when setting default attribute values" do
svc[:path].should == ["testing"]
end
- it "should default to the binary for the pattern if one is provided" do
+ it "should default 'pattern' to the binary if one is provided" do
svc = Puppet::Type::Service.create(:name => "other", :binary => "/some/binary")
svc[:pattern].should == "/some/binary"
end
- it "should default to the name for the pattern if no pattern is provided" do
+ it "should default 'pattern' to the name if no pattern is provided" do
svc = Puppet::Type::Service.create(:name => "other")
svc[:pattern].should == "other"
end
+ it "should default 'control' to the upcased service name with periods replaced by underscores if the provider supports the 'controllable' feature" do
+ provider = stub 'provider', :controllable? => true, :class => Puppet::Type::Service.defaultprovider, :clear => nil
+ Puppet::Type::Service.defaultprovider.stubs(:new).returns(provider)
+ svc = Puppet::Type::Service.create(:name => "nfs.client")
+ svc[:control].should == "NFS_CLIENT_START"
+ end
+
after { Puppet::Type::Service.clear }
end
diff --git a/test/ral/types/exec.rb b/test/ral/types/exec.rb
index 4133d8519..e2a3dd9ed 100755
--- a/test/ral/types/exec.rb
+++ b/test/ral/types/exec.rb
@@ -394,8 +394,8 @@ class TestExec < Test::Unit::TestCase
assert_apply(exec)
assert_nothing_raised {
- exec[:command] = "echo logoutput is warning"
- exec[:logoutput] = "warning"
+ exec[:command] = "echo logoutput is on_failure"
+ exec[:logoutput] = "on_failure"
}
assert_apply(exec)