using System.Collections.Generic;
using System.Linq;
using System.Net;
namespace PSProxmox.Models
{
///
/// Represents an IP address pool for Proxmox VE.
///
public class ProxmoxIPPool
{
///
/// Gets or sets the name of the pool.
///
public string Name { get; set; }
///
/// Gets or sets the CIDR notation of the pool.
///
public string CIDR { get; set; }
///
/// Gets or sets the network address of the pool.
///
public string NetworkAddress { get; set; }
///
/// Gets or sets the subnet mask of the pool.
///
public string SubnetMask { get; set; }
///
/// Gets or sets the prefix length of the pool.
///
public int PrefixLength { get; set; }
///
/// Gets or sets the total number of IPs in the pool.
///
public int TotalIPs { get; set; }
///
/// Gets or sets the number of available IPs in the pool.
///
public int AvailableIPs { get; set; }
///
/// Gets or sets the number of used IPs in the pool.
///
public int UsedIPs { get; set; }
///
/// Gets or sets the number of excluded IPs in the pool.
///
public int ExcludedIPs { get; set; }
///
/// Gets or sets the list of used IP addresses.
///
public List UsedIPAddresses { get; set; }
///
/// Gets or sets the list of available IP addresses.
///
public List AvailableIPAddresses { get; set; }
///
/// Gets or sets the list of excluded IP addresses.
///
public List ExcludedIPAddresses { get; set; }
///
/// Creates a new instance of the class from an object.
///
/// The IP pool.
/// A new IP pool information object.
public static ProxmoxIPPool FromIPPool(IPAM.IPPool pool)
{
return new ProxmoxIPPool
{
Name = pool.Name,
CIDR = pool.CIDR,
NetworkAddress = pool.NetworkAddress.ToString(),
SubnetMask = pool.SubnetMask.ToString(),
PrefixLength = pool.PrefixLength,
TotalIPs = pool.TotalIPs,
AvailableIPs = pool.AvailableIPs,
UsedIPs = pool.UsedIPs,
ExcludedIPs = pool.ExcludedIPs,
UsedIPAddresses = pool.GetUsedIPs().Select(ip => ip.ToString()).ToList(),
AvailableIPAddresses = pool.GetAvailableIPs().Select(ip => ip.ToString()).ToList(),
ExcludedIPAddresses = pool.GetExcludedIPs().Select(ip => ip.ToString()).ToList()
};
}
}
}