From 2eb9635de627abfaa14ee83ba4c022f7ecd9d74b Mon Sep 17 00:00:00 2001 From: Ivan Devat Date: Wed, 7 Jun 2017 14:36:05 +0200 Subject: [PATCH] squash bz1459503 OSP workarounds not compatible wi reuse existing pcmk authkey during setup show only warn if `resource create` creates remote --- pcs/cluster.py | 10 +++++++++- pcs/lib/commands/resource.py | 6 ++++-- pcs/test/cib_resource/test_create.py | 13 ++++++------- pcs/test/test_resource.py | 24 ++++++++++++------------ 4 files changed, 31 insertions(+), 22 deletions(-) diff --git a/pcs/cluster.py b/pcs/cluster.py index b1f63d45..42e94a94 100644 --- a/pcs/cluster.py +++ b/pcs/cluster.py @@ -519,13 +519,21 @@ def cluster_setup(argv): print("Destroying cluster on nodes: {0}...".format( ", ".join(primary_addr_list) )) + + try: + pcmk_authkey_content = ( + open(settings.pacemaker_authkey_file, "rb").read() + ) + except EnvironmentError as e: + pcmk_authkey_content = generate_key() + destroy_cluster(primary_addr_list) print() try: file_definitions = {} file_definitions.update( - node_communication_format.pcmk_authkey_file(generate_key()) + node_communication_format.pcmk_authkey_file(pcmk_authkey_content) ) if modifiers["encryption"] == "1": file_definitions.update( diff --git a/pcs/lib/commands/resource.py b/pcs/lib/commands/resource.py index 90dab8f4..de5cfb4e 100644 --- a/pcs/lib/commands/resource.py +++ b/pcs/lib/commands/resource.py @@ -76,7 +76,8 @@ def _validate_remote_connection( report_list.append( reports.get_problem_creator( report_codes.FORCE_NOT_SUITABLE_COMMAND, - allow_not_suitable_command + is_forced=True, + # allow_not_suitable_command )(reports.use_command_node_add_remote) ) @@ -106,7 +107,8 @@ def _validate_guest_change( report_list.append( reports.get_problem_creator( report_codes.FORCE_NOT_SUITABLE_COMMAND, - allow_not_suitable_command + is_forced=True + # allow_not_suitable_command )(create_report) ) diff --git a/pcs/test/cib_resource/test_create.py b/pcs/test/cib_resource/test_create.py index 57d95350..3cd49e74 100644 --- a/pcs/test/cib_resource/test_create.py +++ b/pcs/test/cib_resource/test_create.py @@ -1627,11 +1627,10 @@ class FailOrWarnGroup(ResourceTestLocal): ) def test_fail_when_on_pacemaker_remote_attempt(self): - self.assert_pcs_fail( + self.assert_pcs_success( "resource create R2 ocf:pacemaker:remote", - "Error: this command is not sufficient for creating a remote" - " connection, use 'pcs cluster node add-remote'" - ", use --force to override\n" + "Warning: this command is not sufficient for creating a remote" + " connection, use 'pcs cluster node add-remote'\n" ) def test_warn_when_on_pacemaker_remote_attempt(self): @@ -1731,10 +1730,10 @@ class FailOrWarnGroup(ResourceTestLocal): ) def test_fail_when_on_pacemaker_remote_guest_attempt(self): - self.assert_pcs_fail( + self.assert_pcs_success( "resource create R2 ocf:heartbeat:Dummy meta remote-node=HOST", - "Error: this command is not sufficient for creating a guest node," - " use 'pcs cluster node add-guest', use --force to override\n" + "Warning: this command is not sufficient for creating a guest node," + " use 'pcs cluster node add-guest'\n" ) def test_warn_when_on_pacemaker_remote_guest_attempt(self): diff --git a/pcs/test/test_resource.py b/pcs/test/test_resource.py index f514f9ed..773b37cf 100644 --- a/pcs/test/test_resource.py +++ b/pcs/test/test_resource.py @@ -5712,10 +5712,10 @@ class ResourceUpdateRemoteAndGuestChecks(unittest.TestCase, AssertPcsMixin): self.assert_pcs_success( "resource create R ocf:heartbeat:Dummy", ) - self.assert_pcs_fail( + self.assert_pcs_success( "resource update R meta remote-node=HOST", - "Error: this command is not sufficient for creating a guest node," - " use 'pcs cluster node add-guest', use --force to override\n" + "Warning: this command is not sufficient for creating a guest node," + " use 'pcs cluster node add-guest'\n" ) def test_update_warn_on_pacemaker_guest_attempt(self): self.assert_pcs_success( @@ -5734,10 +5734,10 @@ class ResourceUpdateRemoteAndGuestChecks(unittest.TestCase, AssertPcsMixin): "Warning: this command is not sufficient for creating a guest node," " use 'pcs cluster node add-guest'\n" ) - self.assert_pcs_fail( + self.assert_pcs_success( "resource update R meta remote-node=", - "Error: this command is not sufficient for removing a guest node," - " use 'pcs cluster node remove-guest', use --force to override\n" + "Warning: this command is not sufficient for removing a guest node," + " use 'pcs cluster node remove-guest'\n" ) def test_update_warn_on_pacemaker_guest_attempt_remove(self): @@ -5758,10 +5758,10 @@ class ResourceUpdateRemoteAndGuestChecks(unittest.TestCase, AssertPcsMixin): self.assert_pcs_success( "resource create R ocf:heartbeat:Dummy", ) - self.assert_pcs_fail( + self.assert_pcs_success( "resource meta R remote-node=HOST", - "Error: this command is not sufficient for creating a guest node," - " use 'pcs cluster node add-guest', use --force to override\n" + "Warning: this command is not sufficient for creating a guest node," + " use 'pcs cluster node add-guest'\n" ) def test_meta_warn_on_pacemaker_guest_attempt(self): @@ -5782,10 +5782,10 @@ class ResourceUpdateRemoteAndGuestChecks(unittest.TestCase, AssertPcsMixin): "Warning: this command is not sufficient for creating a guest node," " use 'pcs cluster node add-guest'\n" ) - self.assert_pcs_fail( + self.assert_pcs_success( "resource meta R remote-node=", - "Error: this command is not sufficient for removing a guest node," - " use 'pcs cluster node remove-guest', use --force to override\n" + "Warning: this command is not sufficient for removing a guest node," + " use 'pcs cluster node remove-guest'\n" ) def test_meta_warn_on_pacemaker_guest_attempt_remove(self): -- 2.17.0