Tested proxmox integration package

master
Tudor Stanciu 2022-03-15 19:34:38 +02:00
parent cea69ace15
commit 6e7d32220a
5 changed files with 47 additions and 15 deletions

View File

@ -13,7 +13,7 @@ namespace ProxmoxConnector.Integration.Corsinvest.Services
var client = new PveClient("***REMOVED***"); ***REMOVED***
if (await client.Login(***REMOVED***))
{
var vm = client.Nodes["pve1"].Qemu[100];
var vm = client.Nodes["pve-test1"].Qemu[100];
//config vm
var config = await vm.Config.VmConfig();
@ -37,16 +37,16 @@ namespace ProxmoxConnector.Integration.Corsinvest.Services
//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}\" \\>");
var dataImg = (await client.Nodes["pve-test1"].Rrd.Rrd("cpu", "day")).Response;
Console.WriteLine($"<img src=\"{dataImg}\" \\>");
}
}
public async Task TestWithToken()
{
//using Api Token
var client2 = new PveClient("10.92.100.33");
client2.ApiToken = "root@pam!qqqqqq=***REMOVED***";
var client2 = new PveClient("***REMOVED***");
client2.ApiToken = "root@pam!test-token=***REMOVED***";
var version = await client2.Version.Version();
Console.WriteLine(JsonConvert.SerializeObject(version.Response.data, Formatting.Indented));
}

File diff suppressed because one or more lines are too long

View File

@ -29,6 +29,7 @@ namespace ProxmoxConnector.Server.Application.Queries
public async Task<Model> Handle(Query request, CancellationToken cancellationToken)
{
await _pveConnector.TestWithLogin();
await _pveConnector.TestWithToken();
return await Task.FromResult(new Model() { Msg = "-!-" });
}

View File

@ -2,9 +2,7 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using ProxmoxConnector.Server.Application.Queries.System;
using System;
using System.Threading.Tasks;
namespace ProxmoxConnector.Server.Controllers
{
@ -29,13 +27,5 @@ namespace ProxmoxConnector.Server.Controllers
_logger.LogInformation("Ping");
return Ok($"Ping success. System datetime: {DateTime.Now}");
}
[AllowAnonymous]
[HttpGet("version")]
public async Task<IActionResult> GetSystemVersion([FromRoute] GetSystemVersion.Query query)
{
var result = await _mediator.Send(query);
return Ok(result);
}
}
}

View File

@ -0,0 +1,29 @@
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using ProxmoxConnector.Server.Application.Queries.System;
using System.Threading.Tasks;
namespace ProxmoxConnector.Server.Controllers
{
[Authorize]
[ApiController]
[Route("system")]
public class SystemController : ControllerBase
{
private readonly IMediator _mediator;
public SystemController(IMediator mediator)
{
_mediator=mediator;
}
[AllowAnonymous]
[HttpGet("version")]
public async Task<IActionResult> GetSystemVersion([FromRoute] GetSystemVersion.Query query)
{
var result = await _mediator.Send(query);
return Ok(result);
}
}
}