diff options
author | Luke Kanies <luke@madstop.com> | 2008-05-22 00:45:08 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2008-05-22 00:45:08 -0500 |
commit | c370104f7efa6231af05df17ccbb03cbaa2e48ab (patch) | |
tree | 66487b58b31bb2fe9a6bd4bf2bbf5e90c9391401 | |
parent | bd51a53b0870ee2355c046af255232ec868d8f1d (diff) | |
download | puppet-c370104f7efa6231af05df17ccbb03cbaa2e48ab.tar.gz puppet-c370104f7efa6231af05df17ccbb03cbaa2e48ab.tar.xz puppet-c370104f7efa6231af05df17ccbb03cbaa2e48ab.zip |
Fixing the node/catalog so that it can convert from parser catalogs to RAL catalogs.
It largely worked previously, except when aliases were set,
which require catalogs. This now converts all parser resources
to trans_objects then to RAL resources, and sets the catalog
in the meantime. This allows aliases to work just
fine when converting directly from parser catalogs to RAL catalogs.
-rw-r--r-- | lib/puppet/node/catalog.rb | 4 | ||||
-rwxr-xr-x | spec/unit/node/catalog.rb | 20 |
2 files changed, 24 insertions, 0 deletions
diff --git a/lib/puppet/node/catalog.rb b/lib/puppet/node/catalog.rb index ecda472be..c4d697244 100644 --- a/lib/puppet/node/catalog.rb +++ b/lib/puppet/node/catalog.rb @@ -483,6 +483,10 @@ class Puppet::Node::Catalog < Puppet::PGraph if resource.is_a?(Puppet::TransObject) resource = resource.dup resource.catalog = result + elsif resource.is_a?(Puppet::Parser::Resource) + resource = resource.to_transobject + p resource + resource.catalog = result end newres = resource.send(convert) diff --git a/spec/unit/node/catalog.rb b/spec/unit/node/catalog.rb index 8178f953a..ff9ab6930 100755 --- a/spec/unit/node/catalog.rb +++ b/spec/unit/node/catalog.rb @@ -292,6 +292,26 @@ describe Puppet::Node::Catalog, " when converting to a RAL catalog" do @catalog.vertices.each { |v| v.catalog.object_id.should equal(@catalog.object_id) } end + it "should convert parser resources to transobjects and set the catalog" do + catalog = Puppet::Node::Catalog.new("mynode") + + result = mock 'catalog' + result.stub_everything + + Puppet::Node::Catalog.expects(:new).returns result + + trans = mock 'trans' + resource = Puppet::Parser::Resource.new(:scope => mock("scope"), :source => mock("source"), :type => :file, :title => "/eh") + resource.expects(:to_transobject).returns trans + trans.expects(:catalog=).with result + + trans.stub_everything + + catalog.add_resource(resource) + + catalog.to_ral + end + # This tests #931. it "should not lose track of resources whose names vary" do changer = Puppet::TransObject.new 'changer', 'test' |