Skip to content

Commit

Permalink
Merge pull request #26 from franklupo/master
Browse files Browse the repository at this point in the history
Fix #25
  • Loading branch information
franklupo authored Sep 19, 2024
2 parents ae56692 + 4a694ea commit 4ea8098
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 7 deletions.
2 changes: 1 addition & 1 deletion common.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<LangVersion>latest</LangVersion>
<Version>8.2.4</Version>
<Version>8.2.5</Version>
<!--<NoWarn>$(NoWarn);CS1591;CS0436</NoWarn>-->

<Company>Corsinvest Srl</Company>
Expand Down
34 changes: 31 additions & 3 deletions src/Corsinvest.ProxmoxVE.Api.Shared/Models/Vm/VmConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,42 @@ internal void OnSerializedMethod(StreamingContext context)
|| (Regex.IsMatch(key, @"(efidisk|tpmstate|virtio|ide|scsi|sata|mp)\d+") && !Regex.IsMatch(def, "media=cdrom")))
{
var infos = def.Split(',');
var storages = infos[0].Split(':');
var storage = string.Empty;
var fileName = string.Empty;
var passthrough = false;
var device = string.Empty;
var mountSourcePath = string.Empty;

if (infos[0].Contains(":"))
{
var data = infos[0].Split(':');
storage = data[0];
fileName = data[1];
}
else if (infos[0].StartsWith("/dev"))
{
passthrough = true;
device = infos[0];
}
else if (key.StartsWith("mp"))
{
mountSourcePath = infos[0];
}
else
{
storage = infos[0];
}

disks.Add(new VmDisk
{
Id = key,
Storage = storages[0],
FileName = storages[1],
Storage = storage,
FileName = fileName,
Device = device,
Passthrough = passthrough,
Size = infos.Where(a => a.StartsWith("size=")).Select(a => a.Substring(5)).FirstOrDefault(),
MountPoint = infos.Where(a => a.StartsWith("mp=")).Select(a => a.Substring(3)).FirstOrDefault(),
MountSourcePath = mountSourcePath,
Backup = !infos.Contains("backup=0")
});
}
Expand Down
22 changes: 20 additions & 2 deletions src/Corsinvest.ProxmoxVE.Api.Shared/Models/Vm/VmDisk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,33 @@ public class VmDisk
/// <summary>
/// Storage
/// </summary>
/// <value></value>
public string Storage { get; set; }

/// <summary>
/// Name
/// </summary>
/// <value></value>
public string FileName { get; set; }

/// <summary>
/// Device
/// </summary>
public string Device { get; set; }

/// <summary>
/// Passthrough
/// </summary>
public bool Passthrough { get; set; }

/// <summary>
/// Mount Point
/// </summary>
public string MountPoint { get; set; }

/// <summary>
/// Mount Source Path
/// </summary>
public string MountSourcePath { get; set; }

/// <summary>
/// Size
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Corsinvest.ProxmoxVE.Api.Test/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Corsinvest.ProxmoxVE.Api;

var client = new PveClient("192.168.0.2");
if (await client.LoginAsync("root", Environment.GetEnvironmentVariable("pve_password")))
if (await client.LoginAsync("root", Environment.GetEnvironmentVariable("PvePassword")))
{
Console.WriteLine("pippo");

Expand Down

0 comments on commit 4ea8098

Please sign in to comment.