mirror of
https://github.com/unraid/webgui.git
synced 2026-03-05 08:00:49 -06:00
Allow modifying Docker and VM Settings pages; show docker and libvirt running status
This commit is contained in:
@@ -16,11 +16,6 @@ Markdown="false"
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
if ($var['fsState'] != "Started") {
|
||||
echo "<p class='notice'>Array must be Started to manage Docker.</p>";
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the Docker JSON client
|
||||
require_once('/usr/local/emhttp/plugins/dynamix.docker.manager/include/DockerClient.php');
|
||||
$docker = new DockerClient();
|
||||
@@ -46,9 +41,8 @@ if (file_exists($realfile)) {
|
||||
.fileTree{width:305px;max-height:150px;overflow:scroll;position:absolute;z-index:100;display:none;}
|
||||
.basic{display: block;}
|
||||
.advanced{display:none;white-space: nowrap;}
|
||||
.switch-button-label.off{color: inherit;}
|
||||
</style>
|
||||
<span class="status" style="margin-top: -44px;"><input type="checkbox" class="advancedview"></span>
|
||||
<span class="status" style="margin-top: -10px;"><input type="checkbox" class="advancedview"></span>
|
||||
<form id="settingsForm" markdown="1" method="POST" action="/update.php" target="progressFrame">
|
||||
<input type="hidden" name="#file" value="<?=$docker_cfgfile;?>" />
|
||||
|
||||
@@ -58,7 +52,7 @@ if (file_exists($realfile)) {
|
||||
<select id="DOCKER_ENABLED" name="DOCKER_ENABLED" class="narrow">
|
||||
<?= mk_option($dockercfg['DOCKER_ENABLED'], 'no', 'No'); ?>
|
||||
<?= mk_option($dockercfg['DOCKER_ENABLED'], 'yes', 'Yes'); ?>
|
||||
</select>
|
||||
</select> <?if ($var['fsState'] != "Started"):?><span id="arraystopped"><i class="fa fa-warning icon warning"></i> <?=($dockercfg['DOCKER_ENABLED']=='yes')?'Docker will be available after Array is Started':'Apply to activate Docker after Array is Started'?></span><?endif;?>
|
||||
</dd>
|
||||
</dl>
|
||||
<blockquote class="inline_help">
|
||||
@@ -71,7 +65,7 @@ if (file_exists($realfile)) {
|
||||
|
||||
<dl>
|
||||
<dt>Docker vdisk size:</dt>
|
||||
<dd><input id="DOCKER_IMAGE_SIZE" type="number" name="DOCKER_IMAGE_SIZE" value="<?=$dockercfg['DOCKER_IMAGE_SIZE'];?>" class="narrow" required="required" />GB <span id="SIZE_ERROR" class="errortext"></span></dd>
|
||||
<dd><input id="DOCKER_IMAGE_SIZE" type="number" name="DOCKER_IMAGE_SIZE" value="<?=$dockercfg['DOCKER_IMAGE_SIZE'];?>" style="width:50px;" required="required" />GB <span id="SIZE_ERROR" class="errortext"></span></dd>
|
||||
</dl>
|
||||
<blockquote class="inline_help">
|
||||
<p>If the system needs to create a new docker image file, this is the default size to use specified in GB.</p>
|
||||
@@ -120,7 +114,7 @@ if (file_exists($realfile)) {
|
||||
<p>Only used when adding new Docker apps. Editing existing Docker apps will not be affected by this setting.</p>
|
||||
</blockquote>
|
||||
|
||||
<dl>
|
||||
<!--dl>
|
||||
<dt>Auto-map user shares to containers as /unraid:</dt>
|
||||
<dd>
|
||||
<select id="DOCKER_APP_UNRAID_PATH" name="DOCKER_APP_UNRAID_PATH" class="narrow">
|
||||
@@ -132,7 +126,7 @@ if (file_exists($realfile)) {
|
||||
<blockquote class="inline_help">
|
||||
<p>You can expose all of your user shares (/mnt/user) to a folder named /unraid within Docker containers.</p>
|
||||
<p>Only used when adding new Docker apps. Editing existing Docker apps will not be affected by this setting.</p>
|
||||
</blockquote>
|
||||
</blockquote-->
|
||||
</div>
|
||||
|
||||
<dl>
|
||||
@@ -232,6 +226,15 @@ $(function() {
|
||||
$("#settingsForm").submit();
|
||||
});
|
||||
|
||||
$("#DOCKER_ENABLED").change(function changeService() {
|
||||
if ($(this).val()=='yes') {
|
||||
$('#arraystopped').fadeIn('slow');
|
||||
} else {
|
||||
$('#arraystopped').fadeOut('fast');
|
||||
}
|
||||
});
|
||||
if ($("#DOCKER_ENABLED").val()!='yes') $('#arraystopped').hide();
|
||||
|
||||
if ($("#DOCKER_IMAGE_FILE").length) {
|
||||
$("#DOCKER_IMAGE_FILE").on("input change", function(){
|
||||
$("#IMAGE_ERROR").fadeOut();
|
||||
@@ -247,9 +250,11 @@ $(function() {
|
||||
<? } ?>
|
||||
});
|
||||
|
||||
<?if ($var['fsState'] == "Started"):?>
|
||||
$("#DOCKER_IMAGE_FILE").fileTreeAttach(null, null, function(folder) {
|
||||
$("#DOCKER_IMAGE_FILE").val(folder + 'docker.img').change();
|
||||
});
|
||||
<?endif;?>
|
||||
|
||||
$("#deleteCheckbox").change(function(){
|
||||
var checked = $(this).is(":checked");
|
||||
@@ -262,8 +267,6 @@ $(function() {
|
||||
});
|
||||
}
|
||||
|
||||
$("#DOCKER_APP_CONFIG_PATH").fileTreeAttach();
|
||||
|
||||
if ($.cookie('dockersettings_view_mode') == 'advanced') {
|
||||
$('.advanced').show();
|
||||
$('.basic').hide();
|
||||
@@ -279,5 +282,11 @@ $(function() {
|
||||
$('.basic').toggle('slow');
|
||||
$.cookie('dockersettings_view_mode', $('.advancedview').is(':checked') ? 'advanced' : 'basic', { expires: 3650 });
|
||||
});
|
||||
|
||||
showStatus('pid','docker');
|
||||
|
||||
<?if ($var['fsState'] == "Started"):?>
|
||||
$("#DOCKER_APP_CONFIG_PATH").fileTreeAttach();
|
||||
<?endif;?>
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -15,25 +15,23 @@ Icon="dynamix.vm.manager.png"
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
if ($var['fsState'] != "Started") {
|
||||
echo "<p class='notice'>Array must be Started to manage Virtual Machines.</p>";
|
||||
return;
|
||||
}
|
||||
|
||||
require_once('/usr/local/emhttp/plugins/dynamix.vm.manager/classes/libvirt.php');
|
||||
require_once('/usr/local/emhttp/plugins/dynamix.vm.manager/classes/libvirt_helpers.php');
|
||||
|
||||
|
||||
// Check for Intel VT-x (vmx) or AMD-V (svm) cpu virtualzation support
|
||||
// Attempt to load either of the kvm modules to see if virtualzation hw is supported
|
||||
exec('modprobe -a kvm_intel kvm_amd 2>/dev/null');
|
||||
|
||||
// If either kvm_intel or kvm_amd are loaded then Intel VT-x (vmx) or AMD-V (svm) cpu virtualzation support was found
|
||||
$strLoadedModules = shell_exec("lsmod | grep '^kvm_\(amd\|intel\)'");
|
||||
|
||||
if (empty($strLoadedModules)) {
|
||||
?><p class="notice">Your hardware does not have Intel VT-x or AMD-V capability. This is required to create VMs in KVM. <a href="http://lime-technology.com/wiki/index.php/UnRAID_Manual_6#Hardware-Assisted_Virtualization_.28HVM.29" target="_blank">Click here to see the unRAID Wiki for more information</a></p><?php
|
||||
exit;
|
||||
// Attempt to load either of the kvm modules to see if virtualzation hw is supported
|
||||
exec('modprobe -a kvm_intel kvm_amd 2>/dev/null');
|
||||
$strLoadedModules = shell_exec("lsmod | grep '^kvm_\(amd\|intel\)'");
|
||||
if (!empty($strLoadedModules)) {
|
||||
exec('modprobe -r kvm_intel kvm_amd 2>/dev/null');
|
||||
} else {
|
||||
?><p class="notice">Your hardware does not have Intel VT-x or AMD-V capability. This is required to create VMs in KVM. <a href="http://lime-technology.com/wiki/index.php/UnRAID_Manual_6#Hardware-Assisted_Virtualization_.28HVM.29" target="_blank">Click here to see the unRAID Wiki for more information</a></p><?php
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +80,6 @@ if ($boolACSEnabled != $boolACSInSyslinux) {
|
||||
}
|
||||
.basic{display:block;}
|
||||
.advanced{display:none;white-space:nowrap;}
|
||||
.switch-button-label.off{color: inherit;}
|
||||
#winvirtio{display:none;}
|
||||
#download_status {
|
||||
margin-left: 5px;
|
||||
@@ -91,7 +88,7 @@ if ($boolACSEnabled != $boolACSInSyslinux) {
|
||||
}
|
||||
#download_button {
|
||||
cursor: pointer;
|
||||
margin-left: -5px;
|
||||
margin-left: -2px;
|
||||
color: #08C;
|
||||
font-size: 1.4em;
|
||||
display: none;
|
||||
@@ -101,23 +98,26 @@ if ($boolACSEnabled != $boolACSInSyslinux) {
|
||||
cursor: default;
|
||||
color: #777;
|
||||
}
|
||||
#download_button span {
|
||||
font-size: 12px;
|
||||
font-family: arimo;
|
||||
vertical-align: top;
|
||||
}
|
||||
</style>
|
||||
<span class="status" style="margin-top: -44px;"><input type="checkbox" class="advancedview"></span>
|
||||
<span class="status advanced" style="margin-top: -4px;"><a id="openlog" title="/var/log/libvirt/libvirtd.log" href="#" onclick="openWindow('/webGui/scripts/tail_log&arg1=libvirt/libvirtd.log','Log Information',600,900);">view libvirt log</a></span>
|
||||
<span class="status" style="margin-top: -10px;"><input type="checkbox" class="advancedview"></span>
|
||||
<form id="settingsForm" markdown="1" method="POST" action="/update.php" target="progressFrame">
|
||||
<input type="hidden" name="#file" value="<?=$domain_cfgfile;?>" />
|
||||
<input type="hidden" id="command" name="#command" value="" />
|
||||
|
||||
Enable VMs:
|
||||
: <select id="SERVICE" name="SERVICE" class="narrow">
|
||||
<?= mk_option($libvirt_service, 'disable', 'No'); ?>
|
||||
<?= mk_option($libvirt_service, 'enable', 'Yes'); ?>
|
||||
</select>
|
||||
</select> <?if ($var['fsState'] != "Started"):?><span id="arraystopped"><i class="fa fa-warning icon warning"></i> <?=($libvirt_service=='enable')?'VMs will be available after Array is Started':'Apply to activate VMs after Array is Started'?></span><?endif;?>
|
||||
|
||||
> Stopping the VM Manager will first attempt to shutdown all running VMs. After 40 seconds, any remaining VM instances will be terminated.
|
||||
|
||||
<div class="advanced" markdown="1">
|
||||
<? if ($libvirt_service == 'enable') {
|
||||
<? if ($libvirt_running == 'yes') {
|
||||
$libvirt_info = libvirt_version('libvirt');
|
||||
$qemu_info = $lv->get_connect_information(); ?>
|
||||
Libvirt version:
|
||||
@@ -170,7 +170,7 @@ Default Windows VirtIO driver ISO <span style="font-weight: normal">(optional)</
|
||||
|
||||
echo mk_option($strManual, 'manual', 'Manual');
|
||||
?>
|
||||
</select><input type="text" id="winvirtio" name="VIRTIOISO" data-pickfilter="iso" data-pickcloseonfile="true" data-pickroot="<?= (is_dir('/mnt/user/') ? '/mnt/user/' : '/mnt/') ?>" value="<?=$domain_cfg['VIRTIOISO']?>" placeholder="Click to Select"><i class="fa fa-download" id="download_button" title="Download Windows VirtIO driver ISO"></i><span id="download_status"></span>
|
||||
</select><input type="text" id="winvirtio" name="VIRTIOISO" data-pickfilter="iso" data-pickcloseonfile="true" data-pickroot="<?= (is_dir('/mnt/user/') ? '/mnt/user/' : '/mnt/') ?>" value="<?=$domain_cfg['VIRTIOISO']?>"<?if ($var['fsState'] == "Started"):?> placeholder="Click to Select"><i class="fa fa-download" id="download_button" title="Download Windows VirtIO driver ISO"> <span>Download</span></i><span id="download_status"></span<?endif;?>>
|
||||
|
||||
> Specify the virtual CD-ROM (ISO) that contains the VirtIO Windows drivers as provided by the Fedora Project.
|
||||
> Download the latest ISO from here: <a href="https://fedoraproject.org/wiki/Windows_Virtio_Drivers#Direct_download" target="_blank">https://fedoraproject.org/wiki/Windows_Virtio_Drivers#Direct_download</a>
|
||||
@@ -185,7 +185,7 @@ Default Windows VirtIO driver ISO <span style="font-weight: normal">(optional)</
|
||||
<div class="advanced" markdown="1">
|
||||
Default network bridge:
|
||||
: <select id="bridge" name="BRNAME">
|
||||
<?php
|
||||
<?
|
||||
foreach ($arrValidBridges as $strBridge) {
|
||||
echo mk_option($domain_cfg['BRNAME'], $strBridge, $strBridge);
|
||||
}
|
||||
@@ -209,12 +209,13 @@ Enable PCIe ACS Override:
|
||||
> A reboot will be required for changes to this setting to take affect.
|
||||
</div>
|
||||
|
||||
|
||||
<?if (file_exists("/var/log/libvirt/libvirtd.log")):?><input type="button" class="advanced" onclick="openWindow('/webGui/scripts/tail_log&arg1=libvirt/libvirtd.log','Log Information',600,900);" value="View libvirt log"/><?endif;?>
|
||||
: <input type="button" id="applyBtn" value="Apply"/><input type="button" value="Done" onclick="done()">
|
||||
</form>
|
||||
|
||||
> View the log for libvirt: <a id="openlog" title="/var/log/libvirt/libvirtd.log" href="#" onclick="openWindow('/webGui/scripts/tail_log&arg1=libvirt/libvirtd.log','Log Information',600,900);">/var/log/libvirt/libvirtd.log</a>
|
||||
|
||||
<?if (file_exists("/var/log/libvirt/libvirtd.log")):?>
|
||||
> View the log for libvirt: <a id="openlog" title="/var/log/libvirt/libvirtd.log" href="#" onclick="openWindow('/webGui/scripts/tail_log&arg1=libvirt/libvirtd.log','Log Information',600,900);">/var/log/libvirt/libvirtd.log</a>
|
||||
<?endif;?>
|
||||
|
||||
<script src="/webGui/javascript/jquery.filetree.js"></script>
|
||||
<script src="/webGui/javascript/jquery.switchbutton.js"></script>
|
||||
@@ -222,8 +223,6 @@ Enable PCIe ACS Override:
|
||||
<script>
|
||||
$(function(){
|
||||
$("#applyBtn").click(function(){
|
||||
$("#command").val("/plugins/dynamix.vm.manager/event/" + ($("#SERVICE").val()=="enable" ? "started" : "stopping_svcs"));
|
||||
|
||||
if ($('#pcie_acs_override').val() == '1') {
|
||||
$.get("/plugins/dynamix.vm.manager/VMajax.php?action=acs-override-enable", function( data ) {
|
||||
$("#settingsForm").submit();
|
||||
@@ -235,8 +234,6 @@ $(function(){
|
||||
}
|
||||
});
|
||||
|
||||
$("input[data-pickroot]").fileTreeAttach();
|
||||
|
||||
$("#mediadir").on("input change", function() {
|
||||
$("#winvirtio_select").change();
|
||||
});
|
||||
@@ -279,7 +276,16 @@ $(function(){
|
||||
}, "json");
|
||||
};
|
||||
|
||||
$("#download_button").click(function changeVirtIOVersion() {
|
||||
$("#SERVICE").change(function changeService() {
|
||||
if ($(this).val()=='enable') {
|
||||
$('#arraystopped').fadeIn('slow');
|
||||
} else {
|
||||
$('#arraystopped').fadeOut('fast');
|
||||
}
|
||||
});
|
||||
if ($("#SERVICE").val()!='enable') $('#arraystopped').hide();
|
||||
|
||||
$("#download_button").click(function downloadVirtIOVersion() {
|
||||
if (!$(this).hasClass('fa-spin')) {
|
||||
checkOrInitDownload(false);
|
||||
}
|
||||
@@ -334,5 +340,11 @@ $(function(){
|
||||
$('.basic').toggle('slow');
|
||||
$.cookie('vmsettings_view_mode', $('.advancedview').is(':checked') ? 'advanced' : 'basic', { expires: 3650 });
|
||||
});
|
||||
|
||||
showStatus('pid','libvirt/libvirtd');
|
||||
|
||||
<?if ($var['fsState'] == "Started"):?>
|
||||
$("input[data-pickroot]").fileTreeAttach();
|
||||
<?endif;?>
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -16,6 +16,16 @@ require_once('/usr/local/emhttp/webGui/include/Helpers.php');
|
||||
require_once('/usr/local/emhttp/plugins/dynamix.vm.manager/classes/libvirt.php');
|
||||
require_once('/usr/local/emhttp/plugins/dynamix.vm.manager/classes/libvirt_helpers.php');
|
||||
|
||||
function requireLibvirt() {
|
||||
global $lv;
|
||||
|
||||
// Make sure libvirt is connected to qemu
|
||||
if (!isset($lv) || !$lv->enabled()) {
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode(['error' => 'failed to connect to the hypervisor']));
|
||||
}
|
||||
}
|
||||
|
||||
$arrSizePrefix = [
|
||||
0 => '',
|
||||
1 => 'K',
|
||||
@@ -30,13 +40,8 @@ $_REQUEST = array_merge($_GET, $_POST);
|
||||
$action = array_key_exists('action', $_REQUEST) ? $_REQUEST['action'] : '';
|
||||
$uuid = array_key_exists('uuid', $_REQUEST) ? $_REQUEST['uuid'] : '';
|
||||
|
||||
// Make sure libvirt is connected to qemu
|
||||
if (!isset($lv) || !$lv->enabled()) {
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode(['error' => 'failed to connect to the hypervisor']));
|
||||
}
|
||||
|
||||
if ($uuid) {
|
||||
requireLibvirt();
|
||||
$domName = $lv->domain_get_name_by_uuid($uuid);
|
||||
if (!$domName) {
|
||||
header('Content-Type: application/json');
|
||||
@@ -50,30 +55,35 @@ $arrResponse = [];
|
||||
switch ($action) {
|
||||
|
||||
case 'domain-autostart':
|
||||
requireLibvirt();
|
||||
$arrResponse = $lv->domain_set_autostart($domName, ($_REQUEST['autostart'] != "false")) ?
|
||||
['success' => true, 'autostart' => (bool)$lv->domain_get_autostart($domName)] :
|
||||
['error' => $lv->get_last_error()];
|
||||
break;
|
||||
|
||||
case 'domain-start':
|
||||
requireLibvirt();
|
||||
$arrResponse = $lv->domain_start($domName) ?
|
||||
['success' => true, 'state' => $lv->domain_get_state($domName)] :
|
||||
['error' => $lv->get_last_error()];
|
||||
break;
|
||||
|
||||
case 'domain-pause':
|
||||
requireLibvirt();
|
||||
$arrResponse = $lv->domain_suspend($domName) ?
|
||||
['success' => true, 'state' => $lv->domain_get_state($domName)] :
|
||||
['error' => $lv->get_last_error()];
|
||||
break;
|
||||
|
||||
case 'domain-resume':
|
||||
requireLibvirt();
|
||||
$arrResponse = $lv->domain_resume($domName) ?
|
||||
['success' => true, 'state' => $lv->domain_get_state($domName)] :
|
||||
['error' => $lv->get_last_error()];
|
||||
break;
|
||||
|
||||
case 'domain-pmwakeup':
|
||||
requireLibvirt();
|
||||
// No support in libvirt-php to do a dompmwakeup, use virsh tool instead
|
||||
exec("virsh dompmwakeup " . escapeshellarg($uuid) . " 2>&1", $arrOutput, $intReturnCode);
|
||||
$arrResponse = ($intReturnCode == 0) ?
|
||||
@@ -82,42 +92,49 @@ switch ($action) {
|
||||
break;
|
||||
|
||||
case 'domain-restart':
|
||||
requireLibvirt();
|
||||
$arrResponse = $lv->domain_reboot($domName) ?
|
||||
['success' => true, 'state' => $lv->domain_get_state($domName)] :
|
||||
['error' => $lv->get_last_error()];
|
||||
break;
|
||||
|
||||
case 'domain-save':
|
||||
requireLibvirt();
|
||||
$arrResponse = $lv->domain_save($domName) ?
|
||||
['success' => true, 'state' => $lv->domain_get_state($domName)] :
|
||||
['error' => $lv->get_last_error()];
|
||||
break;
|
||||
|
||||
case 'domain-stop':
|
||||
requireLibvirt();
|
||||
$arrResponse = $lv->domain_shutdown($domName) ?
|
||||
['success' => true, 'state' => $lv->domain_get_state($domName)] :
|
||||
['error' => $lv->get_last_error()];
|
||||
break;
|
||||
|
||||
case 'domain-destroy':
|
||||
requireLibvirt();
|
||||
$arrResponse = $lv->domain_destroy($domName) ?
|
||||
['success' => true, 'state' => $lv->domain_get_state($domName)] :
|
||||
['error' => $lv->get_last_error()];
|
||||
break;
|
||||
|
||||
case 'domain-delete':
|
||||
requireLibvirt();
|
||||
$arrResponse = $lv->domain_delete($domName) ?
|
||||
['success' => true] :
|
||||
['error' => $lv->get_last_error()];
|
||||
break;
|
||||
|
||||
case 'domain-undefine':
|
||||
requireLibvirt();
|
||||
$arrResponse = $lv->domain_undefine($domName) ?
|
||||
['success' => true] :
|
||||
['error' => $lv->get_last_error()];
|
||||
break;
|
||||
|
||||
case 'domain-define':
|
||||
requireLibvirt();
|
||||
$domName = $lv->domain_define($_REQUEST['xml']);
|
||||
$arrResponse = $domName ?
|
||||
['success' => true, 'state' => $lv->domain_get_state($domName)] :
|
||||
@@ -125,6 +142,7 @@ switch ($action) {
|
||||
break;
|
||||
|
||||
case 'domain-state':
|
||||
requireLibvirt();
|
||||
$state = $lv->domain_get_state($domName);
|
||||
$arrResponse = ($state) ?
|
||||
['success' => true, 'state' => $state] :
|
||||
@@ -132,60 +150,70 @@ switch ($action) {
|
||||
break;
|
||||
|
||||
case 'domain-diskdev':
|
||||
requireLibvirt();
|
||||
$arrResponse = ($lv->domain_set_disk_dev($domName, $_REQUEST['olddev'], $_REQUEST['diskdev'])) ?
|
||||
['success' => true] :
|
||||
['error' => $lv->get_last_error()];
|
||||
break;
|
||||
|
||||
case 'cdrom-change':
|
||||
requireLibvirt();
|
||||
$arrResponse = ($lv->domain_change_cdrom($domName, $_REQUEST['cdrom'], $_REQUEST['dev'], $_REQUEST['bus'])) ?
|
||||
['success' => true] :
|
||||
['error' => $lv->get_last_error()];
|
||||
break;
|
||||
|
||||
case 'memory-change':
|
||||
requireLibvirt();
|
||||
$arrResponse = ($lv->domain_set_memory($domName, $_REQUEST['memory']*1024)) ?
|
||||
['success' => true] :
|
||||
['error' => $lv->get_last_error()];
|
||||
break;
|
||||
|
||||
case 'vcpu-change':
|
||||
requireLibvirt();
|
||||
$arrResponse = ($lv->domain_set_vcpu($domName, $_REQUEST['vcpu'])) ?
|
||||
['success' => true] :
|
||||
['error' => $lv->get_last_error()];
|
||||
break;
|
||||
|
||||
case 'bootdev-change':
|
||||
requireLibvirt();
|
||||
$arrResponse = ($lv->domain_set_boot_device($domName, $_REQUEST['bootdev'])) ?
|
||||
['success' => true] :
|
||||
['error' => $lv->get_last_error()];
|
||||
break;
|
||||
|
||||
case 'disk-remove':
|
||||
requireLibvirt();
|
||||
$arrResponse = ($lv->domain_disk_remove($domName, $_REQUEST['dev'])) ?
|
||||
['success' => true] :
|
||||
['error' => $lv->get_last_error()];
|
||||
break;
|
||||
|
||||
case 'snap-create':
|
||||
requireLibvirt();
|
||||
$arrResponse = ($lv->domain_snapshot_create($domName)) ?
|
||||
['success' => true] :
|
||||
['error' => $lv->get_last_error()];
|
||||
break;
|
||||
|
||||
case 'snap-delete':
|
||||
requireLibvirt();
|
||||
$arrResponse = ($lv->domain_snapshot_delete($domName, $_REQUEST['snap'])) ?
|
||||
['success' => true] :
|
||||
['error' => $lv->get_last_error()];
|
||||
break;
|
||||
|
||||
case 'snap-revert':
|
||||
requireLibvirt();
|
||||
$arrResponse = ($lv->domain_snapshot_revert($domName, $_REQUEST['snap'])) ?
|
||||
['success' => true] :
|
||||
['error' => $lv->get_last_error()];
|
||||
break;
|
||||
|
||||
case 'snap-desc':
|
||||
requireLibvirt();
|
||||
$arrResponse = ($lv->snapshot_set_metadata($domName, $_REQUEST['snap'], $_REQUEST['snapdesc'])) ?
|
||||
['success' => true] :
|
||||
['error' => $lv->get_last_error()];
|
||||
@@ -194,7 +222,7 @@ switch ($action) {
|
||||
case 'disk-create':
|
||||
$disk = $_REQUEST['disk'];
|
||||
$driver = $_REQUEST['driver'];
|
||||
$size = str_replace(array("KB","MB","GB","TB","PB", " ", ","), array("K","M","G","T","P", "", ""), strtoupper($_REQUEST['size']));
|
||||
$size = str_replace(["KB","MB","GB","TB","PB", " ", ","], ["K","M","G","T","P", "", ""], strtoupper($_REQUEST['size']));
|
||||
|
||||
$dir = dirname($disk);
|
||||
|
||||
@@ -218,8 +246,8 @@ switch ($action) {
|
||||
|
||||
case 'disk-resize':
|
||||
$disk = $_REQUEST['disk'];
|
||||
$capacity = str_replace(array("KB","MB","GB","TB","PB", " ", ","), array("K","M","G","T","P", "", ""), strtoupper($_REQUEST['cap']));
|
||||
$old_capacity = str_replace(array("KB","MB","GB","TB","PB", " ", ","), array("K","M","G","T","P", "", ""), strtoupper($_REQUEST['oldcap']));
|
||||
$capacity = str_replace(["KB","MB","GB","TB","PB", " ", ","], ["K","M","G","T","P", "", ""], strtoupper($_REQUEST['cap']));
|
||||
$old_capacity = str_replace(["KB","MB","GB","TB","PB", " ", ","], ["K","M","G","T","P", "", ""], strtoupper($_REQUEST['oldcap']));
|
||||
|
||||
if (substr($old_capacity,0,-1) < substr($capacity,0,-1)){
|
||||
$strLastLine = exec("qemu-img resize -q " . escapeshellarg($disk) . " " . escapeshellarg($capacity) . " 2>&1", $out, $status);
|
||||
@@ -287,6 +315,7 @@ switch ($action) {
|
||||
break;
|
||||
|
||||
case 'generate-mac':
|
||||
requireLibvirt();
|
||||
$arrResponse = [
|
||||
'mac' => $lv->generate_random_mac_addr()
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user