
In Pacemaker, target-role defaults to 'Started', but we want to allow consumers of the LWRPs the choice whether their newly created resource gets started or not, and we also want to adhere to the Principle of Least Surprise. Therefore we stick to the intuitive semantics that action :create creates the resource with target-role="Stopped" in order to prevent it from starting immediately, whereas action [:create, :start] creates the resource and then starts it. Since we are honouring :start / :stop actions to determine the target-role value, if target-role is specified via meta, it will just be overridden anyway. So we also deprecate direct use of target-role meta parameter in recipes.
31 lines
664 B
Ruby
31 lines
664 B
Ruby
# A mixin for Pacemaker::Resource subclasses which support meta attributes
|
|
# (priority, target-role, is-managed, etc.)
|
|
|
|
module Pacemaker
|
|
module Mixins
|
|
module Resource
|
|
module Meta
|
|
def self.included(base)
|
|
base.extend ClassMethods
|
|
end
|
|
|
|
attr_accessor :meta
|
|
|
|
def meta_string
|
|
self.class.meta_string(meta)
|
|
end
|
|
|
|
module ClassMethods
|
|
def meta_string(meta)
|
|
return "" if ! meta or meta.empty?
|
|
"meta " +
|
|
meta.sort.map do |key, value|
|
|
%'#{key}="#{value}"'
|
|
end.join(' ')
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|