Skip to content

Commit 6b46527

Browse files
jacklacey11copybara-github
authored andcommitted
Update base Windows mixin to offer RemoteCommandWithReturnCode and the existing RemoteCommand.
PiperOrigin-RevId: 845429895
1 parent 9bea38c commit 6b46527

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

perfkitbenchmarker/windows_virtual_machine.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ def RobustRemoteCommand(
183183
"""
184184
return self.RemoteCommand(command, ignore_failure, timeout)
185185

186-
@winrm_retry
187186
def RemoteCommand(
188187
self,
189188
command: str,
@@ -202,6 +201,33 @@ def RemoteCommand(
202201
Returns:
203202
A tuple of stdout and stderr from running the command.
204203
204+
Raises:
205+
RemoteCommandError: If there was a problem issuing the command or the
206+
command timed out.
207+
"""
208+
return self.RemoteCommandWithReturnCode(
209+
command, ignore_failure, timeout
210+
)[:2]
211+
212+
@winrm_retry
213+
def RemoteCommandWithReturnCode(
214+
self,
215+
command: str,
216+
ignore_failure: bool = False,
217+
timeout: float | None = None,
218+
) -> Tuple[str, str, int]:
219+
"""Runs a powershell command on the VM.
220+
221+
Args:
222+
command: A valid powershell command.
223+
ignore_failure: Ignore any failure if set to true.
224+
timeout: Float. A timeout in seconds for the command. If None is passed,
225+
no timeout is applied. Timeout kills the winrm session which then kills
226+
the process being executed.
227+
228+
Returns:
229+
A tuple of stdout, stderr, and return code from running the command.
230+
205231
Raises:
206232
RemoteCommandError: If there was a problem issuing the command or the
207233
command timed out.
@@ -259,7 +285,7 @@ def run_command():
259285
)
260286
raise errors.VirtualMachine.RemoteCommandError(error_text)
261287

262-
return stdout, stderr
288+
return stdout, stderr, retcode
263289

264290
def PartitionDisk(self, dev_name, dev_path, num_partitions, partition_size):
265291
raise NotImplementedError()

0 commit comments

Comments
 (0)