summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics/pages
diff options
context:
space:
mode:
authorSimon Rettberg2022-04-06 16:54:27 +0200
committerSimon Rettberg2022-04-06 17:25:28 +0200
commit506913f66f62fe83c3ab1c55d14dea23255efdd7 (patch)
tree6f7874329e4055f72f4120bf29de81c4554a7f56 /modules-available/statistics/pages
parent[statistics] Fix translation tags (diff)
downloadslx-admin-506913f66f62fe83c3ab1c55d14dea23255efdd7.tar.gz
slx-admin-506913f66f62fe83c3ab1c55d14dea23255efdd7.tar.xz
slx-admin-506913f66f62fe83c3ab1c55d14dea23255efdd7.zip
[statistics] client details: show which pci devices are passed through
Diffstat (limited to 'modules-available/statistics/pages')
-rw-r--r--modules-available/statistics/pages/machine.inc.php37
1 files changed, 33 insertions, 4 deletions
diff --git a/modules-available/statistics/pages/machine.inc.php b/modules-available/statistics/pages/machine.inc.php
index 6ea0ce28..4e8f9f34 100644
--- a/modules-available/statistics/pages/machine.inc.php
+++ b/modules-available/statistics/pages/machine.inc.php
@@ -61,8 +61,12 @@ class SubPage
Message::addError('unknown-machine', $uuid);
return;
}
- if (Module::isAvailable('locations') && !Location::isLeaf($client['locationid'])) {
- $client['hasroomplan'] = false;
+ $locations = [];
+ if ($client['locationid'] > 0 && Module::isAvailable('locations')) {
+ if (!Location::isLeaf($client['locationid'])) {
+ $client['hasroomplan'] = false;
+ }
+ $locations = Location::getLocationRootChain($client['locationid']);
}
User::assertPermission('machine.view-details', (int)$client['locationid']);
// Hack: Get raw collected data
@@ -89,18 +93,43 @@ class SubPage
}
}
unset($item);
+ // PCI
+ // 1) get passthrough groups
+ $passthroughTypes = [];
+ if (!empty($locations)) {
+ $hw = new HardwareQuery(HardwareInfo::PCI_DEVICE, $uuid, true);
+ // TODO: Get list of enabled pass through groups for this client's location
+ $hw->addForeignJoin(true, '@PASSTHROUGH', 'passthrough_group_x_location', 'groupid',
+ 'locationid', $locations);
+ $hw->addGlobalColumn('vendor');
+ $hw->addGlobalColumn('device');
+ $res = $hw->query();
+ foreach ($res as $row) {
+ $devId = $row['vendor'] . ':' . $row['device'];
+ if (!isset($passthroughTypes[$devId])) {
+ $passthroughTypes[$devId] = [];
+ }
+ $passthroughTypes[$devId][] = $row['@PASSTHROUGH'];
+ }
+ }
+ // 2) Sort and mangle list
$client['lspci1'] = $client['lspci2'] = [];
foreach ($client['lspci'] as $item) {
+ $devId = $item['vendor'] . ':' . $item['device'];
$item['vendor_s'] = PciId::getPciId(PciId::VENDOR, $item['vendor']);
$item['device_s'] = PciId::getPciId(PciId::DEVICE, $item['vendor'] . $item['device']);
if ($item['vendor_s'] === false) {
$pciLookup[$item['vendor']] = true;
}
if ($item['device_s'] === false) {
- $pciLookup[$item['vendor'] . ':' . $item['device']] = true;
+ $pciLookup[$devId] = true;
+ }
+ // Passthrough enabled?
+ if (isset($passthroughTypes[$devId])) {
+ $item['pt'] = implode(', ', $passthroughTypes[$devId]);
}
$class = $item['class'];
- if ($class === '0300' || $class === '0200' || $class === '0403') {
+ if ($class === '0300' || $class === '0200' || $class === '0403' || !empty($item['pt'])) {
$dst =& $client['lspci1'];
} else {
$dst =& $client['lspci2'];