Skip to content

Commit

Permalink
Add Proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
franklupo committed Oct 12, 2020
1 parent df1dbcb commit 9768872
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
5 changes: 4 additions & 1 deletion README.md
Expand Up @@ -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:
Expand Down
@@ -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>
Expand All @@ -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>
16 changes: 14 additions & 2 deletions src/Corsinvest.ProxmoxVE.Pepper/Program.cs
Expand Up @@ -27,17 +27,29 @@ static int Main(string[] args)

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)
{
Expand Down Expand Up @@ -78,7 +90,7 @@ static int Main(string[] args)
}
else
{
if(!client.LastResult.IsSuccessStatusCode)
if (!client.LastResult.IsSuccessStatusCode)
{
app.Out.WriteLine($"Error: {client.LastResult.ReasonPhrase}");
}
Expand Down

0 comments on commit 9768872

Please sign in to comment.