Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions application/controllers/VmsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ public function snapshotAction()
{
$this->handleTabs();
$urlParams = $this->getParentParamsToPreserve();
$filterVdi = $this->params->get('filter_vdi', '0');

$this->actions()->add([
Link::create(
$this->translate('Disk Usage'),
Expand All @@ -106,8 +108,16 @@ public function snapshotAction()
$urlParams,
['class' => 'icon-left-small']
),
Link::create(
$filterVdi === '1' ? $this->translate('Show All VMs') : $this->translate('Hide VDI, Templates & Off'),
'vspheredb/vms/snapshot',
array_merge($urlParams, ['filter_vdi' => $filterVdi === '1' ? '0' : '1']),
['class' => 'icon-filter']
)
]);

$table = new VmsSnapshotsTable($this->db(), $this->url());

(new AdditionalTableActions($table, Auth::getInstance(), $this->url()))
->appendTo($this->actions());
$this->showTable($table, 'vspheredb/vms', $this->translate('Virtual Machines with Snapshots'));
Expand Down
23 changes: 23 additions & 0 deletions library/Vspheredb/Web/Table/Objects/VmsSnapshotsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@
class VmsSnapshotsTable extends ObjectsTable
{
protected $baseUrl = 'vspheredb/vm';

protected $vmsRequestUrl;

protected $searchColumns = [
'object_name',
'guest_host_name',
];

public function __construct($db, $url = null)
{
$this->vmsRequestUrl = $url;
parent::__construct($db, $url);
}

public function filterHost($uuid)
{
$this->getQuery()->where('vc.runtime_host_uuid = ?', $uuid);
Expand Down Expand Up @@ -70,6 +78,21 @@ public function prepareQuery()
[]
)->group('vm.uuid');

$urlFilter = '0';
if ($this->vmsRequestUrl !== null) {
$urlFilter = $this->vmsRequestUrl->getParam('filter_vdi', '0');
}

if ($urlFilter === '1') {
$query->where("vm.template = 'n' OR vm.template = 0");
$query->where("vm.runtime_power_state != 'poweredOff'");
$query->where("LOWER(o.object_name) NOT LIKE 'cp-template-%'");
$query->where("LOWER(o.object_name) NOT LIKE 'cp-replica-%'");
$query->where("LOWER(o.object_name) NOT LIKE '%-vdi-%'");
$query->where("LOWER(o.object_name) NOT LIKE '%-gis-%'");
$query->where("LOWER(o.object_name) NOT LIKE '%horizon%'");
}

return $query;
}

Expand Down
Loading