Blame SOURCES/bz1661059-01-re-add-and-deprecate-pcs-resource-show.patch

50c00a
From be56e49edd4e844e20c8b41a05b42728f66e1455 Mon Sep 17 00:00:00 2001
50c00a
From: Tomas Jelinek <tojeline@redhat.com>
50c00a
Date: Fri, 18 Jan 2019 17:18:18 +0100
50c00a
Subject: [PATCH] re-add and deprecate 'pcs resource show'
50c00a
50c00a
---
50c00a
 pcs/cli/common/parse_args.py           |  6 +++
50c00a
 pcs/cli/common/test/test_parse_args.py |  3 ++
50c00a
 pcs/resource.py                        | 63 ++++++++++++++++++++++++++
50c00a
 pcs/stonith.py                         |  5 ++
50c00a
 4 files changed, 77 insertions(+)
50c00a
50c00a
diff --git a/pcs/cli/common/parse_args.py b/pcs/cli/common/parse_args.py
50c00a
index 9b5a2be6..efce977f 100644
50c00a
--- a/pcs/cli/common/parse_args.py
50c00a
+++ b/pcs/cli/common/parse_args.py
50c00a
@@ -22,6 +22,9 @@ PCS_LONG_OPTIONS = [
50c00a
     "hide-inactive",
50c00a
     # pcs resource (un)manage - enable or disable monitor operations
50c00a
     "monitor",
50c00a
+    # TODO remove
50c00a
+    # used only in deprecated 'pcs resource|stonith show'
50c00a
+    "groups",
50c00a
 ]
50c00a
 
50c00a
 def split_list(arg_list, separator):
50c00a
@@ -319,6 +322,9 @@ class InputModifiers():
50c00a
             "--enable": "--enable" in options,
50c00a
             "--force": "--force" in options,
50c00a
             "--full": "--full" in options,
50c00a
+            # TODO remove
50c00a
+            # used only in deprecated 'pcs resource|stonith show'
50c00a
+            "--groups": "--groups" in options,
50c00a
             "--hide-inactive": "--hide-inactive" in options,
50c00a
             "--interactive": "--interactive" in options,
50c00a
             "--local": "--local" in options,
50c00a
diff --git a/pcs/cli/common/test/test_parse_args.py b/pcs/cli/common/test/test_parse_args.py
50c00a
index 09b98162..56bb2f41 100644
50c00a
--- a/pcs/cli/common/test/test_parse_args.py
50c00a
+++ b/pcs/cli/common/test/test_parse_args.py
50c00a
@@ -496,6 +496,9 @@ class InputModifiersTest(TestCase):
50c00a
             "--enable",
50c00a
             "--force",
50c00a
             "--full",
50c00a
+            # TODO remove
50c00a
+            # used only in deprecated 'pcs resource|stonith show'
50c00a
+            "--groups",
50c00a
             "--hide-inactive",
50c00a
             "--interactive",
50c00a
             "--local",
50c00a
diff --git a/pcs/resource.py b/pcs/resource.py
50c00a
index eaca7126..862553e0 100644
50c00a
--- a/pcs/resource.py
50c00a
+++ b/pcs/resource.py
50c00a
@@ -111,6 +111,10 @@ def resource_cmd(lib, argv, modifiers):
50c00a
             resource_meta(lib, argv_next, modifiers)
50c00a
         elif sub_cmd in {"delete", "remove"}:
50c00a
             resource_remove_cmd(lib, argv_next, modifiers)
50c00a
+        # TODO remove, deprecated command
50c00a
+        # replaced with 'resource status' and 'resource config'
50c00a
+        elif sub_cmd == "show":
50c00a
+            resource_show(lib, argv_next, modifiers)
50c00a
         elif sub_cmd == "status":
50c00a
             resource_status(lib, argv_next, modifiers)
50c00a
         elif sub_cmd == "config":
50c00a
@@ -2225,6 +2229,65 @@ def resource_group_list(lib, argv, modifiers):
50c00a
             line_parts.append(resource.getAttribute("id"))
50c00a
         print(" ".join(line_parts))
50c00a
 
50c00a
+def resource_show(lib, argv, modifiers, stonith=False):
50c00a
+    # TODO remove, deprecated command
50c00a
+    # replaced with 'resource status' and 'resource config'
50c00a
+    """
50c00a
+    Options:
50c00a
+      * -f - CIB file
50c00a
+      * --full - print all configured options
50c00a
+      * --groups - print resource groups
50c00a
+      * --hide-inactive - print only active resources
50c00a
+    """
50c00a
+    modifiers.ensure_only_supported(
50c00a
+        "-f", "--full", "--groups", "--hide-inactive"
50c00a
+    )
50c00a
+    mutually_exclusive_opts = ("--full", "--groups", "--hide-inactive")
50c00a
+    specified_modifiers = [
50c00a
+        opt for opt in mutually_exclusive_opts if modifiers.is_specified(opt)
50c00a
+    ]
50c00a
+    if (len(specified_modifiers) > 1) or (argv and specified_modifiers):
50c00a
+        utils.err(
50c00a
+            "you can specify only one of resource id, {0}".format(
50c00a
+                ", ".join(mutually_exclusive_opts)
50c00a
+            )
50c00a
+        )
50c00a
+
50c00a
+    if modifiers.get("--groups"):
50c00a
+        warn(
50c00a
+            "This command is deprecated and will be removed. "
50c00a
+            "Please use 'pcs resource group list' instead."
50c00a
+        )
50c00a
+        resource_group_list(lib, argv, modifiers.get_subset("-f"))
50c00a
+        return
50c00a
+
50c00a
+    if modifiers.get("--full") or argv:
50c00a
+        warn(
50c00a
+            "This command is deprecated and will be removed. "
50c00a
+            "Please use 'pcs {} config' instead.".format(
50c00a
+                "stonith" if stonith else "resource"
50c00a
+            )
50c00a
+        )
50c00a
+        resource_config(
50c00a
+            lib,
50c00a
+            argv,
50c00a
+            modifiers.get_subset("-f"),
50c00a
+            stonith=stonith
50c00a
+        )
50c00a
+        return
50c00a
+
50c00a
+    warn(
50c00a
+        "This command is deprecated and will be removed. "
50c00a
+        "Please use 'pcs {} status' instead.".format(
50c00a
+            "stonith" if stonith else "resource"
50c00a
+        )
50c00a
+    )
50c00a
+    resource_status(
50c00a
+        lib,
50c00a
+        argv,
50c00a
+        modifiers.get_subset("-f", "--hide-inactive"),
50c00a
+        stonith=stonith
50c00a
+    )
50c00a
 
50c00a
 def resource_status(lib, argv, modifiers, stonith=False):
50c00a
     """
50c00a
diff --git a/pcs/stonith.py b/pcs/stonith.py
50c00a
index 3f08efe3..c5270c84 100644
50c00a
--- a/pcs/stonith.py
50c00a
+++ b/pcs/stonith.py
50c00a
@@ -40,6 +40,11 @@ def stonith_cmd(lib, argv, modifiers):
50c00a
             resource.resource_update(lib, argv_next, modifiers)
50c00a
         elif sub_cmd in {"delete", "remove"}:
50c00a
             resource.resource_remove_cmd(lib, argv_next, modifiers)
50c00a
+        # TODO remove, deprecated command
50c00a
+        # replaced with 'stonith status' and 'stonith config'
50c00a
+        elif sub_cmd == "show":
50c00a
+            resource.resource_show(lib, argv_next, modifiers, stonith=True)
50c00a
+            print_stonith_levels(lib)
50c00a
         elif sub_cmd == "status":
50c00a
             resource.resource_status(lib, argv_next, modifiers, stonith=True)
50c00a
             print_stonith_levels(lib)
50c00a
-- 
50c00a
2.17.0
50c00a