From ba462e4b528ab680fa4bce8b7ed0e1db71ce782f Mon Sep 17 00:00:00 2001 From: ashwini-orchestral <72917414+ashwini-orchestral@users.noreply.github.com> Date: Fri, 14 Jan 2022 13:02:41 +0530 Subject: [PATCH 1/5] WinRM parameter passing fails for larger scripts --- contrib/runners/winrm_runner/winrm_runner/winrm_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/runners/winrm_runner/winrm_runner/winrm_base.py b/contrib/runners/winrm_runner/winrm_runner/winrm_base.py index 232c902b62..5903d5d6a0 100644 --- a/contrib/runners/winrm_runner/winrm_runner/winrm_base.py +++ b/contrib/runners/winrm_runner/winrm_runner/winrm_base.py @@ -403,7 +403,7 @@ def _run_ps_script(self, script, params=None): # the following wraps the script (from the file) in a script block ( {} ) # executes it, passing in the parameters built above # https://docs.microsoft.com/en-us/powershell/scripting/core-powershell/console/powershell.exe-command-line-help - ps = "& {%s}" % (tmp_script) + ps = tmp_script if params: ps += " " + params return self._run_ps(ps) From f08d1f4539be9a237443ca640fb349e8f486193e Mon Sep 17 00:00:00 2001 From: ashwini-orchestral <72917414+ashwini-orchestral@users.noreply.github.com> Date: Fri, 14 Jan 2022 13:48:39 +0530 Subject: [PATCH 2/5] Modified testcases for WinRM parameter passing fails for larger scripts --- contrib/runners/winrm_runner/tests/unit/test_winrm_base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/runners/winrm_runner/tests/unit/test_winrm_base.py b/contrib/runners/winrm_runner/tests/unit/test_winrm_base.py index 1ff9f2ce1d..1fb5f8ac2e 100644 --- a/contrib/runners/winrm_runner/tests/unit/test_winrm_base.py +++ b/contrib/runners/winrm_runner/tests/unit/test_winrm_base.py @@ -909,7 +909,7 @@ def test__run_ps_script(self, mock_tmp_script, mock_run_ps): mock_tmp_script.assert_called_with( "[System.IO.Path]::GetTempPath()", "$PSVersionTable" ) - mock_run_ps.assert_called_with("& {C:\\tmpscript.ps1}") + mock_run_ps.assert_called_with("C:\\tmpscript.ps1") @mock.patch("winrm_runner.winrm_base.WinRmBaseRunner._run_ps") @mock.patch("winrm_runner.winrm_base.WinRmBaseRunner._tmp_script") @@ -923,7 +923,7 @@ def test__run_ps_script_with_params(self, mock_tmp_script, mock_run_ps): mock_tmp_script.assert_called_with( "[System.IO.Path]::GetTempPath()", "Get-ChildItem" ) - mock_run_ps.assert_called_with("& {C:\\tmpscript.ps1} -param1 value1 arg1") + mock_run_ps.assert_called_with("C:\\tmpscript.ps1 -param1 value1 arg1") @mock.patch("winrm_runner.winrm_base.WinRmBaseRunner._run_ps") def test__run_ps_or_raise(self, mock_run_ps): From ed9702ea687b729842dc7d4396f35d318afedc38 Mon Sep 17 00:00:00 2001 From: ashwini-orchestral <72917414+ashwini-orchestral@users.noreply.github.com> Date: Fri, 14 Jan 2022 16:47:34 +0530 Subject: [PATCH 3/5] Minor fix --- contrib/runners/winrm_runner/winrm_runner/winrm_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/runners/winrm_runner/winrm_runner/winrm_base.py b/contrib/runners/winrm_runner/winrm_runner/winrm_base.py index 5903d5d6a0..8d35703138 100644 --- a/contrib/runners/winrm_runner/winrm_runner/winrm_base.py +++ b/contrib/runners/winrm_runner/winrm_runner/winrm_base.py @@ -401,7 +401,7 @@ def _run_ps_script(self, script, params=None): # handle deletion of the temporary file on exit of the with block with self._tmp_script(tmp_dir, script) as tmp_script: # the following wraps the script (from the file) in a script block ( {} ) - # executes it, passing in the parameters built above + # executes it, passing in the parameters built above. # https://docs.microsoft.com/en-us/powershell/scripting/core-powershell/console/powershell.exe-command-line-help ps = tmp_script if params: From ed516e18365f12c498fc72e248a02c0d96497fa5 Mon Sep 17 00:00:00 2001 From: ashwini-orchestral <72917414+ashwini-orchestral@users.noreply.github.com> Date: Wed, 9 Feb 2022 12:05:41 +0530 Subject: [PATCH 4/5] Updated Changelog.rst for WinRM issue fix --- CHANGELOG.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 4715252e39..81c4253246 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,6 +7,10 @@ in development Fixed ~~~~~ +* Fix issue of WinRM parameter passing fails for larger scripts.#5538 + + Contributed by @ashwini-orchestral + * Fix Type error for ``time_diff`` critera comparison. convert the timediff value as float to match ``timedelta.total_seconds()`` return. #5462 From c0b6e0bf404a8e249c2eda5078b0c39623b90e63 Mon Sep 17 00:00:00 2001 From: ashwini-orchestral <72917414+ashwini-orchestral@users.noreply.github.com> Date: Wed, 9 Feb 2022 13:33:50 +0530 Subject: [PATCH 5/5] Fixed lint error --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 81c4253246..b73979cb35 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -10,7 +10,7 @@ Fixed * Fix issue of WinRM parameter passing fails for larger scripts.#5538 Contributed by @ashwini-orchestral - + * Fix Type error for ``time_diff`` critera comparison. convert the timediff value as float to match ``timedelta.total_seconds()`` return. #5462