refactor - Use ->table(2) rather than ::pivotTable function. (#15796)

This commit is contained in:
Ville Hukkamäki 2024-02-03 23:32:07 +02:00 committed by GitHub
parent 0611f81b14
commit 391a918e2e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -137,18 +137,6 @@ class Powerconnect extends OS implements ProcessorDiscovery, ProcessorPolling, N
return $res;
}
private static function pivotTable(array $table): array
{
$res = [];
foreach ($table as $column => $data) {
foreach ($data as $index => $value) {
$res[$index][$column] = $value;
}
}
return $res;
}
public function pollNac()
{
$nac = new Collection();
@ -160,15 +148,13 @@ class Powerconnect extends OS implements ProcessorDiscovery, ProcessorPolling, N
return $nac;
}
$table = SnmpQuery::mibs(['DNOS-AUTHENTICATION-MANAGER-MIB'])->mibDir('dell')->hideMib()->enumStrings()->walk('agentAuthMgrClientStatusTable')->table();
$table = SnmpQuery::mibs(['DNOS-AUTHENTICATION-MANAGER-MIB'])->mibDir('dell')->hideMib()->enumStrings()->walk('agentAuthMgrClientStatusTable')->table(2);
if (count($table) === 0) {
d_echo('Client status table is empty, not processing NAC entries.');
return $nac;
}
$table = self::pivotTable($table);
$hostmode = SnmpQuery::mibs(['DNOS-AUTHENTICATION-MANAGER-MIB'])->mibDir('dell')->hideMib()->enumStrings()->walk('agentAuthMgrPortHostMode')->valuesByIndex();
foreach ($table as &$row) {
if ($row['agentAuthMgrClientAuthState'] === 'success') {