-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathComputeClusterController.php
More file actions
72 lines (64 loc) · 2.63 KB
/
Copy pathComputeClusterController.php
File metadata and controls
72 lines (64 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
// SPDX-FileCopyrightText: 2019 Icinga GmbH <https://icinga.com>
// SPDX-License-Identifier: GPL-3.0-or-later
namespace Icinga\Module\Vspheredb\Controllers;
use Icinga\Authentication\Auth;
use Icinga\Module\Vspheredb\DbObject\ComputeCluster;
use Icinga\Module\Vspheredb\Web\Controller;
use Icinga\Module\Vspheredb\Web\Table\Objects\HostsTable;
use Icinga\Module\Vspheredb\Web\Widget\AdditionalTableActions;
use Icinga\Module\Vspheredb\Web\Widget\ComputeClusterHeader;
use Icinga\Module\Vspheredb\Web\Widget\Summaries;
class ComputeClusterController extends Controller
{
/**
* @throws \Icinga\Exception\MissingParameterException
* @throws \Icinga\Exception\NotFoundError
*/
public function indexAction()
{
$computeCluster = $this->addComputeCluster();
$this->content()->addAttributes(['class' => 'host-info']);
$table = new HostsTable($this->db(), $this->url());
(new AdditionalTableActions($table, Auth::getInstance(), $this->url()))
->appendTo($this->actions());
$table->filterParentUuids([$computeCluster->get('uuid')])
->renderTo($this);
$summaries = new Summaries($table, $this->db(), $this->url());
$this->content()->prepend($summaries);
}
/**
* @return ComputeCluster
* @throws \Icinga\Exception\MissingParameterException
* @throws \Icinga\Exception\NotFoundError
*/
protected function addComputeCluster()
{
$computeCluster = ComputeCluster::loadWithUuid($this->params->getRequired('uuid'), $this->db());
$this->getRestrictionHelper()->assertAccessToVCenterUuidIsGranted($computeCluster->get('vcenter_uuid'));
$this->controls()->add(new ComputeClusterHeader($computeCluster));
$this->setTitle($computeCluster->get('object_name'));
$this->handleTabs($computeCluster);
return $computeCluster;
}
/**
* @param ComputeCluster $computeCluster
* @throws \Icinga\Exception\MissingParameterException
*/
protected function handleTabs(ComputeCluster $computeCluster)
{
$hexId = $this->params->getRequired('uuid');
$this->tabs()->add('index', [
'label' => $this->translate('Compute Cluster'),
'url' => 'vspheredb/compute-cluster',
'urlParams' => ['uuid' => $hexId]
])/*->add('hosts', [
'label' => sprintf(
$this->translate('Host Systems (%d)'),
$computeCluster->countHosts()
),
'url' => 'vspheredb/compute-cluster/hosts',
'urlParams' => ['uuid' => $hexId]
])*/->activate($this->getRequest()->getActionName());
}
}