Blame SOURCES/bz1475318-01-rfe-validate-nodes-watchdog-device-by-using-sbd.patch

be1b1f
From 2e5005b822b1dab3d074361f46607af3bd696b71 Mon Sep 17 00:00:00 2001
be1b1f
From: Ivan Devat <idevat@redhat.com>
be1b1f
Date: Mon, 6 Aug 2018 08:43:47 +0200
be1b1f
Subject: [PATCH] squash bz1475318 RFE: Validate node's watchdog dev
be1b1f
be1b1f
9d95b73a1b22 do not connect stdin of subprocess to pcs's stdin
be1b1f
be1b1f
7607976d478e fix tests
be1b1f
---
be1b1f
 pcs/lib/external.py           | 10 +++++++++-
be1b1f
 pcs/test/test_lib_external.py |  8 ++++----
be1b1f
 pcs/utils.py                  |  8 +++++++-
be1b1f
 3 files changed, 20 insertions(+), 6 deletions(-)
be1b1f
be1b1f
diff --git a/pcs/lib/external.py b/pcs/lib/external.py
be1b1f
index 5507543f..fe17a864 100644
be1b1f
--- a/pcs/lib/external.py
be1b1f
+++ b/pcs/lib/external.py
be1b1f
@@ -25,6 +25,12 @@ try:
be1b1f
 except ImportError:
be1b1f
     # python3
be1b1f
     from urllib.parse import urlencode as urllib_urlencode
be1b1f
+try:
be1b1f
+    # python 3
be1b1f
+    from subprocess import DEVNULL
be1b1f
+except ImportError:
be1b1f
+    # python 2
be1b1f
+    DEVNULL = open(os.devnull, "r")
be1b1f
 
be1b1f
 from pcs import settings
be1b1f
 from pcs.common import pcs_pycurl as pycurl
be1b1f
@@ -401,7 +407,9 @@ class CommandRunner(object):
be1b1f
             process = subprocess.Popen(
be1b1f
                 args,
be1b1f
                 # Some commands react differently if they get anything via stdin
be1b1f
-                stdin=(subprocess.PIPE if stdin_string is not None else None),
be1b1f
+                stdin=(
be1b1f
+                    subprocess.PIPE if stdin_string is not None else DEVNULL
be1b1f
+                ),
be1b1f
                 stdout=subprocess.PIPE,
be1b1f
                 stderr=subprocess.PIPE,
be1b1f
                 preexec_fn=(
be1b1f
diff --git a/pcs/test/test_lib_external.py b/pcs/test/test_lib_external.py
be1b1f
index b249c47a..85c52a18 100644
be1b1f
--- a/pcs/test/test_lib_external.py
be1b1f
+++ b/pcs/test/test_lib_external.py
be1b1f
@@ -74,7 +74,7 @@ class CommandRunnerTest(TestCase):
be1b1f
         self.assert_popen_called_with(
be1b1f
             mock_popen,
be1b1f
             command,
be1b1f
-            {"env": {}, "stdin": None,}
be1b1f
+            {"env": {}, "stdin": lib.DEVNULL,}
be1b1f
         )
be1b1f
         logger_calls = [
be1b1f
             mock.call("Running: {0}\nEnvironment:".format(command_str)),
be1b1f
@@ -158,7 +158,7 @@ class CommandRunnerTest(TestCase):
be1b1f
         self.assert_popen_called_with(
be1b1f
             mock_popen,
be1b1f
             command,
be1b1f
-            {"env": {"a": "a", "b": "B", "c": "{C}"}, "stdin": None,}
be1b1f
+            {"env": {"a": "a", "b": "B", "c": "{C}"}, "stdin": lib.DEVNULL,}
be1b1f
         )
be1b1f
         logger_calls = [
be1b1f
             mock.call(
be1b1f
@@ -327,7 +327,7 @@ class CommandRunnerTest(TestCase):
be1b1f
         self.assert_popen_called_with(
be1b1f
             mock_popen,
be1b1f
             command,
be1b1f
-            {"env": {}, "stdin": None,}
be1b1f
+            {"env": {}, "stdin": lib.DEVNULL,}
be1b1f
         )
be1b1f
         logger_calls = [
be1b1f
             mock.call("Running: {0}\nEnvironment:".format(command_str)),
be1b1f
@@ -376,7 +376,7 @@ class CommandRunnerTest(TestCase):
be1b1f
         self.assert_popen_called_with(
be1b1f
             mock_popen,
be1b1f
             command,
be1b1f
-            {"env": {}, "stdin": None,}
be1b1f
+            {"env": {}, "stdin": lib.DEVNULL,}
be1b1f
         )
be1b1f
         logger_calls = [
be1b1f
             mock.call("Running: {0}\nEnvironment:".format(command_str)),
be1b1f
diff --git a/pcs/utils.py b/pcs/utils.py
be1b1f
index eb02ca34..347ad73e 100644
be1b1f
--- a/pcs/utils.py
be1b1f
+++ b/pcs/utils.py
be1b1f
@@ -86,6 +86,12 @@ try:
be1b1f
 except ImportError:
be1b1f
     # python3
be1b1f
     from urllib.parse import urlencode as urllib_urlencode
be1b1f
+try:
be1b1f
+    # python 3
be1b1f
+    from subprocess import DEVNULL
be1b1f
+except ImportError:
be1b1f
+    # python 2
be1b1f
+    DEVNULL = open(os.devnull, "r")
be1b1f
 
be1b1f
 
be1b1f
 PYTHON2 = (sys.version_info.major == 2)
be1b1f
@@ -1035,7 +1041,7 @@ def run(
be1b1f
         if string_for_stdin != None:
be1b1f
             stdin_pipe = subprocess.PIPE
be1b1f
         else:
be1b1f
-            stdin_pipe = None
be1b1f
+            stdin_pipe = DEVNULL
be1b1f
 
be1b1f
         p = subprocess.Popen(
be1b1f
             args,
be1b1f
-- 
be1b1f
2.13.6
be1b1f