From 2767b30ebe76642283b36981672d6add92017ab8 Mon Sep 17 00:00:00 2001 From: thl-cmk <thl-cmk@outlook.com> Date: Sat, 31 Jul 2021 14:38:22 +0000 Subject: [PATCH] Delete snmp_cisco_flash --- inventory/snmp_cisco_flash | 295 ------------------------------------- 1 file changed, 295 deletions(-) delete mode 100644 inventory/snmp_cisco_flash diff --git a/inventory/snmp_cisco_flash b/inventory/snmp_cisco_flash deleted file mode 100644 index 9c71698..0000000 --- a/inventory/snmp_cisco_flash +++ /dev/null @@ -1,295 +0,0 @@ -#!/usr/bin/python -# -*- encoding: utf-8; py-indent-offset: 4 -*- -# -# invetory of cisco flash devices -# writen by: Th.L thl-cmk[at]outlook[dot]com -# -# 2019-10-22 : -# -# -# - - -def inv_cisco_flash(info, params): - def DevProgrammingJumper(mode): - modes = {1: 'installed', - 2: 'not installed', - 3: 'unknown', - } - if mode.isdigit(): - mode = modes.get(int(mode), mode) - return mode - - def DevRemovable(mode): - modes = {1: 'True', - 2: 'False', - } - if mode.isdigit(): - mode = modes.get(int(mode), mode) - return mode - - def PartStatus(mode): - modes = { - 1: 'Read Only', - 2: 'run from flash', - 3: 'Read Write', - } - if mode.isdigit(): - mode = modes.get(int(mode), mode) - return mode - - def PartChecksumAlgorithm(mode): - modes = { - 1: 'simple Checksum', - 2: 'undefined', - 3: 'simple CRC', - } - if mode.isdigit(): - mode = modes.get(int(mode), mode) - return mode - - def PartUpgradeMethod(mode): - modes = { - 1: 'unkown', - 2: 'rxboot Flash Load Helper', - 3: 'direct', - } - if mode.isdigit(): - mode = modes.get(int(mode), mode) - return mode - - def PartNeedErasure(mode): - modes = { - 1: 'True', - 2: 'False', - } - if mode.isdigit(): - mode = modes.get(int(mode), mode) - return mode - - cflDevices, cflChips, cflPartitions = info - - # inventory of cisco flash devices - - removecolumns = None - disabled = False - node = None - - if params: - disabled = params.get('cflDeviceDisable', disabled) - # get list of columns to remove from inventory - removecolumns = params.get('cflDeviceRemovecolumns', removecolumns) - - if not disabled: - node = inv_tree_list('hardware.components.flash.devices:') - - for cflDevice in cflDevices: - clfOID_END, cflDevSize, cflDevMinPartitionSize, cflDevMaxPartitions, cflDevPartitions, cflDevChipCount, \ - cflDevName, cflDevDescr, cflDevController, cflDevProgrammingJumper, cflDevInitTime, cflDevRemovable, \ - cflDevPhyEntIndex, cflDevNameExtended, cflDevSizeExtended, cflDevMinPartitionSizeExtended = cflDevice - - # change sizes to MB - if cflDevSize.isdigit(): - cflDevSize = int(cflDevSize) - else: - cflDevSize = 0 - - if cflDevSizeExtended.isdigit(): - cflDevSizeExtended = int(cflDevSizeExtended) - else: - cflDevSizeExtended = 0 - - if cflDevMinPartitionSize.isdigit(): - cflDevMinPartitionSize = int(cflDevMinPartitionSize) - else: - cflDevMinPartitionSize = 0 - - if cflDevMinPartitionSizeExtended.isdigit(): - cflDevMinPartitionSizeExtended = int(cflDevMinPartitionSizeExtended) - else: - cflDevMinPartitionSizeExtended = 0 - - cflDevProgrammingJumper = DevProgrammingJumper(cflDevProgrammingJumper) - cflDevRemovable = DevRemovable(cflDevRemovable) - - node.append({ - 'index': clfOID_END, - 'size': max(cflDevSize,cflDevSizeExtended) / 1024 / 1024, - 'minpartitionsize': max(cflDevMinPartitionSize,cflDevMinPartitionSizeExtended) / 1024 / 1024, - 'maxprtitions': cflDevMaxPartitions, - 'partitions': cflDevPartitions, - 'chipcount': cflDevChipCount, - 'name': cflDevName, - 'description': cflDevDescr, - 'controller': cflDevController, - 'programmingjumper': cflDevProgrammingJumper, - 'inittime': cflDevInitTime, - 'removable': cflDevRemovable, - 'physentindex': cflDevPhyEntIndex, - 'nameextended': cflDevNameExtended, - }) - - for i in node: - if removecolumns is not None: - for column in removecolumns: - if i.get(column) is not None: - i.pop(column) - - # inventory of cisco flash chips - - removecolumns = None - disabled = False - - if params: - disabled = params.get('cflChipDisable', disabled) - # get list of columns to remove from inventory - removecolumns = params.get('cflChipRemovecolumns', removecolumns) - - if not disabled: - node = inv_tree_list('hardware.components.flash.chips:') - - for cflChip in cflChips: - cflOID_END, cflChipCode,cflChipDescr,cflChipWriteRetries,cflChipEraseRetries,cflChipMaxWriteRetries,cflChipMaxEraseRetries = cflChip - cflDevIndex, cflChipIndex = cflOID_END.split('.') - - node.append({ - 'index': cflChipIndex, - 'flashindex': cflDevIndex, - 'code': cflChipCode, - 'description': cflChipDescr, - 'writeretries': cflChipWriteRetries, - 'eraseretries': cflChipEraseRetries, - 'maxwriteretries': cflChipMaxWriteRetries, - 'maxeraseretries': cflChipMaxEraseRetries, - }) - - for i in node: - if removecolumns is not None: - for column in removecolumns: - if i.get(column) is not None: - i.pop(column) - - # inventory of cisco flash partitions - - removecolumns = None - disabled = False - - if params: - disabled = params.get('cflPartitionDisable', disabled) - # get list of columns to remove from inventory - removecolumns = params.get('cflPartitionRemovecolumns', removecolumns) - - if not disabled: - node = inv_tree_list('hardware.components.flash.partitions:') - - for cflPartition in cflPartitions: - cflpartOID_END, cflpartStartChip, cflpartEndChip, cflpartSize, cflpartFreeSpace, cflpartFileCount,\ - cflpartChecksumAlgorithm, cflpartStatus, cflpartUpgradeMethod, cflpartName, cflpartNeedErasure,\ - cflpartFileNameLength, cflpartSizeExtended, cflpartFreeSpaceExtended, cflpartLowSpaceNotifThreshold = cflPartition - cflDevIndex, cflPartIndex = cflpartOID_END.split('.') - - # change sizes to MB - if cflpartSize.isdigit(): - cflpartSize = int(cflpartSize) - else: - cflpartSize = 0 - - if cflpartFreeSpace.isdigit(): - cflpartFreeSpace = int(cflpartFreeSpace) - else: - cflpartFreeSpace = 0 - - - if cflpartSizeExtended.isdigit(): - cflpartSizeExtended = int(cflpartSizeExtended) - else: - cflpartSizeExtended=0 - - if cflpartFreeSpaceExtended.isdigit(): - cflpartFreeSpaceExtended = int(cflpartFreeSpaceExtended) - else: - cflpartFreeSpaceExtended = 0 - - cflpartStatus = PartStatus(cflpartStatus) - cflpartChecksumAlgorithm = PartChecksumAlgorithm(cflpartChecksumAlgorithm) - cflpartUpgradeMethod = PartUpgradeMethod(cflpartUpgradeMethod) - cflpartNeedErasure = PartNeedErasure(cflpartNeedErasure) - - node.append({ - 'index': cflPartIndex, - 'flashindex': cflDevIndex, - 'startchip': cflpartStartChip, - 'endchip': cflpartEndChip, - 'size': max(cflpartSize, cflpartSizeExtended) / 1024 / 1024, - 'freespace': max(cflpartFreeSpace,cflpartFreeSpaceExtended) / 1024 / 1024, - 'filecount': cflpartFileCount, - 'crcsumalgo': cflpartChecksumAlgorithm, - 'status':cflpartStatus, - 'upgrademethod': cflpartUpgradeMethod, - 'name': cflpartName, - 'neederasure': cflpartNeedErasure, - 'filenamelength': cflpartFileNameLength, - 'lowspacenotifythreshold':cflpartLowSpaceNotifThreshold, - }) - - for i in node: - if removecolumns is not None: - for column in removecolumns: - if i.get(column) is not None: - i.pop(column) - return node - - -inv_info['inv_cisco_flash'] = { - 'inv_function' : inv_cisco_flash, - 'snmp_scan_function': lambda oid: oid('.1.3.6.1.2.1.1.1.0').lower().find('cisco') != -1 and - oid('.1.3.6.1.4.1.9.9.10.1.1.1.*'), # CISCO-FLASH-MIB::ciscoFlashDevicesSupported - 'snmp_info' : [#('.1.3.6.1.4.1.9.9.10.1.1', [ # CISCO-FLASH-MIB - #'1', # ciscoFlashDevicesSupported - #]), - ('.1.3.6.1.4.1.9.9.10.1.1.2.1', [ - OID_END, # - '2', # ciscoFlashDeviceSize - '3', # ciscoFlashDeviceMinPartitionSize - '4', # ciscoFlashDeviceMaxPartitions - '5', # ciscoFlashDevicePartitions - '6', # ciscoFlashDeviceChipCount - '7', # ciscoFlashDeviceName - '8', # ciscoFlashDeviceDescr - '9', # ciscoFlashDeviceController - '11', # ciscoFlashDeviceProgrammingJumper - '12', # ciscoFlashDeviceInitTime - '13', # ciscoFlashDeviceRemovable - '14', # ciscoFlashPhyEntIndex - '15', # ciscoFlashDeviceNameExtended - '16', # ciscoFlashDeviceSizeExtended - '17', # ciscoFlashDeviceMinPartitionSizeExtended - ]), - ('.1.3.6.1.4.1.9.9.10.1.1.3.1.1', [ - OID_END, # - '2', # ciscoFlashChipCode - '3', # ciscoFlashChipDescr - '4', # ciscoFlashChipWriteRetries - '5', # ciscoFlashChipEraseRetries - '6', # ciscoFlashChipMaxWriteRetries - '7', # ciscoFlashChipMaxEraseRetries - ]), - ('.1.3.6.1.4.1.9.9.10.1.1.4.1.1', [ - OID_END, # - '2', # ciscoFlashPartitionStartChip - '3', # ciscoFlashPartitionEndChip - '4', # ciscoFlashPartitionSize - '5', # ciscoFlashPartitionFreeSpace - '6', # ciscoFlashPartitionFileCount - '7', # ciscoFlashPartitionChecksumAlgorithm - '8', # ciscoFlashPartitionStatus - '9', # ciscoFlashPartitionUpgradeMethod - '10', # ciscoFlashPartitionName - '11', # ciscoFlashPartitionNeedErasure - '12', # ciscoFlashPartitionFileNameLength - '13', # ciscoFlashPartitionSizeExtended - '14', # ciscoFlashPartitionFreeSpaceExtended - '15', # ciscoFlashPartitionLowSpaceNotifThreshold - ]) - ], -} -- GitLab