1
0
Fork 0
mirror of https://github.com/Corsinvest/cv4pve-pepper.git synced 2025-02-12 10:01:53 +00:00

Add Proxy

#8
This commit is contained in:
Daniele Corsini 2020-10-12 17:48:19 +02:00
parent df1dbcba0a
commit 97688723a2
3 changed files with 20 additions and 5 deletions

View file

@ -20,7 +20,10 @@ Options:
--api-token Api token format 'USER@REALM!TOKENID=UUID'. Require Proxmox VE 6.2 or later
--username User name <username>@<realm>
--password The password. Specify 'file:path_file' to store password in file.
--vmid The id or name VM/CT
--vmid The id or name VM
--proxy SPICE proxy server. This can be used by the client to specify the proxy server.
All nodes in a cluster runs 'spiceproxy', so it is up to the client to choose one.
By default, we return the node where the VM is currently running.
--viewer Executable SPICE client remote viewer
Commands:

View file

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<Version>1.3.5</Version>
<Version>1.3.6</Version>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyName>cv4pve-pepper</AssemblyName>
<Company>Corsinvest Srl</Company>
@ -19,6 +19,6 @@
<TrimmerRootAssembly Include="System.Net.WebClient" />
<!-- <ProjectReference Include="..\..\..\cv4pve-api-dotnet\src\Corsinvest.ProxmoxVE.Api.Shell\Corsinvest.ProxmoxVE.Api.Shell.csproj" /> -->
<PackageReference Include="Corsinvest.ProxmoxVE.Api.Shell" Version="2.6.7" />
<PackageReference Include="Corsinvest.ProxmoxVE.Api.Shell" Version="2.6.9" />
</ItemGroup>
</Project>

View file

@ -27,17 +27,29 @@ namespace Corsinvest.ProxmoxVE.Pepper
var optVmId = app.VmIdOrNameOption().DependOn(app, CommandOptionExtension.HOST_OPTION_NAME);
var optProxy = app.Option("--proxy",
@"SPICE proxy server. This can be used by the client to specify the proxy server." +
" All nodes in a cluster runs 'spiceproxy', so it is up to the client to choose one." +
" By default, we return the node where the VM is currently running.",
CommandOptionType.SingleValue);
var optRemoteViewer = app.Option("--viewer",
"Executable SPICE client remote viewer",
CommandOptionType.SingleValue)
.DependOn(app, CommandOptionExtension.HOST_OPTION_NAME);
optRemoteViewer.Accepts().ExistingFile();
app.OnExecute(() =>
{
var fileName = Path.GetTempFileName().Replace(".tmp", ".vv");
var client = app.ClientTryLogin();
var ret = SpiceHelper.CreateFileSpaceClient(client, optVmId.Value(), fileName);
var ret = SpiceHelper.CreateFileSpaceClient(client,
optVmId.Value(),
optProxy.HasValue() ? optProxy.Value() : null,
fileName);
if (ret)
{
@ -78,7 +90,7 @@ namespace Corsinvest.ProxmoxVE.Pepper
}
else
{
if(!client.LastResult.IsSuccessStatusCode)
if (!client.LastResult.IsSuccessStatusCode)
{
app.Out.WriteLine($"Error: {client.LastResult.ReasonPhrase}");
}