From 45a36f3632343b94801895d303ab7fd7f60a9183 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Wed, 10 Oct 2012 13:16:30 +0200 Subject: [PATCH] cluster epo: Fix bug where IndexError is raised MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updating the βnode_query_listβ variable would fail if no arguments were passed and the β--allβ option wasn't specified. A follow-up patch will add unit tests. Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- lib/client/gnt_cluster.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/client/gnt_cluster.py b/lib/client/gnt_cluster.py index faebcf772..42f671a8d 100644 --- a/lib/client/gnt_cluster.py +++ b/lib/client/gnt_cluster.py @@ -1427,13 +1427,12 @@ def Epo(opts, args): fields=["name", "master", "pinst_list", "sinst_list", "powered", "offline"], use_locking=False) + + all_nodes = map(compat.fst, result) node_list = [] inst_map = {} for (idx, (node, master, pinsts, sinsts, powered, offline)) in enumerate(result): - # Normalize the node_query_list as well - if not opts.show_all: - node_query_list[idx] = node if not offline: for inst in (pinsts + sinsts): if inst in inst_map: @@ -1461,11 +1460,11 @@ def Epo(opts, args): elif not offline or (offline and powered): node_list.append(node) - if not opts.force and not ConfirmOperation(node_query_list, "nodes", "epo"): + if not opts.force and not ConfirmOperation(all_nodes, "nodes", "epo"): return constants.EXIT_FAILURE if opts.on: - return _EpoOn(opts, node_query_list, node_list, inst_map) + return _EpoOn(opts, all_nodes, node_list, inst_map) else: return _EpoOff(opts, node_list, inst_map) -- GitLab