mirror of
https://github.com/unraid/webgui.git
synced 2026-04-29 06:19:30 -05:00
Merge pull request #1064 from SimonFair/VM_Running_IPs
Show IP on VM Manager VM Page
This commit is contained in:
@@ -164,6 +164,31 @@ foreach ($vms as $vm) {
|
||||
$bus = $arrValidDiskBuses[$arrCD['bus']] ?? 'VirtIO';
|
||||
echo "<tr><td>$disk</td><td>$bus</td><td>$capacity</td><td>$allocation</td></tr>";
|
||||
}
|
||||
|
||||
/* Display VM IP Addresses "execute":"guest-network-get-interfaces" --pretty */
|
||||
echo "<thead><tr><th><i class='fa fa-sitemap'></i> <b>"._('IP Interfaces')."</b></th><th>"._('Type')."</th><th>"._('IP')."</th><th>"._('Prefix')."</th></tr></thead>";
|
||||
$ip=$lv->domain_qemu_agent_command($res, '{"execute":"guest-network-get-interfaces"}', 10, 0) ;
|
||||
if ($ip != false) {
|
||||
$ip=json_decode($ip,true) ;
|
||||
$ip=$ip["return"] ;
|
||||
$duplicates = []; // hide duplicate interface names
|
||||
foreach ($ip as $arrIP) {
|
||||
$ipname = $arrIP["name"] ;
|
||||
if (preg_match('/^(lo|Loopback)/',$ipname)) continue; // omit loopback interface
|
||||
$iphdwadr = $arrIP["hardware-address"] == "" ? _("N/A") : $arrIP["hardware-address"] ;
|
||||
$iplist = $arrIP["ip-addresses"] ;
|
||||
foreach ($iplist as $arraddr) {
|
||||
$ipaddrval = $arraddr["ip-address"] ;
|
||||
if (preg_match('/^f[c-f]/',$ipaddrval)) continue; // omit ipv6 private addresses
|
||||
$iptype= $arraddr["ip-address-type"] ;
|
||||
$ipprefix =$arraddr["prefix"] ;
|
||||
$ipnamemac = "$ipname($iphdwadr)" ;
|
||||
if (!in_array($ipnamemac,$duplicates)) $duplicates[] = $ipnamemac; else $ipnamemac = "";
|
||||
echo "<tr><td>$ipnamemac</td><td>$iptype</td><td>$ipaddrval</td><td>$ipprefix</td></tr>";
|
||||
}
|
||||
}
|
||||
} else echo "<tr><td>"._('Guest not running or guest agent not installed')."</td><td></td><td></td><td></td></tr>";
|
||||
|
||||
echo "</tbody></table>";
|
||||
echo "</td></tr>";
|
||||
}
|
||||
|
||||
@@ -1607,6 +1607,12 @@
|
||||
return ($tmp) ? $tmp : $this->_set_last_error();
|
||||
}
|
||||
|
||||
function domain_qemu_agent_command($domain,$cmd,$timeout,$flags) {
|
||||
$domain = $this->get_domain_object($domain);
|
||||
$tmp = libvirt_domain_qemu_agent_command($domain,$cmd,$timeout,$flags);
|
||||
return ($tmp) ? $tmp : $this->_set_last_error();
|
||||
}
|
||||
|
||||
function generate_uuid($seed=false) {
|
||||
if (!$seed)
|
||||
$seed = time();
|
||||
|
||||
Reference in New Issue
Block a user