diff --git a/.env b/.env new file mode 100644 index 0000000..d24cd38 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +PYTHONPATH=lib diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..32b7042 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,28 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Python", + "type": "python", + "request": "launch", + "program": "${file}", + "console": "integratedTerminal", + "env": { + "PYTHONPATHsdsd": "${workspaceFolder}/lib;${env:PYTHONPATH}" + } + }, + { + "name": "PyTest", + "type": "python", + "request": "launch", + "stopOnEntry": false, + "module": "pytest", + "args": [ + "-sv" + ], + "cwd": "${workspaceRoot}", + "env": {}, + "envFile": "${workspaceRoot}/.env" + } + ] +} \ No newline at end of file diff --git a/lib/nelsnmp/vendors/hpe/versions.py b/lib/nelsnmp/vendors/hpe/versions.py index 6e44713..4eed787 100644 --- a/lib/nelsnmp/vendors/hpe/versions.py +++ b/lib/nelsnmp/vendors/hpe/versions.py @@ -1,5 +1,22 @@ from nelsnmp.hostinfo.version import DeviceVersion +# Comware SAMPLES +# +# Comware Platform Software, Software Version 5.20, Release 2112P08 +# HPE Comware Platform Software, Software Version 5.20.105, Release 1810P16 +# HPE Comware Platform Software, Software Version 7.1.045, Release 2432P06 + +# ProCurve SAMPLES +# +# ProCurve 516733-B21 6120XG Blade Switch, revision Z.14.58, ROM Z.14.09 (/ws/swbuildm/Z_zinfandel_fip_t4b_qaoff/code/build/vern(Z1.3.6.1.4.1.11.2.3.7.11.107 +# ProCurve J9022A Switch 2810-48G, revision N.11.78, ROM N.10.01 (/sw/code/build/bass) +# HP ProCurve 1810G - 24 GE, P.2.24, eCos-2.0, CFE-2.1 +# PROCURVE J9028B - PB.03.10 + +# OfficeConnect SAMPLES +# +# HPE OfficeConnect Switch 1820 48G J9981A, PT.02.08, Linux 3.6.5-45630aff, U-Boot 2012.10-00119-gae4e43bd91 (Aug 31 2018 - 10:12:27) + class HpeVersion(DeviceVersion): @@ -7,7 +24,33 @@ def _get_version(self): for line in self._descriptions: if 'ProCurve' in line: self.os = 'procurve' - parts = line.split() - if len(parts) > 5: - if parts[4] == 'revision': - self.version = parts[5].split(',')[0] + parts = line.split(',') + if len(parts) > 1: + if 'revision' in parts[1]: + self.version = parts[1].replace('revision', "").strip() + else: + self.version = parts[1].strip() + elif 'PROCURVE' in line: + self.os = 'procurve' + parts = line.split('-') + if len(parts) > 1: + self.version = parts[1].strip() + elif 'OfficeConnect' in line: + self.os = 'officeconnect' + parts = line.split(',') + if len(parts) > 1: + self.version = parts[1].strip() + elif 'Comware' in line: + self.os = 'comware' + parts = line.split(',') + if len(parts) > 1: + if 'Software Version' in parts[1]: + self.version = "V " + parts[1].replace('Software Version', "").strip() + if len(parts) > 2: + if 'Release' in parts[2]: + self.version += " - R " + parts[2].replace('Release', "").strip() + # default HP + elif 'HP' in line: + parts = line.split(',') + if len(parts) > 1: + self.version = parts[1].strip() diff --git a/lib/nelsnmp/vendors/mappings.py b/lib/nelsnmp/vendors/mappings.py index 67d8379..dec306c 100644 --- a/lib/nelsnmp/vendors/mappings.py +++ b/lib/nelsnmp/vendors/mappings.py @@ -2,6 +2,7 @@ vendor_map = {} vendor_map['9'] = 'cisco' vendor_map['11'] = 'hpe' +vendor_map['25506'] = 'hpe' vendor_map['1916'] = 'extreme' vendor_map['2011'] = 'huawei' vendor_map['2352'] = 'ericsson' diff --git a/tests/valid_hostinfo_files/hpe.yml b/tests/valid_hostinfo_files/hpe.yml index 26b86d5..6cd130b 100644 --- a/tests/valid_hostinfo_files/hpe.yml +++ b/tests/valid_hostinfo_files/hpe.yml @@ -1,4 +1,10 @@ --- +# OID REF +# - https://oidref.com/1.3.6.1.4.1.11.2.3.7.11 +# - http://www.circitor.fr/Mibs/Html/H/HH3C-PRODUCT-ID-MIB.php +# +# Get sysobjectid: 1.3.6.1.2.1.1.2 + procurve01: sysobjectid: 1.3.6.1.4.1.11.2.3.7.11.62 description: 'ProCurve j9020a Switch 2510-48, revision U.11.57, ROM R.10.06 (/sw/code/build/dosx' @@ -6,3 +12,72 @@ procurve01: os: procurve version: U.11.57 +procurve-516733-B21: + sysobjectid: 1.3.6.1.4.1.11.2.3.7.11.107 + description: 'ProCurve 516733-B21 6120XG Blade Switch, revision Z.14.58, ROM Z.14.09 (/ws/swbuildm' + vendor: hpe + os: procurve + version: Z.14.58 + +procurve-J9022A: + sysobjectid: 1.3.6.1.4.1.11.2.3.7.11.64 + description: 'ProCurve J9022A Switch 2810-48G, revision N.11.78, ROM N.10.01 (/sw/code/build/bass)' + vendor: hpe + os: procurve + version: N.11.78 + +procurve-J9450A: + sysobjectid: 1.3.6.1.4.1.11.2.3.7.11.104 + description: 'HP ProCurve 1810G - 24 GE, P.2.24, eCos-2.0, CFE-2.1' + vendor: hpe + os: procurve + version: P.2.24 + +procurve-J9028B: + sysobjectid: 1.3.6.1.4.1.11.2.3.7.11.81 + description: 'PROCURVE J9028B - PB.03.10' + vendor: hpe + os: procurve + version: PB.03.10 + +comware-6125G: + sysobjectid: 1.3.6.1.4.1.25506.11.1.103 + description: 'Comware Platform Software, Software Version 5.20, Release 2112P08' + vendor: hpe + os: comware + version: V 5.20 - R 2112P08 + +comware-5820X: + sysobjectid: 1.3.6.1.4.1.25506.11.1.23 + description: 'HPE Comware Platform Software, Software Version 5.20.105, Release 1810P16' + vendor: hpe + os: comware + version: V 5.20.105 - R 1810P16 + +comware-6125XLG: + sysobjectid: 1.3.6.1.4.1.25506.11.1.137 + description: 'HPE Comware Platform Software, Software Version 7.1.045, Release 2432P06' + vendor: hpe + os: comware + version: V 7.1.045 - R 2432P06 + +comware-5950: + sysobjectid: 1.3.6.1.4.1.25506.11.1.260 + description: 'HPE Comware Platform Software, Software Version 7.1.070, Release 6301' + vendor: hpe + os: comware + version: V 7.1.070 - R 6301 + +comware-5710: + sysobjectid: 1.3.6.1.4.1.25506.11.1.287 + description: 'HPE Comware Platform Software, Software Version 7.1.070, Release 2702' + vendor: hpe + os: comware + version: V 7.1.070 - R 2702 + +officeconnect-J9981A: + sysobjectid: 1.3.6.1.4.1.11.2.3.7.11.169 + description: 'HPE OfficeConnect Switch 1820 48G J9981A, PT.02.08, Linux 3.6.5-45630aff, U-Boot 2012.10-00119-gae4e43bd91 (Aug 31 2018 - 10:12:27)' + vendor: hpe + os: officeconnect + version: PT.02.08