mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-11-18 03:26:17 +00:00
Update AppImage
This commit is contained in:
@@ -123,6 +123,7 @@ interface VMDetails extends VMData {
|
||||
gpu_passthrough?: string[]
|
||||
devices?: string[]
|
||||
}
|
||||
lxc_ip?: string
|
||||
}
|
||||
|
||||
const fetcher = async (url: string) => {
|
||||
@@ -157,7 +158,11 @@ const formatUptime = (seconds: number) => {
|
||||
return `${days}d ${hours}h ${minutes}m`
|
||||
}
|
||||
|
||||
const extractIPFromConfig = (config?: VMConfig): string => {
|
||||
const extractIPFromConfig = (config?: VMConfig, lxcIP?: string): string => {
|
||||
if (lxcIP) {
|
||||
return lxcIP
|
||||
}
|
||||
|
||||
if (!config) return "DHCP"
|
||||
|
||||
// Check net0, net1, net2, etc.
|
||||
@@ -282,7 +287,9 @@ export function VirtualMachines() {
|
||||
const response = await fetch(`/api/vms/${lxc.vmid}`)
|
||||
if (response.ok) {
|
||||
const details = await response.json()
|
||||
if (details.config) {
|
||||
if (details.lxc_ip) {
|
||||
configs[lxc.vmid] = details.lxc_ip
|
||||
} else if (details.config) {
|
||||
configs[lxc.vmid] = extractIPFromConfig(details.config)
|
||||
}
|
||||
}
|
||||
@@ -1243,9 +1250,9 @@ export function VirtualMachines() {
|
||||
<div>
|
||||
<div className="text-xs text-muted-foreground mb-1">IP Address</div>
|
||||
<div
|
||||
className={`font-semibold ${extractIPFromConfig(vmDetails.config) === "DHCP" ? "text-yellow-500" : "text-green-500"}`}
|
||||
className={`font-semibold ${extractIPFromConfig(vmDetails.config, vmDetails.lxc_ip) === "DHCP" ? "text-yellow-500" : "text-green-500"}`}
|
||||
>
|
||||
{extractIPFromConfig(vmDetails.config)}
|
||||
{extractIPFromConfig(vmDetails.config, vmDetails.lxc_ip)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -165,6 +165,26 @@ def parse_lxc_hardware_config(vmid, node):
|
||||
|
||||
return hardware_info
|
||||
|
||||
|
||||
def get_lxc_ip_from_lxc_info(vmid):
|
||||
"""Get LXC IP address using lxc-info command (for DHCP containers)"""
|
||||
try:
|
||||
result = subprocess.run(
|
||||
['lxc-info', '-n', str(vmid), '-iH'],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=5
|
||||
)
|
||||
if result.returncode == 0:
|
||||
ip = result.stdout.strip()
|
||||
# Return IP only if it's valid (not empty)
|
||||
if ip and ip != '':
|
||||
return ip
|
||||
return None
|
||||
except Exception:
|
||||
# Silently fail if lxc-info is not available or fails
|
||||
return None
|
||||
|
||||
# Helper function to format bytes into human-readable string
|
||||
def format_bytes(size_in_bytes):
|
||||
"""Converts bytes to a human-readable string (KB, MB, GB, TB)."""
|
||||
|
||||
Reference in New Issue
Block a user