|
|
15f218 |
From d1a31c8b887fc668eff8ef582124a84524a5b760 Mon Sep 17 00:00:00 2001
|
|
|
15f218 |
From: Ondrej Mular <omular@redhat.com>
|
|
|
15f218 |
Date: Mon, 22 Aug 2016 15:52:08 +0200
|
|
|
15f218 |
Subject: [PATCH] fix error message in node maintenance/unmaintenance commands
|
|
|
15f218 |
|
|
|
15f218 |
---
|
|
|
15f218 |
pcs/node.py | 23 ++++++++++++++---------
|
|
|
15f218 |
pcs/test/test_node.py | 10 ++++++++--
|
|
|
15f218 |
2 files changed, 22 insertions(+), 11 deletions(-)
|
|
|
15f218 |
|
|
|
15f218 |
diff --git a/pcs/node.py b/pcs/node.py
|
|
|
15f218 |
index be2fb13..ed77d5d 100644
|
|
|
15f218 |
--- a/pcs/node.py
|
|
|
15f218 |
+++ b/pcs/node.py
|
|
|
15f218 |
@@ -77,8 +77,8 @@ def node_maintenance(argv, on=True):
|
|
|
15f218 |
for node in argv:
|
|
|
15f218 |
if node not in cluster_nodes:
|
|
|
15f218 |
utils.err(
|
|
|
15f218 |
- "Node '%s' does not appear to exist in configuration" %
|
|
|
15f218 |
- argv[0],
|
|
|
15f218 |
+ "Node '{0}' does not appear to exist in "
|
|
|
15f218 |
+ "configuration".format(node),
|
|
|
15f218 |
False
|
|
|
15f218 |
)
|
|
|
15f218 |
failed_count += 1
|
|
|
15f218 |
@@ -87,25 +87,30 @@ def node_maintenance(argv, on=True):
|
|
|
15f218 |
else:
|
|
|
15f218 |
nodes.append("")
|
|
|
15f218 |
|
|
|
15f218 |
+ if failed_count > 0:
|
|
|
15f218 |
+ sys.exit(1)
|
|
|
15f218 |
+
|
|
|
15f218 |
for node in nodes:
|
|
|
15f218 |
- node = ["-N", node] if node else []
|
|
|
15f218 |
+ node_attr = ["-N", node] if node else []
|
|
|
15f218 |
output, retval = utils.run(
|
|
|
15f218 |
["crm_attribute", "-t", "nodes", "-n", "maintenance"] + action +
|
|
|
15f218 |
- node
|
|
|
15f218 |
+ node_attr
|
|
|
15f218 |
)
|
|
|
15f218 |
if retval != 0:
|
|
|
15f218 |
- node_name = ("node '%s'" % node) if argv else "current node"
|
|
|
15f218 |
+ node_name = ("node '{0}'".format(node)) if argv else "current node"
|
|
|
15f218 |
failed_count += 1
|
|
|
15f218 |
if on:
|
|
|
15f218 |
utils.err(
|
|
|
15f218 |
- "Unable to put %s to maintenance mode.\n%s" %
|
|
|
15f218 |
- (node_name, output),
|
|
|
15f218 |
+ "Unable to put {0} to maintenance mode: {1}".format(
|
|
|
15f218 |
+ node_name, output
|
|
|
15f218 |
+ ),
|
|
|
15f218 |
False
|
|
|
15f218 |
)
|
|
|
15f218 |
else:
|
|
|
15f218 |
utils.err(
|
|
|
15f218 |
- "Unable to remove %s from maintenance mode.\n%s" %
|
|
|
15f218 |
- (node_name, output),
|
|
|
15f218 |
+ "Unable to remove {0} from maintenance mode: {1}".format(
|
|
|
15f218 |
+ node_name, output
|
|
|
15f218 |
+ ),
|
|
|
15f218 |
False
|
|
|
15f218 |
)
|
|
|
15f218 |
if failed_count > 0:
|
|
|
15f218 |
diff --git a/pcs/test/test_node.py b/pcs/test/test_node.py
|
|
|
15f218 |
index 6f03112..785c711 100644
|
|
|
15f218 |
--- a/pcs/test/test_node.py
|
|
|
15f218 |
+++ b/pcs/test/test_node.py
|
|
|
15f218 |
@@ -88,11 +88,14 @@ Node Attributes:
|
|
|
15f218 |
"""
|
|
|
15f218 |
ac(expected_out, output)
|
|
|
15f218 |
|
|
|
15f218 |
- output, returnVal = pcs(temp_cib, "node maintenance nonexistant-node")
|
|
|
15f218 |
+ output, returnVal = pcs(
|
|
|
15f218 |
+ temp_cib, "node maintenance nonexistant-node and-another"
|
|
|
15f218 |
+ )
|
|
|
15f218 |
self.assertEqual(returnVal, 1)
|
|
|
15f218 |
self.assertEqual(
|
|
|
15f218 |
output,
|
|
|
15f218 |
"Error: Node 'nonexistant-node' does not appear to exist in configuration\n"
|
|
|
15f218 |
+ "Error: Node 'and-another' does not appear to exist in configuration\n"
|
|
|
15f218 |
)
|
|
|
15f218 |
output, _ = pcs(temp_cib, "property")
|
|
|
15f218 |
expected_out = """\
|
|
|
15f218 |
@@ -134,11 +137,14 @@ Cluster Properties:
|
|
|
15f218 |
"""
|
|
|
15f218 |
ac(expected_out, output)
|
|
|
15f218 |
|
|
|
15f218 |
- output, returnVal = pcs(temp_cib, "node unmaintenance nonexistant-node")
|
|
|
15f218 |
+ output, returnVal = pcs(
|
|
|
15f218 |
+ temp_cib, "node unmaintenance nonexistant-node and-another"
|
|
|
15f218 |
+ )
|
|
|
15f218 |
self.assertEqual(returnVal, 1)
|
|
|
15f218 |
self.assertEqual(
|
|
|
15f218 |
output,
|
|
|
15f218 |
"Error: Node 'nonexistant-node' does not appear to exist in configuration\n"
|
|
|
15f218 |
+ "Error: Node 'and-another' does not appear to exist in configuration\n"
|
|
|
15f218 |
)
|
|
|
15f218 |
output, _ = pcs(temp_cib, "property")
|
|
|
15f218 |
expected_out = """\
|
|
|
15f218 |
--
|
|
|
15f218 |
1.8.3.1
|
|
|
15f218 |
|