ProxmoxConnector.Integration.Corsinvest

master
Tudor Stanciu 2022-02-18 10:13:25 +02:00
parent 747948b8bb
commit 4dfde81ecf
9 changed files with 127 additions and 6 deletions

View File

@ -22,13 +22,19 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{FA6E3503-ADF
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "server", "server", "{2D975A5D-3612-4536-A501-248F6B9A5AC2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProxmoxConnector.Server", "src\server\ProxmoxConnector.Server\ProxmoxConnector.Server.csproj", "{340A176C-AE9F-4F01-A82F-AAAAF140A728}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProxmoxConnector.Server", "src\server\ProxmoxConnector.Server\ProxmoxConnector.Server.csproj", "{340A176C-AE9F-4F01-A82F-AAAAF140A728}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProxmoxConnector.Server.Application", "src\server\ProxmoxConnector.Server.Application\ProxmoxConnector.Server.Application.csproj", "{96718232-FFFA-4E3C-B068-53C679B60669}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProxmoxConnector.Server.Application", "src\server\ProxmoxConnector.Server.Application\ProxmoxConnector.Server.Application.csproj", "{96718232-FFFA-4E3C-B068-53C679B60669}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProxmoxConnector.Server.Domain", "src\server\ProxmoxConnector.Server.Domain\ProxmoxConnector.Server.Domain.csproj", "{57F68716-671A-476C-9F07-E0E86FDE6940}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProxmoxConnector.Server.Domain", "src\server\ProxmoxConnector.Server.Domain\ProxmoxConnector.Server.Domain.csproj", "{57F68716-671A-476C-9F07-E0E86FDE6940}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProxmoxConnector.Server.Domain.Data", "src\server\ProxmoxConnector.Server.Domain.Data\ProxmoxConnector.Server.Domain.Data.csproj", "{65C2410A-57CA-45A1-9E98-A12633A32A3E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProxmoxConnector.Server.Domain.Data", "src\server\ProxmoxConnector.Server.Domain.Data\ProxmoxConnector.Server.Domain.Data.csproj", "{65C2410A-57CA-45A1-9E98-A12633A32A3E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "integration", "integration", "{9E74B673-1931-4E5F-8BEF-122B742A3261}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProxmoxConnector.Integration.Corsinvest", "src\integration\ProxmoxConnector.Integration.Corsinvest\ProxmoxConnector.Integration.Corsinvest.csproj", "{A39B9288-3D3D-41FD-B18C-C5805E6A9CAC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProxmoxConnector.Integration.Abstractions", "src\integration\ProxmoxConnector.Integration.Abstractions\ProxmoxConnector.Integration.Abstractions.csproj", "{A5998190-6649-4C43-BB6A-226C2BF76E11}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -56,6 +62,14 @@ Global
{65C2410A-57CA-45A1-9E98-A12633A32A3E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{65C2410A-57CA-45A1-9E98-A12633A32A3E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{65C2410A-57CA-45A1-9E98-A12633A32A3E}.Release|Any CPU.Build.0 = Release|Any CPU
{A39B9288-3D3D-41FD-B18C-C5805E6A9CAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A39B9288-3D3D-41FD-B18C-C5805E6A9CAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A39B9288-3D3D-41FD-B18C-C5805E6A9CAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A39B9288-3D3D-41FD-B18C-C5805E6A9CAC}.Release|Any CPU.Build.0 = Release|Any CPU
{A5998190-6649-4C43-BB6A-226C2BF76E11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A5998190-6649-4C43-BB6A-226C2BF76E11}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A5998190-6649-4C43-BB6A-226C2BF76E11}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A5998190-6649-4C43-BB6A-226C2BF76E11}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -67,6 +81,9 @@ Global
{96718232-FFFA-4E3C-B068-53C679B60669} = {2D975A5D-3612-4536-A501-248F6B9A5AC2}
{57F68716-671A-476C-9F07-E0E86FDE6940} = {2D975A5D-3612-4536-A501-248F6B9A5AC2}
{65C2410A-57CA-45A1-9E98-A12633A32A3E} = {2D975A5D-3612-4536-A501-248F6B9A5AC2}
{9E74B673-1931-4E5F-8BEF-122B742A3261} = {FA6E3503-ADFD-46D3-912B-D4A05BF4407F}
{A39B9288-3D3D-41FD-B18C-C5805E6A9CAC} = {9E74B673-1931-4E5F-8BEF-122B742A3261}
{A5998190-6649-4C43-BB6A-226C2BF76E11} = {9E74B673-1931-4E5F-8BEF-122B742A3261}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2BE248DF-16B1-42EF-9A34-C3FE5359D418}

View File

@ -16,3 +16,8 @@ https://pve.proxmox.com/wiki/Proxmox_VE_API
https://forum.proxmox.com/threads/shutdown-the-server-via-api.98125/
https://github.com/Corsinvest/cv4pve-api-dotnet
***REMOVED***
https://***REMOVED******REMOVED***/
https://***REMOVED******REMOVED***/api2/extjs/access/ticket

View File

@ -0,0 +1,6 @@
namespace ProxmoxConnector.Integration.Abstractions
{
public interface IPveConnector
{
}
}

View File

@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,15 @@
using Microsoft.Extensions.DependencyInjection;
using ProxmoxConnector.Integration.Abstractions;
using ProxmoxConnector.Integration.Corsinvest.Services;
using System;
namespace ProxmoxConnector.Integration.Corsinvest
{
public static class DependencyInjectionExtensions
{
public static void AddCorsinvestPveConnector(this IServiceCollection services)
{
services.AddScoped<IPveConnector, PveConnector>();
}
}
}

View File

@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Corsinvest.ProxmoxVE.Api" Version="7.2.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ProxmoxConnector.Integration.Abstractions\ProxmoxConnector.Integration.Abstractions.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,51 @@
using Corsinvest.ProxmoxVE.Api;
using Newtonsoft.Json;
using ProxmoxConnector.Integration.Abstractions;
using System;
using System.Threading.Tasks;
namespace ProxmoxConnector.Integration.Corsinvest.Services
{
internal class PveConnector : IPveConnector
{
public async Task Test()
{
var client = new PveClient("***REMOVED***"); ***REMOVED***
if (await client.Login("root", "password"))
{
var vm = client.Nodes["pve1"].Qemu[100];
//config vm
var config = await vm.Config.VmConfig();
Console.WriteLine(JsonConvert.SerializeObject(config.Response, Formatting.Indented));
//create snapshot
var response = await vm.Snapshot.Snapshot("pippo2311");
//update snapshot description
await vm.Snapshot["pippo2311"].Config.UpdateSnapshotConfig("description");
//delete snapshot
await vm.Snapshot["pippo2311"].Delsnapshot();
//list of snapshot
foreach (var snapshot in (await vm.Snapshot.SnapshotList()).Response.data)
{
Console.WriteLine(JsonConvert.SerializeObject(snapshot, Formatting.Indented));
Console.WriteLine(snapshot.name);
}
//change response type from json to png
client.ResponseType = ResponseType.Png;
var dataImg = (await client.Nodes["pve1"].Rrd.Rrd("cpu", "day")).Response;
Console.WriteLine("<img src=\"{dataImg}\" \\>");
}
//using Api Token
var client2 = new PveClient("10.92.100.33");
client2.ApiToken = "root@pam!qqqqqq=***REMOVED***";
var version = await client2.Version.Version();
Console.WriteLine(JsonConvert.SerializeObject(version.Response.data, Formatting.Indented));
}
}
}

View File

@ -0,0 +1,5 @@
Corsinvest.ProxmoxVE.Api
https://github.com/Corsinvest/cv4pve-api-dotnet
Corsinvest.ProxmoxVE.Api.Extension
https://www.nuget.org/packages/Corsinvest.ProxmoxVE.Api.Extension/3.2.0#show-readme-container

View File

@ -7,7 +7,6 @@
<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="$(AutoMapperExtensionsPackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="$(NewtonsoftJsonPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="$(MicrosoftExtensionsHostingPackageVersion)" />
<PackageReference Include="NDB.Extensions.Swagger" Version="$(NDBExtensionsSwaggerPackageVersion)" />
<PackageReference Include="NDB.Security.Authentication.Identity" Version="$(NDBSecurityAuthenticationIdentityPackageVersion)" />
<PackageReference Include="Serilog.AspNetCore" Version="$(SerilogAspNetCorePackageVersion)" />