Skip to content

Commit

Permalink
Adding support Dell Networking OS (as L2 switch)
Browse files Browse the repository at this point in the history
  • Loading branch information
meklis committed Dec 2, 2024
1 parent b59f6c0 commit ef19aea
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 1 deletion.
31 changes: 31 additions & 0 deletions configs/models/Dell-switches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,34 @@ models:
multi_console_command: \SwitcherCore\Modules\DellSwitch\MultiRawConsoleCommand
lldp_info: \SwitcherCore\Modules\DellSwitch\LldpInfo
net_settings: \SwitcherCore\Modules\General\NetSettings

- name: Dell Networking OS
key: dell_networking_os
device_type: SWITCH
inputs:
- snmp
- console
detect: {description: .*, objid: ^.1.3.6.1.4.1.6027 }
traps:
- ./traps/global.yml
extra:
console_conn_type: dell
modules:
parse_interface: \SwitcherCore\Modules\DellSwitch\ParseInterface
fdb: \SwitcherCore\Modules\DellSwitch\Fdb
link_info: \SwitcherCore\Modules\DellSwitch\LinkInfo
interface_counters: \SwitcherCore\Modules\DellSwitch\Counters
system: \SwitcherCore\Modules\DellSwitch\System
vlans: \SwitcherCore\Modules\DellSwitch\VlansDot1q
errors: \SwitcherCore\Modules\DellSwitch\Errors
rmon: \SwitcherCore\Modules\DellSwitch\Rmon
pvid: \SwitcherCore\Modules\DellSwitch\PvidDot1q
vlans_by_port: \SwitcherCore\Modules\DellSwitch\VlanByPorts
interface_descriptions: \SwitcherCore\Modules\DellSwitch\Descriptions
interfaces_list: \SwitcherCore\Modules\DellSwitch\InterfacesList
ctrl_port_descr: \SwitcherCore\Modules\DellSwitch\SetPortDescription
ctrl_port_state: \SwitcherCore\Modules\DellSwitch\StatePortControl
console_command: \SwitcherCore\Modules\DellSwitch\RawConsoleCommand
multi_console_command: \SwitcherCore\Modules\DellSwitch\MultiRawConsoleCommand
lldp_info: \SwitcherCore\Modules\DellSwitch\LldpInfo
net_settings: \SwitcherCore\Modules\General\NetSettings
2 changes: 1 addition & 1 deletion configs/oids/global.oids.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
- {name: if.HCOutBroadcastPkts, oid: .1.3.6.1.2.1.31.1.1.1.13, access: read }
- {name: if.HCInBroadcastPkts, oid: .1.3.6.1.2.1.31.1.1.1.9, access: read }

- {name: if.HighSpeed, oid: .1.3.6.1.2.1.31.1.1.1.15, access: read, values: {0: "Down", 1000: 1G, 1250: 1.25G, 2000: 2G, 3000: 3G, 4000: 3G, 2488: 2.5G, 2500: 2.5G, 10000: 10G, 20000: 20G, 30000: 30G, 40000: 40G } }
- {name: if.HighSpeed, oid: .1.3.6.1.2.1.31.1.1.1.15, access: read, values: {0: "Down", 1000: 1G, 1250: 1.25G, 2000: 2G, 3000: 3G, 4000: 3G, 2488: 2.5G, 2500: 2.5G, 10000: 10G, 20000: 20G, 30000: 30G, 40000: 40G, 50000: 50G, 60000: 60G, 80000: 80G, 100000: 100G } }
- {name: if.ConnectorPresent, oid: .1.3.6.1.2.1.31.1.1.1.17, access: read, values: { 1: 'YES', 2: 'NO' } }
- {name: if.Name, oid: .1.3.6.1.2.1.31.1.1.1.1, access: read }
- {name: if.Alias, oid: .1.3.6.1.2.1.31.1.1.1.18, access: write }
Expand Down
52 changes: 52 additions & 0 deletions src/Modules/DellSwitch/Fdb.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,56 @@
class Fdb extends FdbDot1Bridge
{
use InterfacesTrait;

protected function formate() {
if($this->response) {
$pretties = [];
$statuses = [];
$ports = [];
if($this->response['dot1q.FdbStatus']->error()) {
throw new \Exception("Returned error {$this->response['dot1q.FdbStatus']->error()} from {$this->response['dot1q.FdbStatus']->getRaw()->ip}");
} else {
while ($d = $this->response['dot1q.FdbStatus']->fetchOne()) {
$data = Helper::oid2MacVlan($d->getOid());
$statuses["{$data['vid']}-{$data['mac']}"] = $d->getParsedValue();
}
}
if($this->response['dot1q.FdbPort']->error()) {
throw new \Exception("Returned error {$this->response['dot1q.FdbPort']->error()} from {$this->response['dot1q.FdbPort']->getRaw()->ip}");
} else {
while ($d = $this->response['dot1q.FdbPort']->fetchOne()) {
$data = Helper::oid2MacVlan($d->getOid());
$ports["{$data['vid']}-{$data['mac']}"] = $d->getValue();
}
}
foreach ($statuses as $key=>$status) {
list($vlanId, $macAddr) = explode("-", $key);
if(!isset($ports[$key])) {
continue;
}
if(!(int)$ports[$key]) continue;
try {
$pretties[] = [
'interface' => $this->getIfaceByDot1q($ports[$key]),
'vlan_id' => (int)$vlanId,
'mac_address' => $macAddr,
'status' => $status,
];
} catch (\Throwable $e) {}
}
return $pretties;
} else {
throw new \Exception("No response");
}
}

protected function getIfaceByDot1q($ident) {
$filtered = array_filter($this->getInterfacesIds(), function ($iface) use ($ident) {
return $iface['_dot1q_id'] == $ident;
});
if(count($filtered) > 0) {
return array_values($filtered)[0];
}
return null;
}
}
29 changes: 29 additions & 0 deletions src/Modules/DellSwitch/InterfacesTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ function getInterfacesIds()
}
$response = $this->snmp->walk([
Oid::init($this->oids->getOidByName('if.Name')->getOid()),
Oid::init($this->oids->getOidByName('dot1q.PortIfIndex')->getOid()),
]);
$responses = [];
foreach ($response as $resp) {
Expand All @@ -104,8 +105,36 @@ function getInterfacesIds()
'id' => (int)$id,
'name' => $r->getValue(),
'_snmp_id' => $id,
'_dot1q_id' => null,
];
}
if (preg_match('/^(TenGigabitEthernet|fortyGigE) ([0-9]{1,4})\/([0-9]{1,4})$/', $r->getValue(), $m)) {
$id = Helper::getIndexByOid($r->getOid());
$ifaces[Helper::getIndexByOid($r->getOid())] = [
'id' => (int)$id,
'name' => $r->getValue(),
'_snmp_id' => $id,
'_dot1q_id' => null,
];
}
if (preg_match('/^(Port-channel) ([0-9]{1,4})$/', $r->getValue(), $m)) {
$id = Helper::getIndexByOid($r->getOid());
$ifaces[Helper::getIndexByOid($r->getOid())] = [
'id' => (int)$id,
'name' => $r->getValue(),
'_snmp_id' => $id,
'_dot1q_id' => null,
];
}
}
try {
foreach ($responses['dot1q.PortIfIndex'] as $r) {
if(isset($ifaces[$r->getValue()])) {
$ifaces[$r->getValue()]['_dot1q_id'] = Helper::getIndexByOid($r->getOid());
}
}
} catch (\Exception $e) {

}
$this->_interfaces = $ifaces;
$this->setCache("INTERFACES", $ifaces, 600, true);
Expand Down

0 comments on commit ef19aea

Please sign in to comment.