138 lines
4.3 KiB
C#
138 lines
4.3 KiB
C#
using System.Net;
|
|
|
|
namespace QemuVmManager.Models;
|
|
|
|
public enum NodeRole
|
|
{
|
|
Follower,
|
|
Candidate,
|
|
Master
|
|
}
|
|
|
|
public enum NodeState
|
|
{
|
|
Starting,
|
|
Running,
|
|
Stopping,
|
|
Stopped,
|
|
Error
|
|
}
|
|
|
|
public class NodeInfo
|
|
{
|
|
public string NodeId { get; set; } = string.Empty;
|
|
public string Hostname { get; set; } = string.Empty;
|
|
public IPAddress IpAddress { get; set; } = IPAddress.Any;
|
|
public int Port { get; set; } = 8080;
|
|
public NodeRole Role { get; set; } = NodeRole.Follower;
|
|
public NodeState State { get; set; } = NodeState.Stopped;
|
|
public DateTime LastSeen { get; set; } = DateTime.UtcNow;
|
|
public Dictionary<string, object> Metadata { get; set; } = new();
|
|
public List<string> RunningVms { get; set; } = new();
|
|
public SystemInfo SystemInfo { get; set; } = new();
|
|
}
|
|
|
|
public class SystemInfo
|
|
{
|
|
public string OsName { get; set; } = string.Empty;
|
|
public string OsVersion { get; set; } = string.Empty;
|
|
public string Architecture { get; set; } = string.Empty;
|
|
public int CpuCores { get; set; }
|
|
public long TotalMemory { get; set; }
|
|
public long AvailableMemory { get; set; }
|
|
public VirtualizationType AvailableVirtualization { get; set; }
|
|
public bool QemuInstalled { get; set; }
|
|
public string QemuVersion { get; set; } = string.Empty;
|
|
}
|
|
|
|
public class ClusterState
|
|
{
|
|
public string ClusterId { get; set; } = string.Empty;
|
|
public NodeInfo? MasterNode { get; set; }
|
|
public List<NodeInfo> Nodes { get; set; } = new();
|
|
public DateTime LastUpdated { get; set; } = DateTime.UtcNow;
|
|
public Dictionary<string, VmInstance> DistributedVms { get; set; } = new();
|
|
}
|
|
|
|
public class VmInstance
|
|
{
|
|
public string VmId { get; set; } = string.Empty;
|
|
public string VmName { get; set; } = string.Empty;
|
|
public string NodeId { get; set; } = string.Empty;
|
|
public VmState State { get; set; } = VmState.Stopped;
|
|
public DateTime StartedAt { get; set; }
|
|
public VmConfiguration Configuration { get; set; } = new();
|
|
public NetworkEndpoint? PublicEndpoint { get; set; }
|
|
public VmPerformanceMetrics? PerformanceMetrics { get; set; }
|
|
}
|
|
|
|
public class NetworkEndpoint
|
|
{
|
|
public IPAddress PublicIp { get; set; } = IPAddress.Any;
|
|
public int PublicPort { get; set; }
|
|
public IPAddress PrivateIp { get; set; } = IPAddress.Any;
|
|
public int PrivatePort { get; set; }
|
|
public string Protocol { get; set; } = "TCP";
|
|
public string Description { get; set; } = string.Empty;
|
|
}
|
|
|
|
public class ElectionRequest
|
|
{
|
|
public string CandidateId { get; set; } = string.Empty;
|
|
public long Term { get; set; }
|
|
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
|
|
}
|
|
|
|
public class ElectionResponse
|
|
{
|
|
public string VoterId { get; set; } = string.Empty;
|
|
public bool VoteGranted { get; set; }
|
|
public long Term { get; set; }
|
|
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
|
|
}
|
|
|
|
public class HeartbeatMessage
|
|
{
|
|
public string NodeId { get; set; } = string.Empty;
|
|
public NodeRole Role { get; set; }
|
|
public long Term { get; set; }
|
|
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
|
|
public Dictionary<string, object> Metadata { get; set; } = new();
|
|
}
|
|
|
|
public class VmMigrationRequest
|
|
{
|
|
public string VmId { get; set; } = string.Empty;
|
|
public string SourceNodeId { get; set; } = string.Empty;
|
|
public string TargetNodeId { get; set; } = string.Empty;
|
|
public bool LiveMigration { get; set; } = false;
|
|
public DateTime RequestedAt { get; set; } = DateTime.UtcNow;
|
|
}
|
|
|
|
public class VmMigrationResponse
|
|
{
|
|
public string VmId { get; set; } = string.Empty;
|
|
public bool Success { get; set; }
|
|
public string? ErrorMessage { get; set; }
|
|
public DateTime CompletedAt { get; set; } = DateTime.UtcNow;
|
|
}
|
|
|
|
public class PortForwardingRequest
|
|
{
|
|
public string VmId { get; set; } = string.Empty;
|
|
public int PrivatePort { get; set; }
|
|
public int? PublicPort { get; set; }
|
|
public string Protocol { get; set; } = "TCP";
|
|
public string Description { get; set; } = string.Empty;
|
|
}
|
|
|
|
public class PortForwardingResponse
|
|
{
|
|
public string VmId { get; set; } = string.Empty;
|
|
public bool Success { get; set; }
|
|
public IPAddress? PublicIp { get; set; }
|
|
public int? PublicPort { get; set; }
|
|
public string? ErrorMessage { get; set; }
|
|
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
|
}
|