diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-02-28 06:46:43 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-02-28 06:46:43 +0000 |
commit | cc260268a88f69a6bb28535b17ced7228aa71314 (patch) | |
tree | b98a11a6abfc9fe2786a34a94eceb166a940db6b | |
parent | d229d49c5614c5ca9e15ae5716968a184f6f1bc7 (diff) | |
download | puppet-cc260268a88f69a6bb28535b17ced7228aa71314.tar.gz puppet-cc260268a88f69a6bb28535b17ced7228aa71314.tar.xz puppet-cc260268a88f69a6bb28535b17ced7228aa71314.zip |
Fixing #467. It is a hackish solution, because I just reordered the definition of the params, but it works for now, anyway.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2242 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r-- | lib/puppet/metatype/metaparams.rb | 42 | ||||
-rwxr-xr-x | test/other/transactions.rb | 31 |
2 files changed, 53 insertions, 20 deletions
diff --git a/lib/puppet/metatype/metaparams.rb b/lib/puppet/metatype/metaparams.rb index b780316af..2294f6170 100644 --- a/lib/puppet/metatype/metaparams.rb +++ b/lib/puppet/metatype/metaparams.rb @@ -308,8 +308,12 @@ class Puppet::Type RelationshipMetaparam.subclasses end - # For each object we require, subscribe to all events that it generates. We - # might reduce the level of subscription eventually, but for now... + + # Note that the order in which the relationships params is defined + # matters. The labelled params (notify and subcribe) must be later, + # so that if both params are used, those ones win. It's a hackish + # solution, but it works. + newmetaparam(:require, :parent => RelationshipMetaparam, :attributes => {:direction => :in, :events => :NONE}) do desc "One or more objects that this object depends on. This is used purely for guaranteeing that changes to required objects @@ -346,8 +350,6 @@ class Puppet::Type " end - # For each object we require, subscribe to all events that it generates. - # We might reduce the level of subscription eventually, but for now... newmetaparam(:subscribe, :parent => RelationshipMetaparam, :attributes => {:direction => :in, :events => :ALL_EVENTS, :callback => :refresh}) do desc "One or more objects that this object depends on. Changes in the subscribed to objects result in the dependent objects being @@ -368,22 +370,6 @@ class Puppet::Type refreshing. " end - - newmetaparam(:notify, :parent => RelationshipMetaparam, :attributes => {:direction => :out, :events => :ALL_EVENTS, :callback => :refresh}) do - desc %{This parameter is the opposite of **subscribe** -- it sends events - to the specified object: - - file { "/etc/sshd_config": - source => "....", - notify => service[sshd] - } - - service { sshd: - ensure => running - } - - This will restart the sshd service if the sshd config file changes.} - end newmetaparam(:before, :parent => RelationshipMetaparam, :attributes => {:direction => :out, :events => :NONE}) do desc %{This parameter is the opposite of **require** -- it guarantees @@ -404,6 +390,22 @@ class Puppet::Type This will make sure all of the files are up to date before the make command is run.} end + + newmetaparam(:notify, :parent => RelationshipMetaparam, :attributes => {:direction => :out, :events => :ALL_EVENTS, :callback => :refresh}) do + desc %{This parameter is the opposite of **subscribe** -- it sends events + to the specified object: + + file { "/etc/sshd_config": + source => "....", + notify => service[sshd] + } + + service { sshd: + ensure => running + } + + This will restart the sshd service if the sshd config file changes.} + end end # Puppet::Type # $Id$ diff --git a/test/other/transactions.rb b/test/other/transactions.rb index 3129116e7..1213c75b9 100755 --- a/test/other/transactions.rb +++ b/test/other/transactions.rb @@ -1078,6 +1078,37 @@ class TestTransactions < Test::Unit::TestCase assert(! graph.edge?(after, before), "created automatic relationship %s" % str) end end + + def test_labeled_deps_beat_unlabeled + one = Puppet::Type.type(:exec).create :command => "/bin/echo one" + two = Puppet::Type.type(:exec).create :command => "/bin/echo two" + + one[:require] = two + one[:subscribe] = two + + comp = newcomp(one, two) + trans = Puppet::Transaction.new(comp) + graph = trans.relationship_graph + + label = graph.edge_label(two, one) + assert(label, "require beat subscribe") + assert_equal(:refresh, label[:callback], + "did not get correct callback from subscribe") + + one.delete(:require) + one.delete(:subscribe) + + two[:before] = one + two[:notify] = one + + trans = Puppet::Transaction.new(comp) + graph = trans.relationship_graph + + label = graph.edge_label(two, one) + assert(label, "before beat notify") + assert_equal(:refresh, label[:callback], + "did not get correct callback from notify") + end end # $Id$ |