mirror of
				https://github.com/KevinMidboe/mktxp-no-cli.git
				synced 2025-10-29 17:50:23 +00:00 
			
		
		
		
	Merge pull request #101 from urbanserj/wifi-qcom
Add support for RouterOS version 7.13
This commit is contained in:
		| @@ -42,8 +42,8 @@ class WirelessOutput: | |||||||
|  |  | ||||||
|         output_records = 0 |         output_records = 0 | ||||||
|         registration_records = len(registration_records)                 |         registration_records = len(registration_records)                 | ||||||
|         output_entry = BaseOutputProcessor.OutputWiFiWave2Entry \ |         output_entry = BaseOutputProcessor.OutputWiFiEntry \ | ||||||
|                         if WirelessMetricsDataSource.wifiwave2_installed(router_entry) else BaseOutputProcessor.OutputWiFiEntry |                         if WirelessMetricsDataSource.is_legacy(router_entry) else BaseOutputProcessor.OutputWirelessEntry | ||||||
|         output_table = BaseOutputProcessor.output_table(output_entry) |         output_table = BaseOutputProcessor.output_table(output_entry) | ||||||
|          |          | ||||||
|         for key in dhcp_rt_by_interface.keys(): |         for key in dhcp_rt_by_interface.keys(): | ||||||
|   | |||||||
| @@ -19,17 +19,19 @@ from mktxp.datasource.wireless_ds import WirelessMetricsDataSource | |||||||
| class CapsmanInfo: | class CapsmanInfo: | ||||||
|     @staticmethod |     @staticmethod | ||||||
|     def capsman_path(router_entry): |     def capsman_path(router_entry): | ||||||
|         if WirelessMetricsDataSource.wifiwave2_installed(router_entry): |         if WirelessMetricsDataSource.is_legacy(router_entry): | ||||||
|             return '/interface/wifiwave2/capsman' |  | ||||||
|         else: |  | ||||||
|             return '/caps-man' |             return '/caps-man' | ||||||
|  |         else: | ||||||
|  |             wireless_package = WirelessMetricsDataSource.wireless_package(router_entry) | ||||||
|  |             return f'/interface/{wireless_package}/capsman' | ||||||
|  |  | ||||||
|     @staticmethod |     @staticmethod | ||||||
|     def registration_table_path(router_entry): |     def registration_table_path(router_entry): | ||||||
|         if WirelessMetricsDataSource.wifiwave2_installed(router_entry): |         if WirelessMetricsDataSource.is_legacy(router_entry): | ||||||
|             return '/interface/wifiwave2/registration-table' |  | ||||||
|         else: |  | ||||||
|             return '/caps-man/registration-table' |             return '/caps-man/registration-table' | ||||||
|  |         else: | ||||||
|  |             wireless_package = WirelessMetricsDataSource.wireless_package(router_entry) | ||||||
|  |             return f'/interface/{wireless_package}/registration-table' | ||||||
|  |  | ||||||
| class CapsmanCapsMetricsDataSource: | class CapsmanCapsMetricsDataSource: | ||||||
|     ''' Caps Metrics data provider |     ''' Caps Metrics data provider | ||||||
| @@ -76,7 +78,7 @@ class CapsmanInterfacesDatasource: | |||||||
|  |  | ||||||
|     @staticmethod |     @staticmethod | ||||||
|     def metric_records(router_entry, *, metric_labels = None): |     def metric_records(router_entry, *, metric_labels = None): | ||||||
|         if WirelessMetricsDataSource.wireless_package(router_entry) == WirelessMetricsDataSource.WIFIWAVE2: |         if not WirelessMetricsDataSource.is_legacy(router_entry): | ||||||
|             return None             |             return None             | ||||||
|         if metric_labels is None: |         if metric_labels is None: | ||||||
|             metric_labels = []                 |             metric_labels = []                 | ||||||
|   | |||||||
| @@ -21,6 +21,7 @@ class WirelessMetricsDataSource: | |||||||
|     '''              |     '''              | ||||||
|     WIFIWAVE2 = 'wifiwave2' |     WIFIWAVE2 = 'wifiwave2' | ||||||
|     WIRELESS = 'wireless' |     WIRELESS = 'wireless' | ||||||
|  |     WIFI = 'wifi' | ||||||
|  |  | ||||||
|     @staticmethod |     @staticmethod | ||||||
|     def metric_records(router_entry, *, metric_labels = None, add_router_id = True): |     def metric_records(router_entry, *, metric_labels = None, add_router_id = True): | ||||||
| @@ -45,10 +46,14 @@ class WirelessMetricsDataSource: | |||||||
|     @staticmethod |     @staticmethod | ||||||
|     def wireless_package(router_entry): |     def wireless_package(router_entry): | ||||||
|         if not router_entry.wifi_package: |         if not router_entry.wifi_package: | ||||||
|             ww2_installed = PackageMetricsDataSource.is_package_installed(router_entry, package_name = WirelessMetricsDataSource.WIFIWAVE2) |             if PackageMetricsDataSource.is_package_installed(router_entry, package_name = WirelessMetricsDataSource.WIRELESS): | ||||||
|             router_entry.wifi_package = WirelessMetricsDataSource.WIFIWAVE2 if ww2_installed else WirelessMetricsDataSource.WIRELESS |               router_entry.wifi_package = WirelessMetricsDataSource.WIRELESS | ||||||
|  |             elif PackageMetricsDataSource.is_package_installed(router_entry, package_name = WirelessMetricsDataSource.WIFIWAVE2): | ||||||
|  |               router_entry.wifi_package = WirelessMetricsDataSource.WIFIWAVE2 | ||||||
|  |             else: | ||||||
|  |               router_entry.wifi_package = WirelessMetricsDataSource.WIFI | ||||||
|         return router_entry.wifi_package |         return router_entry.wifi_package | ||||||
|  |  | ||||||
|     @staticmethod |     @staticmethod | ||||||
|     def wifiwave2_installed(router_entry): |     def is_legacy(router_entry): | ||||||
|         return WirelessMetricsDataSource.wireless_package(router_entry) == WirelessMetricsDataSource.WIFIWAVE2 |         return WirelessMetricsDataSource.wireless_package(router_entry) == WirelessMetricsDataSource.WIRELESS | ||||||
|   | |||||||
| @@ -27,11 +27,11 @@ class BaseOutputProcessor: | |||||||
|     OutputCapsmanEntry = namedtuple('OutputCapsmanEntry', ['dhcp_name', 'dhcp_address', 'mac_address', 'rx_signal', 'interface', 'ssid', 'tx_rate', 'rx_rate', 'uptime']) |     OutputCapsmanEntry = namedtuple('OutputCapsmanEntry', ['dhcp_name', 'dhcp_address', 'mac_address', 'rx_signal', 'interface', 'ssid', 'tx_rate', 'rx_rate', 'uptime']) | ||||||
|     OutputCapsmanEntry.__new__.__defaults__ = ('',) * len(OutputCapsmanEntry._fields) |     OutputCapsmanEntry.__new__.__defaults__ = ('',) * len(OutputCapsmanEntry._fields) | ||||||
|  |  | ||||||
|     OutputWiFiEntry = namedtuple('OutputWiFiEntry', ['dhcp_name', 'dhcp_address', 'mac_address', 'signal_strength', 'signal_to_noise', 'interface', 'tx_rate', 'rx_rate', 'uptime']) |     OutputWirelessEntry = namedtuple('OutputWirelessEntry', ['dhcp_name', 'dhcp_address', 'mac_address', 'signal_strength', 'signal_to_noise', 'interface', 'tx_rate', 'rx_rate', 'uptime']) | ||||||
|     OutputWiFiEntry.__new__.__defaults__ = ('',) * len(OutputWiFiEntry._fields) |     OutputWirelessEntry.__new__.__defaults__ = ('',) * len(OutputWirelessEntry._fields) | ||||||
|  |  | ||||||
|     OutputWiFiWave2Entry = namedtuple('OutputWiFiWave2Entry', ['dhcp_name', 'dhcp_address', 'mac_address', 'signal_strength', 'interface', 'tx_rate', 'rx_rate', 'uptime']) |     OutputWiFiEntry = namedtuple('OutputWiFiEntry', ['dhcp_name', 'dhcp_address', 'mac_address', 'signal_strength', 'interface', 'tx_rate', 'rx_rate', 'uptime']) | ||||||
|     OutputWiFiWave2Entry.__new__.__defaults__ = ('',) * len(OutputWiFiWave2Entry._fields) |     OutputWiFiEntry.__new__.__defaults__ = ('',) * len(OutputWiFiEntry._fields) | ||||||
|  |  | ||||||
|     OutputDHCPEntry = namedtuple('OutputDHCPEntry', ['host_name', 'server', 'mac_address', 'address', 'active_address', 'expires_after']) |     OutputDHCPEntry = namedtuple('OutputDHCPEntry', ['host_name', 'server', 'mac_address', 'address', 'active_address', 'expires_after']) | ||||||
|     OutputDHCPEntry.__new__.__defaults__ = ('',) * len(OutputDHCPEntry._fields) |     OutputDHCPEntry.__new__.__defaults__ = ('',) * len(OutputDHCPEntry._fields) | ||||||
| @@ -50,13 +50,13 @@ class BaseOutputProcessor: | |||||||
|             registration_record['rx_bytes'] = registration_record['bytes'].split(',')[1] |             registration_record['rx_bytes'] = registration_record['bytes'].split(',')[1] | ||||||
|             del registration_record['bytes'] |             del registration_record['bytes'] | ||||||
|  |  | ||||||
|         ww2_installed = WirelessMetricsDataSource.wifiwave2_installed(router_entry) |         is_legacy = WirelessMetricsDataSource.is_legacy(router_entry) | ||||||
|         if registration_record.get('tx_rate'): |         if registration_record.get('tx_rate'): | ||||||
|             registration_record['tx_rate'] = BaseOutputProcessor.parse_bitrates(registration_record['tx_rate']) \ |             registration_record['tx_rate'] = BaseOutputProcessor.parse_bitrates(registration_record['tx_rate']) \ | ||||||
|                                                 if ww2_installed else BaseOutputProcessor.parse_rates(registration_record['tx_rate']) |                                                 if not is_legacy else BaseOutputProcessor.parse_rates(registration_record['tx_rate']) | ||||||
|         if registration_record.get('rx_rate'): |         if registration_record.get('rx_rate'): | ||||||
|             registration_record['rx_rate'] = BaseOutputProcessor.parse_bitrates(registration_record['rx_rate']) \ |             registration_record['rx_rate'] = BaseOutputProcessor.parse_bitrates(registration_record['rx_rate']) \ | ||||||
|                                                 if ww2_installed else BaseOutputProcessor.parse_rates(registration_record['rx_rate']) |                                                 if not is_legacy else BaseOutputProcessor.parse_rates(registration_record['rx_rate']) | ||||||
|         if registration_record.get('uptime'): |         if registration_record.get('uptime'): | ||||||
|             registration_record['uptime'] = naturaldelta(BaseOutputProcessor.parse_timedelta_seconds(registration_record['uptime']), months=True, minimum_unit='seconds') |             registration_record['uptime'] = naturaldelta(BaseOutputProcessor.parse_timedelta_seconds(registration_record['uptime']), months=True, minimum_unit='seconds') | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user