summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/parser/resource.rb4
-rw-r--r--lib/puppet/resource/catalog.rb9
-rw-r--r--lib/puppet/transportable.rb8
-rwxr-xr-xspec/unit/other/transbucket.rb10
-rwxr-xr-xspec/unit/other/transobject.rb4
-rwxr-xr-xspec/unit/parser/resource.rb4
-rwxr-xr-xspec/unit/resource/catalog.rb2
-rwxr-xr-xspec/unit/type.rb3
-rw-r--r--test/lib/puppettest/support/utils.rb2
-rwxr-xr-xtest/network/client/resource.rb4
-rwxr-xr-xtest/network/handler/resource.rb6
-rwxr-xr-xtest/ral/manager/type.rb71
-rwxr-xr-xtest/util/settings.rb2
13 files changed, 33 insertions, 96 deletions
diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb
index 75c885b61..12c1a8f52 100644
--- a/lib/puppet/parser/resource.rb
+++ b/lib/puppet/parser/resource.rb
@@ -327,8 +327,8 @@ class Puppet::Parser::Resource
# Convert this resource to a RAL resource. We hackishly go via the
# transportable stuff.
- def to_type
- to_resource.to_type
+ def to_ral
+ to_resource.to_ral
end
private
diff --git a/lib/puppet/resource/catalog.rb b/lib/puppet/resource/catalog.rb
index 5b1022799..56534b6be 100644
--- a/lib/puppet/resource/catalog.rb
+++ b/lib/puppet/resource/catalog.rb
@@ -385,7 +385,7 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph
# Convert our catalog into a RAL catalog.
def to_ral
- to_catalog :to_type
+ to_catalog :to_ral
end
# Turn our parser catalog into a transportable catalog.
@@ -463,11 +463,14 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph
#Aliases aren't working in the ral catalog because the current instance of the resource
#has a reference to the catalog being converted. . . So, give it a reference to the new one
#problem solved. . .
- if resource.is_a?(Puppet::TransObject)
+ if resource.is_a?(Puppet::Resource)
+ resource = resource.dup
+ resource.catalog = result
+ elsif resource.is_a?(Puppet::TransObject)
resource = resource.dup
resource.catalog = result
elsif resource.is_a?(Puppet::Parser::Resource)
- resource = resource.to_transobject
+ resource = resource.to_resource
resource.catalog = result
end
diff --git a/lib/puppet/transportable.rb b/lib/puppet/transportable.rb
index 9e85b1fe7..c63e2419c 100644
--- a/lib/puppet/transportable.rb
+++ b/lib/puppet/transportable.rb
@@ -86,7 +86,7 @@ module Puppet
ref
end
- def to_type
+ def to_ral
if typeklass = Puppet::Type.type(self.type)
return typeklass.create(self)
else
@@ -189,13 +189,13 @@ module Puppet
delver = proc do |obj|
obj.catalog = catalog
unless container = catalog.resource(obj.to_ref)
- container = obj.to_type
+ container = obj.to_ral
catalog.add_resource container
end
obj.each do |child|
child.catalog = catalog
unless resource = catalog.resource(child.to_ref)
- resource = child.to_type
+ resource = child.to_ral
catalog.add_resource resource
end
@@ -233,7 +233,7 @@ module Puppet
@ref.to_s if @ref
end
- def to_type
+ def to_ral
Puppet.debug("TransBucket '%s' has no type" % @name) unless defined? @type
# Nodes have the same name and type
diff --git a/spec/unit/other/transbucket.rb b/spec/unit/other/transbucket.rb
index 60efcdb87..3445e26b0 100755
--- a/spec/unit/other/transbucket.rb
+++ b/spec/unit/other/transbucket.rb
@@ -12,7 +12,7 @@ describe Puppet::TransBucket do
@bucket.type = "user"
resource = nil
- proc { resource = @bucket.to_type }.should_not raise_error
+ proc { resource = @bucket.to_ral }.should_not raise_error
resource.should be_instance_of(Puppet::Type::Component)
resource.title.should == "User[luke]"
end
@@ -99,7 +99,7 @@ describe Puppet::TransBucket, " when generating a catalog" do
end
it "should fail if any transportable resources fail to convert to RAL resources" do
- @bottomobj.expects(:to_type).raises ArgumentError
+ @bottomobj.expects(:to_ral).raises ArgumentError
lambda { @bottom.to_catalog }.should raise_error(ArgumentError)
end
@@ -120,12 +120,12 @@ describe Puppet::TransBucket, " when generating a catalog" do
@catalog.vertices.each do |vertex| vertex.should be_finalized end
end
- it "should only call to_type on each resource once" do
+ it "should only call to_ral on each resource once" do
# We just raise exceptions here because we're not interested in
# what happens with the result, only that the method only
# gets called once.
- resource = @topobj.to_type
- @topobj.expects(:to_type).once.returns resource
+ resource = @topobj.to_ral
+ @topobj.expects(:to_ral).once.returns resource
@top.to_catalog
end
diff --git a/spec/unit/other/transobject.rb b/spec/unit/other/transobject.rb
index 33de72c74..7546cf686 100755
--- a/spec/unit/other/transobject.rb
+++ b/spec/unit/other/transobject.rb
@@ -50,13 +50,13 @@ describe Puppet::TransObject, " when converting to a RAL resource" do
type = mock 'resource type'
type.expects(:create).with(@resource).returns(:myresource)
Puppet::Type.expects(:type).with("file").returns(type)
- @resource.to_type.should == :myresource
+ @resource.to_ral.should == :myresource
end
it "should convert to a component instance if the resource type cannot be found" do
Puppet::Type.expects(:type).with("file").returns(nil)
@resource.expects(:to_component).returns(:mycomponent)
- @resource.to_type.should == :mycomponent
+ @resource.to_ral.should == :mycomponent
end
end
diff --git a/spec/unit/parser/resource.rb b/spec/unit/parser/resource.rb
index 5ae8a644a..e778dc8e4 100755
--- a/spec/unit/parser/resource.rb
+++ b/spec/unit/parser/resource.rb
@@ -65,10 +65,10 @@ describe Puppet::Parser::Resource do
end
it "should use a Puppet::Resource for converting to a ral resource" do
- trans = mock 'resource', :to_type => "yay"
+ trans = mock 'resource', :to_ral => "yay"
@resource = mkresource
@resource.expects(:to_resource).returns trans
- @resource.to_type.should == "yay"
+ @resource.to_ral.should == "yay"
end
describe "when initializing" do
diff --git a/spec/unit/resource/catalog.rb b/spec/unit/resource/catalog.rb
index 44ad25aac..53cb98fef 100755
--- a/spec/unit/resource/catalog.rb
+++ b/spec/unit/resource/catalog.rb
@@ -325,7 +325,7 @@ describe Puppet::Resource::Catalog, "when compiling" do
#changer is going to get duplicated as part of a fix for aliases 1094
changer.expects(:dup).returns(changer)
- changer.expects(:to_type).returns(resource)
+ changer.expects(:to_ral).returns(resource)
newconfig = nil
diff --git a/spec/unit/type.rb b/spec/unit/type.rb
index a279e1139..b8950297a 100755
--- a/spec/unit/type.rb
+++ b/spec/unit/type.rb
@@ -34,6 +34,9 @@ describe Puppet::Type do
resource.parameter(:fstype).must be_instance_of(Puppet::Type.type(:mount).attrclass(:fstype))
end
+ describe "when initializing" do
+ end
+
describe "when retrieving current property values" do
# Use 'mount' as an example, because it doesn't override 'retrieve'
before do
diff --git a/test/lib/puppettest/support/utils.rb b/test/lib/puppettest/support/utils.rb
index aa3ad8b8d..c00d8a132 100644
--- a/test/lib/puppettest/support/utils.rb
+++ b/test/lib/puppettest/support/utils.rb
@@ -17,7 +17,7 @@ module PuppetTest::Support::Utils
transport[:path] = path
transport[:ensure] = "file"
assert_nothing_raised {
- file = transport.to_type
+ file = transport.to_ral
}
end
diff --git a/test/network/client/resource.rb b/test/network/client/resource.rb
index 6a2e52471..86c6ccd2f 100755
--- a/test/network/client/resource.rb
+++ b/test/network/client/resource.rb
@@ -40,7 +40,7 @@ class TestResourceClient < Test::Unit::TestCase
resource = nil
assert_nothing_raised {
- resource = tresource.to_type
+ resource = tresource.to_ral
}
assert_events([], resource)
p resource.instance_variable_get("@stat")
@@ -75,7 +75,7 @@ class TestResourceClient < Test::Unit::TestCase
resource = nil
assert_nothing_raised {
- resource = tresource2.to_type
+ resource = tresource2.to_ral
}
assert_events([], resource)
diff --git a/test/network/handler/resource.rb b/test/network/handler/resource.rb
index 269c9571c..d766c685d 100755
--- a/test/network/handler/resource.rb
+++ b/test/network/handler/resource.rb
@@ -15,7 +15,7 @@ class TestResourceServer < Test::Unit::TestCase
described.each do |name, trans|
obj = nil
assert_nothing_raised do
- obj = trans.to_type
+ obj = trans.to_ral
end
assert(obj, "Could not create object")
@@ -61,7 +61,7 @@ class TestResourceServer < Test::Unit::TestCase
object = nil
assert_nothing_raised do
- object = result.to_type
+ object = result.to_ral
end
assert(object, "Could not create type")
@@ -110,7 +110,7 @@ class TestResourceServer < Test::Unit::TestCase
object = nil
assert_nothing_raised do
- object = result.to_type
+ object = result.to_ral
end
catalog = mk_catalog(object)
diff --git a/test/ral/manager/type.rb b/test/ral/manager/type.rb
index f3a116f6f..a56e81267 100755
--- a/test/ral/manager/type.rb
+++ b/test/ral/manager/type.rb
@@ -140,7 +140,7 @@ class TestType < Test::Unit::TestCase
def test_catalogs_are_set_during_initialization_if_present_on_the_transobject
trans = Puppet::TransObject.new("/path/to/some/file", :file)
trans.catalog = stub 'catalog', :resource => nil
- resource = trans.to_type
+ resource = trans.to_ral
assert_equal(resource.catalog, trans.catalog, "Did not set catalog on initialization")
end
@@ -375,75 +375,6 @@ class TestType < Test::Unit::TestCase
assert_equal(path, file[:name], "Did not get correct name")
end
- # Make sure the "create" class method behaves appropriately.
- def test_class_create
- title = "Myfile"
- validate = proc do |element|
- assert(element, "Did not create file")
- assert_instance_of(Puppet::Type.type(:file), element)
- assert_equal(title, element.title, "Title is not correct")
- end
- type = :file
- args = {:path => tempfile(), :owner => "root"}
-
- trans = Puppet::TransObject.new(title, type)
- args.each do |name, val| trans[name] = val end
-
- # First call it on the appropriate typeclass
- obj = nil
- assert_nothing_raised do
- obj = Puppet::Type.type(:file).create(trans)
- end
-
- validate.call(obj)
-
- # Now try it using the class method on Type
- oldid = obj.object_id
- obj = nil
-
- assert_nothing_raised {
- obj = Puppet::Type.create(trans)
- }
-
- validate.call(obj)
- assert(oldid != obj.object_id, "Got same object back")
-
- # Now try the same things with hashes instead of a transobject
- oldid = obj.object_id
- obj = nil
- hash = {
- :type => :file,
- :title => "Myfile",
- :path => tempfile(),
- :owner => "root"
- }
-
- # First call it on the appropriate typeclass
- obj = nil
- assert_nothing_raised do
- obj = Puppet::Type.type(:file).create(hash)
- end
-
- validate.call(obj)
- assert_equal(:file, obj.should(:type),
- "Type param did not pass through")
-
- assert(oldid != obj.object_id, "Got same object back")
-
- # Now try it using the class method on Type
- oldid = obj.object_id
- obj = nil
-
- assert_nothing_raised {
- obj = Puppet::Type.create(hash)
- }
-
- validate.call(obj)
- assert(oldid != obj.object_id, "Got same object back")
- assert_nil(obj.should(:type),
- "Type param passed through")
- end
-
def test_multiplenames
obj = nil
path = tempfile()
diff --git a/test/util/settings.rb b/test/util/settings.rb
index 94b01c80e..049c005b9 100755
--- a/test/util/settings.rb
+++ b/test/util/settings.rb
@@ -51,7 +51,7 @@ class TestSettings < Test::Unit::TestCase
comp = nil
assert_nothing_raised("Could not convert transportable to component") {
- comp = trans.to_type
+ comp = trans.to_ral
}
assert_nothing_raised("Could not retrieve transported config") {