SshProxmoxHostCommandExecutor
Executes bash commands on a Proxmox VE host over the Proxmox SSH channel (directly or through a peer jump host).
public sealed class SshProxmoxHostCommandExecutor : IProxmoxHostCommandExecutor
1. Constructors
1.1. SshProxmoxHostCommandExecutor(Proxmox, ILogger, string)
Initializes a new instance of the SshProxmoxHostCommandExecutor class.
public SshProxmoxHostCommandExecutor(Proxmox client, ILogger logger, string jumpTargetHost = null)
| Name | Type | Description |
|---|---|---|
client |
Proxmox |
Connected Proxmox client whose SSH channel executes commands. |
logger |
ILogger |
Logger every command is written to before it runs. |
jumpTargetHost |
string |
Optional target host IP/hostname to hop to via root SSH from client when the target only accepts cluster-peer SSH keys. |
2. Fields
2.1. ReturnCodeMarker
Marker appended to remote command output to recover the numeric exit code.
public const string ReturnCodeMarker
3. Methods
3.1. BuildWrappedCommand(string, string)
Encodes bashCommand as base64 and wraps it with stderr folding and exit-code marker.
public static string BuildWrappedCommand(string bashCommand, string jumpHost = null)
| Name | Type | Description |
|---|---|---|
bashCommand |
string |
Bash script to run on the target Proxmox host. |
jumpHost |
string |
Optional SSH hop target from the connected Proxmox node. |
Returns: string — Single-line shell command safe for Proxmox.Execute.
3.2. ParseMarkedOutput(string)
Parses combined stdout/stderr output ending with ReturnCodeMarker into a ProxmoxHostCommandResult.
public static ProxmoxHostCommandResult ParseMarkedOutput(string rawOutput)
| Name | Type | Description |
|---|---|---|
rawOutput |
string |
Raw output returned from the SSH channel. |
Returns: ProxmoxHostCommandResult — Parsed command result.
3.3. Run(string, TimeSpan)
Runs bashCommand on the target Proxmox host with a timeout.
public ProxmoxHostCommandResult Run(string bashCommand, TimeSpan timeout)
| Name | Type | Description |
|---|---|---|
bashCommand |
string |
Bash command line to execute. |
timeout |
TimeSpan |
Maximum execution duration. |
Returns: ProxmoxHostCommandResult — Command execution result.