diff --git a/netengine/backends/snmp/airos.py b/netengine/backends/snmp/airos.py index 24c7fd1..64cbb12 100644 --- a/netengine/backends/snmp/airos.py +++ b/netengine/backends/snmp/airos.py @@ -317,13 +317,10 @@ def interfaces_to_dict(self): result = self._dict( { 'name': self.interfaces_MAC[i]['name'], - 'type': self.interfaces_type[i]['type'], - 'mac_address': self.interfaces_MAC[i]['mac_address'], - 'rx_bytes': int(self.interfaces_bytes[i]['rx']), - 'tx_bytes': int(self.interfaces_bytes[i]['tx']), - 'state': self.interfaces_state[i]['state'], - 'mtu': int(self.interfaces_mtu[i]['mtu']), - 'speed': int(self.interfaces_speed[i]['speed']), + 'statistics': { + 'rx_bytes': int(self.interfaces_bytes[i]['rx']), + 'tx_bytes': int(self.interfaces_bytes[i]['tx']), + }, } ) results.append(result) @@ -403,20 +400,16 @@ def RAM_free(self): def to_dict(self): return self._dict( { - 'name': self.name, - 'type': 'radio', - 'os': self.os[0], - 'os_version': self.os[1], - 'manufacturer': self.manufacturer, - 'model': self.model, - 'RAM_total': self.RAM_total, - 'RAM_free': self.RAM_free, - 'uptime': self.uptime, - 'uptime_tuple': self.uptime_tuple, + 'type': 'DeviceMonitoring', + 'general': { + 'uptime': self.uptime, + }, + 'resources': { + 'memory': { + 'total': self.RAM_total, + 'free': self.RAM_free, + }, + }, 'interfaces': self.interfaces_to_dict, - 'antennas': [], - 'wireless_dbm': self.wireless_dbm, - 'wireless_links': self.wireless_links, - 'routing_protocols': None, } ) diff --git a/netengine/backends/snmp/openwrt.py b/netengine/backends/snmp/openwrt.py index 2e21adb..9c8d6c0 100644 --- a/netengine/backends/snmp/openwrt.py +++ b/netengine/backends/snmp/openwrt.py @@ -368,15 +368,10 @@ def interfaces_to_dict(self): result = self._dict( { 'name': name, - 'type': if_type, - 'mac_address': mac_address, - 'ip_address': ip_address, - 'netmask': netmask, - 'rx_bytes': rx_bytes, - 'tx_bytes': tx_bytes, - 'state': state, - 'mtu': mtu, - 'speed': speed, + 'statistics': { + 'rx_bytes': rx_bytes, + 'tx_bytes': tx_bytes, + }, } ) results.append(result) @@ -392,17 +387,15 @@ def RAM_total(self): def to_dict(self): return self._dict( { - 'name': self.name, - 'type': 'radio', - 'os': self.os[0], - 'os_version': self.os[1], - 'manufacturer': self.manufacturer, - 'model': None, - 'RAM_total': self.RAM_total, - 'uptime': self.uptime, - 'uptime_tuple': self.uptime_tuple, - 'interfaces': self.get_interfaces(), - 'antennas': [], - 'routing_protocols': None, + 'type': 'DeviceMonitoring', + 'general': { + 'uptime': self.uptime, + }, + 'resources': { + 'memory': { + 'total': self.RAM_total, + } + }, + 'interfaces': self.interfaces_to_dict, } ) diff --git a/tests/test_snmp/test_airos.py b/tests/test_snmp/test_airos.py index 4ea3227..4630db7 100644 --- a/tests/test_snmp/test_airos.py +++ b/tests/test_snmp/test_airos.py @@ -142,16 +142,6 @@ def test_to_dict(self): ) self.assertTrue(isinstance(self.device.to_dict(), dict)) - def test_manufacturer_to_dict(self): - with self.nextcmd_patcher as np: - SpyMock._update_patch( - np, - _mock_side_effect=lambda *args: self._get_mocked_wireless_links( - data=args - ), - ) - self.assertIsNotNone(self.device.to_dict()['manufacturer']) - def test_manufacturer(self): with self.nextcmd_patcher: self.assertIsNotNone(self.device.manufacturer) diff --git a/tests/test_snmp/test_openwrt.py b/tests/test_snmp/test_openwrt.py index f12588e..71de5fc 100644 --- a/tests/test_snmp/test_openwrt.py +++ b/tests/test_snmp/test_openwrt.py @@ -101,10 +101,5 @@ def test_to_dict(self): len(device_dict['interfaces']), len(self.device.get_interfaces()), ) - def test_manufacturer_to_dict(self): - with self.nextcmd_patcher as p: - SpyMock._update_patch(p, _mock_return_value=[0, 0, 0, [[[0, 1]]] * 5]) - self.assertIsNotNone(self.device.to_dict()['manufacturer']) - def tearDown(self): patch.stopall()