1
0
Fork 0
mirror of https://github.com/Corsinvest/cv4pve-pepper.git synced 2025-03-09 15:39:57 +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 --api-token Api token format 'USER@REALM!TOKENID=UUID'. Require Proxmox VE 6.2 or later
--username User name <username>@<realm> --username User name <username>@<realm>
--password The password. Specify 'file:path_file' to store password in file. --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 --viewer Executable SPICE client remote viewer
Commands: Commands:

View file

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

View file

@ -27,17 +27,29 @@ namespace Corsinvest.ProxmoxVE.Pepper
var optVmId = app.VmIdOrNameOption().DependOn(app, CommandOptionExtension.HOST_OPTION_NAME); 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", var optRemoteViewer = app.Option("--viewer",
"Executable SPICE client remote viewer", "Executable SPICE client remote viewer",
CommandOptionType.SingleValue) CommandOptionType.SingleValue)
.DependOn(app, CommandOptionExtension.HOST_OPTION_NAME); .DependOn(app, CommandOptionExtension.HOST_OPTION_NAME);
optRemoteViewer.Accepts().ExistingFile(); optRemoteViewer.Accepts().ExistingFile();
app.OnExecute(() => app.OnExecute(() =>
{ {
var fileName = Path.GetTempFileName().Replace(".tmp", ".vv"); var fileName = Path.GetTempFileName().Replace(".tmp", ".vv");
var client = app.ClientTryLogin(); 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) if (ret)
{ {
@ -78,7 +90,7 @@ namespace Corsinvest.ProxmoxVE.Pepper
} }
else else
{ {
if(!client.LastResult.IsSuccessStatusCode) if (!client.LastResult.IsSuccessStatusCode)
{ {
app.Out.WriteLine($"Error: {client.LastResult.ReasonPhrase}"); app.Out.WriteLine($"Error: {client.LastResult.ReasonPhrase}");
} }