mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-08-10 14:26:52 +00:00
4ac38f7714
Add C# model classes for all PVE API resources: nodes, VMs, VM config, containers, storage, network interfaces, SDN zones/vnets, users, roles, permissions, snapshots, tasks, and cluster status. All models use dual JSON attributes (System.Text.Json + Newtonsoft.Json), nullable optional fields, and human-readable ToString() overrides. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
115 lines
3.5 KiB
C#
115 lines
3.5 KiB
C#
using System;
|
|
using System.Text.Json.Serialization;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace PSProxmoxVE.Core.Models.Containers;
|
|
|
|
/// <summary>
|
|
/// Represents a Linux Container (LXC) as returned by the cluster or node container list endpoints.
|
|
/// </summary>
|
|
public class PveContainer
|
|
{
|
|
/// <summary>
|
|
/// The unique container identifier.
|
|
/// </summary>
|
|
[JsonPropertyName("vmid")]
|
|
[JsonProperty("vmid")]
|
|
public int VmId { get; set; }
|
|
|
|
/// <summary>
|
|
/// The hostname / display name of the container.
|
|
/// </summary>
|
|
[JsonPropertyName("name")]
|
|
[JsonProperty("name")]
|
|
public string? Name { get; set; }
|
|
|
|
/// <summary>
|
|
/// The current runtime status of the container (e.g., "running", "stopped").
|
|
/// </summary>
|
|
[JsonPropertyName("status")]
|
|
[JsonProperty("status")]
|
|
public string? Status { get; set; }
|
|
|
|
/// <summary>
|
|
/// The node on which the container resides.
|
|
/// </summary>
|
|
[JsonPropertyName("node")]
|
|
[JsonProperty("node")]
|
|
public string? Node { get; set; }
|
|
|
|
/// <summary>
|
|
/// The number of CPU cores assigned to the container.
|
|
/// </summary>
|
|
[JsonPropertyName("cpus")]
|
|
[JsonProperty("cpus")]
|
|
public int? CpuCount { get; set; }
|
|
|
|
/// <summary>
|
|
/// Maximum memory allocated to the container, in bytes.
|
|
/// </summary>
|
|
[JsonPropertyName("maxmem")]
|
|
[JsonProperty("maxmem")]
|
|
public long? MaxMem { get; set; }
|
|
|
|
/// <summary>
|
|
/// Maximum swap space allocated to the container, in bytes.
|
|
/// </summary>
|
|
[JsonPropertyName("maxswap")]
|
|
[JsonProperty("maxswap")]
|
|
public long? MaxSwap { get; set; }
|
|
|
|
/// <summary>
|
|
/// Root filesystem disk size allocated to the container, in bytes.
|
|
/// </summary>
|
|
[JsonPropertyName("maxdisk")]
|
|
[JsonProperty("maxdisk")]
|
|
public long? RootFsSize { get; set; }
|
|
|
|
/// <summary>
|
|
/// The OS template type used for this container (e.g., "debian", "ubuntu").
|
|
/// </summary>
|
|
[JsonPropertyName("ostype")]
|
|
[JsonProperty("ostype")]
|
|
public string? OsType { get; set; }
|
|
|
|
/// <summary>
|
|
/// Indicates whether the container runs in unprivileged mode (1) or privileged mode (0).
|
|
/// </summary>
|
|
[JsonPropertyName("unprivileged")]
|
|
[JsonProperty("unprivileged")]
|
|
public int? Unprivileged { get; set; }
|
|
|
|
/// <summary>
|
|
/// The current lock type applied to the container, if any (e.g., "migrate", "backup").
|
|
/// </summary>
|
|
[JsonPropertyName("lock")]
|
|
[JsonProperty("lock")]
|
|
public string? Lock { get; set; }
|
|
|
|
/// <summary>
|
|
/// Container uptime in seconds.
|
|
/// </summary>
|
|
[JsonPropertyName("uptime")]
|
|
[JsonProperty("uptime")]
|
|
public long? Uptime { get; set; }
|
|
|
|
/// <summary>
|
|
/// Semicolon-separated list of tags assigned to the container.
|
|
/// </summary>
|
|
[JsonPropertyName("tags")]
|
|
[JsonProperty("tags")]
|
|
public string? Tags { get; set; }
|
|
|
|
/// <inheritdoc />
|
|
public override string ToString()
|
|
{
|
|
var maxMemMb = MaxMem.HasValue ? $"{MaxMem.Value / 1024 / 1024} MB" : "N/A";
|
|
var rootFsGb = RootFsSize.HasValue ? $"{RootFsSize.Value / 1024 / 1024 / 1024} GB" : "N/A";
|
|
var uptimeStr = Uptime.HasValue ? TimeSpan.FromSeconds(Uptime.Value).ToString(@"d\.hh\:mm\:ss") : "N/A";
|
|
var privStr = Unprivileged is 1 ? "unprivileged" : "privileged";
|
|
return $"CT {VmId}: {Name ?? "(unnamed)"} | Node: {Node ?? "N/A"} | "
|
|
+ $"Status: {Status ?? "N/A"} | CPUs: {CpuCount?.ToString() ?? "N/A"} | "
|
|
+ $"Mem: {maxMemMb} | Disk: {rootFsGb} | {privStr} | Uptime: {uptimeStr}";
|
|
}
|
|
}
|