extract CIB definition formatting code for reuse

This commit is contained in:
Adam Spiers 2014-02-06 18:52:45 +00:00
parent cb0d3adfb0
commit 66daffffbb
2 changed files with 9 additions and 2 deletions

View File

@ -116,6 +116,14 @@ module Pacemaker
"%s '%s'" % [self.class.description, name]
end
def definition_indent
' ' * 9
end
def continuation_line(text)
" \\\n#{definition_indent}#{text}"
end
# Returns a single-quoted shell-escaped version of the definition
# string, suitable for use in a command like:
#

View File

@ -51,11 +51,10 @@ class Pacemaker::Resource::Primitive < Pacemaker::Resource
def definition_string
str = "#{TYPE} #{name} #{agent}"
indent = ' ' * 9
%w(params meta op).each do |data_type|
unless send(data_type).empty?
data_string = send("#{data_type}_string")
str << " \\\n#{indent}#{data_string}"
str << continuation_line(data_string)
else
end
end