fix primitive definition strings with fewer parameters
This commit is contained in:
@@ -34,7 +34,8 @@ class Pacemaker::Resource::Primitive < Pacemaker::Resource
|
|||||||
|
|
||||||
self.op = {}
|
self.op = {}
|
||||||
%w(start stop monitor).each do |op|
|
%w(start stop monitor).each do |op|
|
||||||
self.op[op] = self.class.extract_hash(definition, "op #{op}")
|
h = self.class.extract_hash(definition, "op #{op}")
|
||||||
|
self.op[op] = h unless h.empty?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -51,12 +52,16 @@ class Pacemaker::Resource::Primitive < Pacemaker::Resource
|
|||||||
end
|
end
|
||||||
|
|
||||||
def definition_string
|
def definition_string
|
||||||
return <<EOF
|
str = "#{TYPE} #{name} #{agent}"
|
||||||
#{TYPE} #{name} #{agent} \\
|
indent = ' ' * 9
|
||||||
#{params_string} \\
|
%w(params meta op).each do |data_type|
|
||||||
#{meta_string} \\
|
unless send(data_type).empty?
|
||||||
#{op_string}
|
data_string = send("#{data_type}_string")
|
||||||
EOF
|
str << " \\\n#{indent}#{data_string}"
|
||||||
|
else
|
||||||
|
end
|
||||||
|
end
|
||||||
|
str
|
||||||
end
|
end
|
||||||
|
|
||||||
def crm_configure_command
|
def crm_configure_command
|
||||||
|
2
spec/fixtures/keystone_primitive.rb
vendored
2
spec/fixtures/keystone_primitive.rb
vendored
@@ -21,7 +21,7 @@ module Chef::RSpec
|
|||||||
[ "monitor", { "timeout" => "60", "interval" => "10s" } ],
|
[ "monitor", { "timeout" => "60", "interval" => "10s" } ],
|
||||||
[ "start", { "timeout" => "240", "interval" => "10s" } ]
|
[ "start", { "timeout" => "240", "interval" => "10s" } ]
|
||||||
]
|
]
|
||||||
KEYSTONE_PRIMITIVE_DEFINITION = <<'EOF'
|
KEYSTONE_PRIMITIVE_DEFINITION = <<'EOF'.chomp
|
||||||
primitive keystone ocf:openstack:keystone \
|
primitive keystone ocf:openstack:keystone \
|
||||||
params os_auth_url="http://node1:5000/v2.0" os_password="adminpw" os_tenant_name="openstack" os_username="admin" user="openstack-keystone" \
|
params os_auth_url="http://node1:5000/v2.0" os_password="adminpw" os_tenant_name="openstack" os_username="admin" user="openstack-keystone" \
|
||||||
meta is-managed="true" target-role="Started" \
|
meta is-managed="true" target-role="Started" \
|
||||||
|
@@ -110,6 +110,17 @@ describe Pacemaker::Resource::Primitive do
|
|||||||
it "should return the definition string" do
|
it "should return the definition string" do
|
||||||
expect(fixture.definition_string).to eq(fixture_definition)
|
expect(fixture.definition_string).to eq(fixture_definition)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should return a short definition string" do
|
||||||
|
primitive = Pacemaker::Resource::Primitive.new('foo')
|
||||||
|
primitive.definition = \
|
||||||
|
%!primitive foo ocf:heartbeat:IPaddr2 params foo="bar"!
|
||||||
|
primitive.parse_definition
|
||||||
|
expect(primitive.definition_string).to eq(<<'EOF'.chomp)
|
||||||
|
primitive foo ocf:heartbeat:IPaddr2 \
|
||||||
|
params foo="bar"
|
||||||
|
EOF
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#parse_definition" do
|
describe "#parse_definition" do
|
||||||
|
Reference in New Issue
Block a user