refactor crm configure load update command
This commit is contained in:
@@ -119,6 +119,10 @@ module Pacemaker
|
||||
.gsub("'") { "\\'" }
|
||||
end
|
||||
|
||||
def reconfigure_command
|
||||
"echo #{quoted_definition_string} | crm configure load update -"
|
||||
end
|
||||
|
||||
def delete_command
|
||||
"crm configure delete '#{name}'"
|
||||
end
|
||||
|
@@ -64,8 +64,7 @@ def maybe_modify_resource(name)
|
||||
desired_colocation = cib_object_class.from_chef_resource(new_resource)
|
||||
if desired_colocation.definition_string != @current_cib_object.definition_string
|
||||
Chef::Log.debug "changed from [#{@current_cib_object.definition_string}] to [#{desired_colocation.definition_string}]"
|
||||
to_echo = desired_colocation.quoted_definition_string
|
||||
cmd = "echo #{to_echo} | crm configure load update -"
|
||||
cmd = desired_colocation.reconfigure_command
|
||||
execute cmd do
|
||||
action :nothing
|
||||
end.run_action(:run)
|
||||
|
@@ -103,8 +103,7 @@ def maybe_modify_resource(name)
|
||||
desired_primitive = cib_object_class.from_chef_resource(new_resource)
|
||||
if desired_primitive.op_string != @current_cib_object.op_string
|
||||
Chef::Log.debug "op changed from [#{@current_cib_object.op_string}] to [#{desired_primitive.op_string}]"
|
||||
to_echo = desired_primitive.quoted_definition_string
|
||||
cmds = ["echo #{to_echo} | crm configure load update -"]
|
||||
cmds = [desired_primitive.reconfigure_command]
|
||||
else
|
||||
maybe_configure_params(name, cmds, :params)
|
||||
maybe_configure_params(name, cmds, :meta)
|
||||
|
@@ -46,12 +46,11 @@ describe "Chef::Provider::PacemakerColocation" do
|
||||
end
|
||||
|
||||
it "should modify the constraint if it has a different score" do
|
||||
echo_string = colo.quoted_definition_string.gsub('inf', '100')
|
||||
expected_configure_cmd_args = [
|
||||
"echo #{echo_string} | crm configure load update -"
|
||||
]
|
||||
new_score = '100'
|
||||
colo.score = new_score
|
||||
expected_configure_cmd_args = [colo.reconfigure_command]
|
||||
test_modify(expected_configure_cmd_args) do
|
||||
@resource.score '100'
|
||||
@resource.score new_score
|
||||
end
|
||||
end
|
||||
|
||||
@@ -59,10 +58,7 @@ describe "Chef::Provider::PacemakerColocation" do
|
||||
new_resource = 'bar:Stopped'
|
||||
expected = colo.dup
|
||||
expected.resources = expected.resources.dup + [new_resource]
|
||||
echo_string = expected.quoted_definition_string
|
||||
expected_configure_cmd_args = [
|
||||
"echo #{echo_string} | crm configure load update -"
|
||||
]
|
||||
expected_configure_cmd_args = [expected.reconfigure_command]
|
||||
test_modify(expected_configure_cmd_args) do
|
||||
@resource.resources expected.resources
|
||||
end
|
||||
@@ -71,10 +67,7 @@ describe "Chef::Provider::PacemakerColocation" do
|
||||
it "should modify the constraint if it has a different resource" do
|
||||
new_resources = ['bar:Started']
|
||||
colo.resources = new_resources
|
||||
echo_string = colo.quoted_definition_string
|
||||
expected_configure_cmd_args = [
|
||||
"echo #{echo_string} | crm configure load update -"
|
||||
]
|
||||
expected_configure_cmd_args = [colo.reconfigure_command]
|
||||
test_modify(expected_configure_cmd_args) do
|
||||
@resource.resources new_resources
|
||||
end
|
||||
|
@@ -91,9 +91,8 @@ describe "Chef::Provider::PacemakerPrimitive" do
|
||||
end
|
||||
|
||||
it "should modify the primitive if it has different op values" do
|
||||
echo_string = rsc.quoted_definition_string.gsub!('60', '120')
|
||||
expected_configure_cmd_args = [
|
||||
"echo #{echo_string} | crm configure load update -"
|
||||
rsc.reconfigure_command.gsub('60', '120')
|
||||
]
|
||||
test_modify(expected_configure_cmd_args) do
|
||||
new_op = Hash[rsc.op]
|
||||
|
Reference in New Issue
Block a user