Skip to content

Commit

Permalink
special crutch|fix for Oleksiy S
Browse files Browse the repository at this point in the history
  • Loading branch information
meklis committed May 20, 2024
1 parent 914b25f commit 07b75c2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
5 changes: 3 additions & 2 deletions src/Modules/AlcatelSwitch/VlansDot1q.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ protected function formate() {
$names = $this->getResponseByName('dot1q.VlanStaticName');
$egress = $this->getResponseByName('dot1q.VlanStaticEgressPorts');

if($names->error()) {
throw new IncompleteResponseException($names->error());
if ($names->error()) {
$this->logger->error($names->error());
return [];
}
if($egress->error()) {
throw new IncompleteResponseException($egress->error());
Expand Down
3 changes: 2 additions & 1 deletion src/Modules/AlliedTelesisSwitch/VlansDot1q.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ protected function formate() {
$egress = $this->getResponseByName('dot1q.VlanStaticEgressPorts');

if($names->error()) {
throw new IncompleteResponseException($names->error());
$this->logger->error($names->error());
return [];
}
if($egress->error()) {
throw new IncompleteResponseException($egress->error());
Expand Down
5 changes: 3 additions & 2 deletions src/Modules/General/Switches/VlansDot1q.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ protected function formate() {
$names = $this->getResponseByName('dot1q.VlanStaticName');
$egress = $this->getResponseByName('dot1q.VlanStaticEgressPorts');

if($names->error()) {
throw new IncompleteResponseException($names->error());
if ($names->error()) {
$this->logger->error($names->error());
return [];
}
if($egress->error()) {
throw new IncompleteResponseException($egress->error());
Expand Down
28 changes: 15 additions & 13 deletions src/Modules/HpSwitch/VlansDot1q.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,25 @@ class VlansDot1q extends \SwitcherCore\Modules\General\Switches\VlansDot1q
{
use InterfacesTrait;

protected function formate() {
protected function formate()
{
$response = [];
$forbidden = $this->getResponseByName('dot1q.VlanStaticForbiddenEgressPorts');
$untagged = $this->getResponseByName('dot1q.VlanStaticUntaggedPorts');
$names = $this->getResponseByName('dot1q.VlanStaticName');
$egress = $this->getResponseByName('dot1q.VlanStaticEgressPorts');

if($names->error()) {
throw new IncompleteResponseException($names->error());
if ($names->error()) {
$this->logger->error($names->error());
return [];
}
if($egress->error()) {
if ($egress->error()) {
throw new IncompleteResponseException($egress->error());
}
if($untagged->error()) {
if ($untagged->error()) {
throw new IncompleteResponseException($untagged->error());
}
if($forbidden->error()) {
if ($forbidden->error()) {
throw new IncompleteResponseException($forbidden->error());
}

Expand All @@ -39,8 +41,8 @@ protected function formate() {
$formater = function ($resp) use ($indexes) {
$dex = Helper::hexToBinStr($resp->getHexValue());
$ports = [];
for($port = 1; $port < strlen($dex) ; $port++) {
if($dex[$port] == '1' && isset($indexes[$port])) $ports[] = $indexes[$port];
for ($port = 1; $port < strlen($dex); $port++) {
if ($dex[$port] == '1' && isset($indexes[$port])) $ports[] = $indexes[$port];
}
return $ports;
};
Expand All @@ -52,19 +54,19 @@ protected function formate() {
}

foreach ($egress->fetchAll() as $resp) {
$response[ Helper::getIndexByOid($resp->getOid())]['ports']['egress'] = $formater($resp);
$response[Helper::getIndexByOid($resp->getOid())]['ports']['egress'] = $formater($resp);
}

foreach ($untagged->fetchAll() as $resp) {
$response[ Helper::getIndexByOid($resp->getOid())]['ports']['untagged'] = $formater($resp);
$response[Helper::getIndexByOid($resp->getOid())]['ports']['untagged'] = $formater($resp);
}
foreach ($forbidden->fetchAll() as $resp) {
$response[ Helper::getIndexByOid($resp->getOid())]['ports']['forbidden'] = $formater($resp);
$response[Helper::getIndexByOid($resp->getOid())]['ports']['forbidden'] = $formater($resp);
}
foreach ($response as $vlan_id => $resp) {
foreach ($resp['ports']['egress'] as $port) {
if(in_array($port, $response[$vlan_id]['ports']['untagged'])) continue;
if(in_array($port, $response[$vlan_id]['ports']['forbidden'])) continue;
if (in_array($port, $response[$vlan_id]['ports']['untagged'])) continue;
if (in_array($port, $response[$vlan_id]['ports']['forbidden'])) continue;
$response[$vlan_id]['ports']['tagged'][] = $port;
}
}
Expand Down

0 comments on commit 07b75c2

Please sign in to comment.