From cb651db6f0f3f0ac33ff6667e539a5d6191a9d75 Mon Sep 17 00:00:00 2001 From: yzdann <1543472-yzdann@users.noreply.gitlab.com> Date: Sat, 30 Nov 2019 12:08:53 +0330 Subject: [PATCH 01/43] add dumb parser for parse cisco ios xe --- sysdescrparser/cisco_iosxe.py | 58 +++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 sysdescrparser/cisco_iosxe.py diff --git a/sysdescrparser/cisco_iosxe.py b/sysdescrparser/cisco_iosxe.py new file mode 100644 index 0000000..deec10f --- /dev/null +++ b/sysdescrparser/cisco_iosxe.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- + +"""sysdescrparser.cisco_iosxe.""" + + +import re +from cisco import Cisco + + +# pylint: disable=no-member +class CiscoIOSXE(Cisco): + + """Class CiscoIOSXE. + + SNMP sysDescr for CiscoIOSXE. + + """ + + def __init__(self, raw): + """Constructor.""" + super(CiscoIOSXE, self).__init__(raw) + self.os = 'IOSXE' + self.model = self.UNKNOWN + self.version = self.UNKNOWN + + def parse(self): + """Parse.""" + main_version_name = "ios-xe" + + misc_version_names = ["gibraltar", "fuji", "everest", "denali", ] + misc_version_names_regex = "|".join( + rf"\[{version_name}\]" + for version_name in misc_version_names + ) + + ios_xe_regex = f"{main_version_name}|{misc_version_names_regex}" + + ios_xe = re.search( + ios_xe_regex, self.raw, flags=re.IGNORECASE + ) + if not ios_xe: + return False + + version_regex = r"version\s+(?P[^\s,]+)" + catched_version = re.search( + version_regex, self.raw, flags=re.IGNORECASE + ) + if catched_version: + version = catched_version.groupdict()['version'] + self.version = version + + model_regex = r"software\s+\((?P.*)\)," + catched_model = re.search(model_regex, self.raw, flags=re.IGNORECASE) + if catched_model: + model = catched_model.groupdict()['model'] + self.model = model + + return self From 2b3ae7ea1c3d552770df603f18f847e2eeedfc03 Mon Sep 17 00:00:00 2001 From: yzdann <1543472-yzdann@users.noreply.gitlab.com> Date: Sat, 30 Nov 2019 12:10:31 +0330 Subject: [PATCH 02/43] add CiscoIOSXE parser to sysdescrparser --- sysdescrparser/sysdescrparser.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sysdescrparser/sysdescrparser.py b/sysdescrparser/sysdescrparser.py index dea69df..1b5872d 100644 --- a/sysdescrparser/sysdescrparser.py +++ b/sysdescrparser/sysdescrparser.py @@ -10,6 +10,7 @@ # pylint: disable=C0413 from cisco_ios import CiscoIOS from cisco_nxos import CiscoNXOS +from cisco_iosxe import CiscoIOSXE from cisco_iosxr import CiscoIOSXR from juniper_junos import JuniperJunos from juniper_screenos import JuniperScreenOS @@ -81,6 +82,12 @@ def sysdescrparser(sysdescr): if obj.parse(): return obj # + # cisco iosxe + # + obj = CiscoIOSXE(sysdescr) + if obj.parse(): + return obj + # # cisco iosxr # obj = CiscoIOSXR(sysdescr) From 8a11e95e8aac10042c95fb8ac38888dd6f82c4a5 Mon Sep 17 00:00:00 2001 From: yzdann <1543472-yzdann@users.noreply.gitlab.com> Date: Sat, 30 Nov 2019 12:23:17 +0330 Subject: [PATCH 03/43] add some ios xe samples to test ios xe parser --- samples/sample_data.json | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/samples/sample_data.json b/samples/sample_data.json index e8dfba7..3a60437 100644 --- a/samples/sample_data.json +++ b/samples/sample_data.json @@ -39,6 +39,46 @@ "version": "12.2(50)SG3" }, + { + "raw": "Cisco IOS Software [Everest], Catalyst L3 Switch Software (CAT3K_CAA-UNIVERSALK9-M), Experimental Version 16.4.20170410:165034 [v164_throttle-BLD-BLD_V164_THROTTLE_LATEST_20170410_174845 105]", + "vendor": "CISCO", + "os": "IOSXE", + "model": "CAT3K_CAA-UNIVERSALK9-M", + "version": "16.4.20170410:165034" + }, + + { + "raw": "Cisco IOS XE Software, Version 16.06.05 Cisco IOS Software [Everest], ISR Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 16.6.5, RELEASE SOFTWARE (fc3)", + "vendor": "CISCO", + "os": "IOSXE", + "model": "X86_64_LINUX_IOSD-UNIVERSALK9-M", + "version": "16.06.05" + }, + + { + "raw": "Cisco IOS Software, IOS-XE Software, Catalyst 4500 L3 Switch Software (cat4500e-UNIVERSALK9-M), Version 03.03.02.SG RELEASE SOFTWARE (fc1)", + "vendor": "CISCO", + "os": "IOSXE", + "model": "cat4500e-UNIVERSALK9-M", + "version": "03.03.02.SG" + }, + + { + "raw": "Cisco IOS Software [Denali], Catalyst L3 Switch Software (CAT3K_CAA-UNIVERSALK9-M), Version 16.3.1a, RELEASE SOFTWARE (fc4)", + "vendor": "CISCO", + "os": "IOSXE", + "model": "CAT3K_CAA-UNIVERSALK9-M", + "version": "16.3.1a" + }, + + { + "raw": "Cisco IOS Software [Fuji], ASR1000 Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 16.7.1prd4, RELEASE SOFTWARE (fc1)", + "vendor": "CISCO", + "os": "IOSXE", + "model": "X86_64_LINUX_IOSD-UNIVERSALK9-M", + "version": "16.7.1prd4" + }, + { "raw": "Cisco NX-OS(tm) cgr1000, Software (cgr1000-uk9), Version 5.2(1)CG2(1), Interim version 5.2(1)CG2(0.167), RELEASE SOFTWARE Copyright (c) 2002-2011 by Cisco Systems, Inc. Compiled 1/1/2012 1:00:00", "vendor": "CISCO", From 3bcd2bf2b7e0ce29eef8e6d63110755fe7b9b2fb Mon Sep 17 00:00:00 2001 From: yzdann <1543472-yzdann@users.noreply.gitlab.com> Date: Tue, 3 Dec 2019 17:43:52 +0330 Subject: [PATCH 04/43] add ability to parse centos and ubuntu in linux parser --- sysdescrparser/linux.py | 69 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 2 deletions(-) diff --git a/sysdescrparser/linux.py b/sysdescrparser/linux.py index e54f979..9f7ddd7 100644 --- a/sysdescrparser/linux.py +++ b/sysdescrparser/linux.py @@ -4,6 +4,7 @@ import re from sysdescr import SysDescr +from utils.utils import os_version_names_regex, extract_version_number # pylint: disable=no-name-in-module @@ -16,6 +17,24 @@ class Linux(SysDescr): """ + versions = { + "ubuntu": { + "ubuntu": "", + "lucid": "10.04", + "precise": "12.04", + "trusty": "14.04", + "xenial": "16.04", + "bionic": "18.04" + }, + "centos": { + "centos": "", + "centos6": "6.0", + "el6": "6.0", + "centos7": "7.0", + "el7": "7.0" + } + } + def __init__(self, raw): """Constructor.""" super(Linux, self).__init__(raw) @@ -34,6 +53,52 @@ def parse(self): pat = re.compile(regex) res = pat.split(self.raw) if len(res) > 2: - self.version = res[2] - return self + kernel_version = res[2] + + ubuntu_version_names_regex = os_version_names_regex(self.__class__.versions["ubuntu"]) + ubuntu_match = re.search( + ubuntu_version_names_regex, + self.raw, + flags=re.IGNORECASE + ) + + centos_version_names_regex = os_version_names_regex(self.__class__.versions["centos"]) + centos_match = re.search( + centos_version_names_regex, + self.raw, + flags=re.IGNORECASE + ) + + version_name = "" + if ubuntu_match: + self.vendor = "CANONICAL" + self.os = "UBUNTU" + version_name = ubuntu_match.group() + + if centos_match: + self.vendor = "CENTOS" + self.os = "CENTOS" + version_name = centos_match.group() + + if version_name: + # make it lower cause our versions dict keys are lower + os_lookup_name = self.os.lower() + os_versions = self.__class__.versions[os_lookup_name] + version_number = extract_version_number( + os_versions, + version_name, + ) + if version_number: + self.version = version_number + self.model = kernel_version + + else: + self.version= kernel_version + + + else: + self.version = kernel_version + + return self + return False From c9a0e21bbb3f144c7973cad7f0f4326d15519db6 Mon Sep 17 00:00:00 2001 From: yzdann <1543472-yzdann@users.noreply.gitlab.com> Date: Tue, 3 Dec 2019 17:44:57 +0330 Subject: [PATCH 05/43] change sample data due to changing linux parse function --- samples/sample_data.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/samples/sample_data.json b/samples/sample_data.json index 3a60437..85769d8 100644 --- a/samples/sample_data.json +++ b/samples/sample_data.json @@ -641,10 +641,10 @@ { "raw": "Linux HOSTNAME 2.6.32-358.6.2.el6.x86_64 #1 SMP Thu May 16 20:59:36 UTC 2013 x86_64", - "vendor": "UNKNOWN", - "os": "LINUX", - "model": "UNKNOWN", - "version": "2.6.32-358.6.2.el6.x86_64" + "vendor": "CENTOS", + "os": "CENTOS", + "model": "2.6.32-358.6.2.el6.x86_64", + "version": "6.0" }, { @@ -657,8 +657,8 @@ { "raw": "Linux hostname 3.2.0-56-generic-pae #86-Ubuntu SMP Wed Oct 23 17:51:27 UTC 2013 i686", - "vendor": "UNKNOWN", - "os": "LINUX", + "vendor": "CANONICAL", + "os": "UBUNTU", "model": "UNKNOWN", "version": "3.2.0-56-generic-pae" }, From b0169b7b24b847b8d3ae9c7580af613624d26a2c Mon Sep 17 00:00:00 2001 From: yzdann <1543472-yzdann@users.noreply.gitlab.com> Date: Wed, 4 Dec 2019 11:11:04 +0330 Subject: [PATCH 06/43] fix bug for not showing ubuntu lts version in string with ubuntu, and also model, version fix --- sysdescrparser/linux.py | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/sysdescrparser/linux.py b/sysdescrparser/linux.py index 9f7ddd7..884adfa 100644 --- a/sysdescrparser/linux.py +++ b/sysdescrparser/linux.py @@ -19,19 +19,18 @@ class Linux(SysDescr): versions = { "ubuntu": { - "ubuntu": "", "lucid": "10.04", "precise": "12.04", "trusty": "14.04", "xenial": "16.04", - "bionic": "18.04" + "bionic": "18.04", }, "centos": { - "centos": "", "centos6": "6.0", "el6": "6.0", "centos7": "7.0", - "el7": "7.0" + "el7": "7.0", + "centos": "", } } @@ -45,6 +44,9 @@ def __init__(self, raw): def parse(self): """Parsing for sysDescr value.""" + version_name = "" + kernel_version = "" + regex = (r'^Linux\s+') pat = re.compile(regex) res = pat.search(self.raw) @@ -56,11 +58,16 @@ def parse(self): kernel_version = res[2] ubuntu_version_names_regex = os_version_names_regex(self.__class__.versions["ubuntu"]) - ubuntu_match = re.search( + ubuntu_lts_match = re.search( ubuntu_version_names_regex, self.raw, flags=re.IGNORECASE ) + ubuntu_main_version_name_match = re.search( + "ubuntu", + self.raw, + flags=re.IGNORECASE + ) centos_version_names_regex = os_version_names_regex(self.__class__.versions["centos"]) centos_match = re.search( @@ -69,18 +76,22 @@ def parse(self): flags=re.IGNORECASE ) - version_name = "" - if ubuntu_match: + if ubuntu_lts_match or ubuntu_main_version_name_match: self.vendor = "CANONICAL" self.os = "UBUNTU" - version_name = ubuntu_match.group() + + if not ubuntu_lts_match: + version_name = self.UNKNOWN + + else: + version_name = ubuntu_lts_match.group() if centos_match: self.vendor = "CENTOS" self.os = "CENTOS" version_name = centos_match.group() - if version_name: + if version_name and version_name != 'UNKNOWN': # make it lower cause our versions dict keys are lower os_lookup_name = self.os.lower() os_versions = self.__class__.versions[os_lookup_name] @@ -90,11 +101,15 @@ def parse(self): ) if version_number: self.version = version_number - self.model = kernel_version else: - self.version= kernel_version + self.version = self.UNKNOWN + + self.model = kernel_version if kernel_version else self.UNKNOWN + elif version_name == 'UNKNOWN': + self.version = version_name + self.model = kernel_version if kernel_version else self.UNKNOWN else: self.version = kernel_version From 269ba3143ab765f1683f4fcd229c14156acdec14 Mon Sep 17 00:00:00 2001 From: yzdann <1543472-yzdann@users.noreply.gitlab.com> Date: Wed, 4 Dec 2019 11:11:37 +0330 Subject: [PATCH 07/43] change samples due to changing linux parse --- samples/sample_data.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/sample_data.json b/samples/sample_data.json index 85769d8..5d23671 100644 --- a/samples/sample_data.json +++ b/samples/sample_data.json @@ -659,8 +659,8 @@ "raw": "Linux hostname 3.2.0-56-generic-pae #86-Ubuntu SMP Wed Oct 23 17:51:27 UTC 2013 i686", "vendor": "CANONICAL", "os": "UBUNTU", - "model": "UNKNOWN", - "version": "3.2.0-56-generic-pae" + "model": "3.2.0-56-generic-pae", + "version": "UNKNOWN" }, { From 39b4dd70b4f8f72b7ec23ce3e68a8fa86c695012 Mon Sep 17 00:00:00 2001 From: yzdann <1543472-yzdann@users.noreply.gitlab.com> Date: Wed, 4 Dec 2019 11:18:49 +0330 Subject: [PATCH 08/43] add more sample for catch ubuntu version from hostname --- samples/sample_data.json | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/samples/sample_data.json b/samples/sample_data.json index 5d23671..06763cf 100644 --- a/samples/sample_data.json +++ b/samples/sample_data.json @@ -663,6 +663,30 @@ "version": "UNKNOWN" }, + { + "raw": "Linux ubuntu-bionic 4.15.0-70-generic #79-Ubuntu SMP Tue Nov 12 10:36:11 UTC 2019 x86_64", + "vendor": "CANONICAL", + "os": "UBUNTU", + "model": "4.15.0-70-generic", + "version": "18.04" + }, + + { + "raw": "Linux ubuntu-xenial 4.4.0-169-generic #198-Ubuntu SMP Tue Nov 12 10:38:00 UTC 2019 x86_64", + "vendor": "CANONICAL", + "os": "UBUNTU", + "model": "4.4.0-169-generic", + "version": "16.04" + }, + + { + "raw": "Linux vagrant-ubuntu-trusty-64 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64", + "vendor": "CANONICAL", + "os": "UBUNTU", + "model": "3.13.0-170-generic", + "version": "14.04" + }, + { "raw": "SunOS 5.10 sun4u sparc SUNW,Sun-Fire-V210, Class 4 Call Manager", "vendor": "SUN", From 2913cfc95f1253e45153d463fa9693bfb2ce66d9 Mon Sep 17 00:00:00 2001 From: yzdann <1543472-yzdann@users.noreply.gitlab.com> Date: Wed, 4 Dec 2019 11:26:06 +0330 Subject: [PATCH 09/43] add setup for 0.1.9 version --- setup.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index df7089f..633fff7 100644 --- a/setup.py +++ b/setup.py @@ -65,17 +65,17 @@ def run_tests(self): EXCLUDE_FROM_PACKAGES = ['tests'] setup( - name="sysdescrparser", - version="0.1.6", + name="snmpsysdescrparser", + version="0.1.9", description='SNMP sysDescr parser.', long_description=README, - author='Toshikatsu Murakoshi', - author_email='mtoshi.g@gmail.com', - url='https://github.com/mtoshi/sysdescrparser', + author='Yazdan', + author_email='yzdannn@gmail.com', + url='https://github.com/yzdann/sysdescrparser', license='MIT', classifiers=classifiers, packages=find_packages(exclude=EXCLUDE_FROM_PACKAGES), - py_modules=['sysdescrparser'], + py_modules=['snmpsysdescrparser'], data_files=[], install_requires=requires, include_package_data=True, From 438bfbb710ce273388436c34840a5d7ac30861b3 Mon Sep 17 00:00:00 2001 From: yzdann <1543472-yzdann@users.noreply.gitlab.com> Date: Sat, 7 Dec 2019 12:34:29 +0330 Subject: [PATCH 10/43] better name for parsing in our vms parser --- sysdescrparser/linux.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sysdescrparser/linux.py b/sysdescrparser/linux.py index 884adfa..c3c8d55 100644 --- a/sysdescrparser/linux.py +++ b/sysdescrparser/linux.py @@ -37,9 +37,9 @@ class Linux(SysDescr): def __init__(self, raw): """Constructor.""" super(Linux, self).__init__(raw) - self.vendor = self.UNKNOWN + self.vendor = 'LINUX' self.model = self.UNKNOWN - self.os = 'LINUX' + self.os = 'LINUX_KERNEL' self.version = self.UNKNOWN def parse(self): @@ -78,7 +78,7 @@ def parse(self): if ubuntu_lts_match or ubuntu_main_version_name_match: self.vendor = "CANONICAL" - self.os = "UBUNTU" + self.os = "UBUNTU_LINUX" if not ubuntu_lts_match: version_name = self.UNKNOWN From 9f5cb3e8fa17e328c6eb7d4d999ba41d34fd1714 Mon Sep 17 00:00:00 2001 From: yzdann <1543472-yzdann@users.noreply.gitlab.com> Date: Sat, 7 Dec 2019 12:49:56 +0330 Subject: [PATCH 11/43] add linux snmp utils --- sysdescrparser/utils/__init__.py | 1 + sysdescrparser/utils/utils.py | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 sysdescrparser/utils/__init__.py create mode 100644 sysdescrparser/utils/utils.py diff --git a/sysdescrparser/utils/__init__.py b/sysdescrparser/utils/__init__.py new file mode 100644 index 0000000..16281fe --- /dev/null +++ b/sysdescrparser/utils/__init__.py @@ -0,0 +1 @@ +from .utils import * diff --git a/sysdescrparser/utils/utils.py b/sysdescrparser/utils/utils.py new file mode 100644 index 0000000..6f24d37 --- /dev/null +++ b/sysdescrparser/utils/utils.py @@ -0,0 +1,10 @@ +def os_version_names_regex(os_dict): + os_version_names = os_dict.keys() + return "|".join(os_version_names) + + +def extract_version_number(os_dict, version_name): + version_name = version_name.lower() + version_number = os_dict[version_name] + version_number = str(version_number) + return version_number From 2977e1e901c5ec82467c14eefc41dda84933e18b Mon Sep 17 00:00:00 2001 From: yzdann <1543472-yzdann@users.noreply.gitlab.com> Date: Sat, 7 Dec 2019 13:00:44 +0330 Subject: [PATCH 12/43] update versions os-lookup since change ubuntu to ubuntu_linux --- sysdescrparser/linux.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sysdescrparser/linux.py b/sysdescrparser/linux.py index c3c8d55..831d823 100644 --- a/sysdescrparser/linux.py +++ b/sysdescrparser/linux.py @@ -18,7 +18,7 @@ class Linux(SysDescr): """ versions = { - "ubuntu": { + "ubuntu_linux": { "lucid": "10.04", "precise": "12.04", "trusty": "14.04", @@ -57,7 +57,7 @@ def parse(self): if len(res) > 2: kernel_version = res[2] - ubuntu_version_names_regex = os_version_names_regex(self.__class__.versions["ubuntu"]) + ubuntu_version_names_regex = os_version_names_regex(self.__class__.versions["ubuntu_linux"]) ubuntu_lts_match = re.search( ubuntu_version_names_regex, self.raw, From 8fac5750c21f155e8bf17249628fca3ec3dbbe07 Mon Sep 17 00:00:00 2001 From: yzdann <1543472-yzdann@users.noreply.gitlab.com> Date: Tue, 7 Jan 2020 18:22:26 +0330 Subject: [PATCH 13/43] add RouterOS for MikroTik to sysdescrparser --- sysdescrparser/mikrotik_routeros.py | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 sysdescrparser/mikrotik_routeros.py diff --git a/sysdescrparser/mikrotik_routeros.py b/sysdescrparser/mikrotik_routeros.py new file mode 100644 index 0000000..b86f682 --- /dev/null +++ b/sysdescrparser/mikrotik_routeros.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- + +"""sysdescrparser.mikrotik_routeros.""" + +from sysdescr import SysDescr +import re + + +# pylint: disable=no-member +class MikroTikRouterOS(SysDescr): + + """Class MikroTikRouterOS. + + SNMP sysDescr for MikroTikRouterOs. + + """ + + def __init__(self, raw): + """Constructor.""" + super(MikroTikRouterOS, self).__init__(raw) + self.vendor = 'MikroTik' + self.os = 'RouterOS' + self.model = self.UNKNOWN + self.version = self.UNKNOWN + + def parse(self): + """Parse.""" + regex = "RouterOS\s+([\d.]+)\s+\((\w+)\)\s+on\s+([\w\-\+]+)" + pat = re.compile(regex) + res = pat.search(self.raw) + if res: + self.version = res.group(1) + self.model = res.group(3) + return self + + return False From 7089ae6e3089e53b223b04a6b485c1d1ed27fc0e Mon Sep 17 00:00:00 2001 From: yzdann <1543472-yzdann@users.noreply.gitlab.com> Date: Tue, 7 Jan 2020 18:24:46 +0330 Subject: [PATCH 14/43] update version 0.1.14 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 633fff7..2fc717a 100644 --- a/setup.py +++ b/setup.py @@ -66,7 +66,7 @@ def run_tests(self): setup( name="snmpsysdescrparser", - version="0.1.9", + version="0.1.14", description='SNMP sysDescr parser.', long_description=README, author='Yazdan', From e2c8fba8d888685ca7c59bf84f2548516febe8a0 Mon Sep 17 00:00:00 2001 From: yzdann <1543472-yzdann@users.noreply.gitlab.com> Date: Tue, 7 Jan 2020 18:26:44 +0330 Subject: [PATCH 15/43] change os name in samples since we change them in parser --- samples/sample_data.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/samples/sample_data.json b/samples/sample_data.json index 06763cf..e1b21d6 100644 --- a/samples/sample_data.json +++ b/samples/sample_data.json @@ -633,8 +633,8 @@ { "raw": "Linux HOSTNAME 3.2.0-4-amd64 #1 SMP Debian 3.2.65-1+deb7u1", - "vendor": "UNKNOWN", - "os": "LINUX", + "vendor": "LINUX", + "os": "LINUX_KERNEL", "model": "UNKNOWN", "version": "3.2.0-4-amd64" }, @@ -649,8 +649,8 @@ { "raw": "Linux HOSTNAME 2.6.21-1.3194.fc7 #1 SMP Wed May 23 22:35:01 EDT 2007 i686", - "vendor": "UNKNOWN", - "os": "LINUX", + "vendor": "LINUX", + "os": "LINUX_KERNEL", "model": "UNKNOWN", "version": "2.6.21-1.3194.fc7" }, @@ -658,7 +658,7 @@ { "raw": "Linux hostname 3.2.0-56-generic-pae #86-Ubuntu SMP Wed Oct 23 17:51:27 UTC 2013 i686", "vendor": "CANONICAL", - "os": "UBUNTU", + "os": "UBUNTU_LINUX", "model": "3.2.0-56-generic-pae", "version": "UNKNOWN" }, @@ -666,7 +666,7 @@ { "raw": "Linux ubuntu-bionic 4.15.0-70-generic #79-Ubuntu SMP Tue Nov 12 10:36:11 UTC 2019 x86_64", "vendor": "CANONICAL", - "os": "UBUNTU", + "os": "UBUNTU_LINUX", "model": "4.15.0-70-generic", "version": "18.04" }, @@ -674,7 +674,7 @@ { "raw": "Linux ubuntu-xenial 4.4.0-169-generic #198-Ubuntu SMP Tue Nov 12 10:38:00 UTC 2019 x86_64", "vendor": "CANONICAL", - "os": "UBUNTU", + "os": "UBUNTU_LINUX", "model": "4.4.0-169-generic", "version": "16.04" }, @@ -682,7 +682,7 @@ { "raw": "Linux vagrant-ubuntu-trusty-64 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64", "vendor": "CANONICAL", - "os": "UBUNTU", + "os": "UBUNTU_LINUX", "model": "3.13.0-170-generic", "version": "14.04" }, From d601f675720f59cccc6d3fafff4b814ba7a50d11 Mon Sep 17 00:00:00 2001 From: yzdann <1543472-yzdann@users.noreply.gitlab.com> Date: Wed, 8 Jan 2020 12:23:13 +0330 Subject: [PATCH 16/43] add mikrotik routeros to main parser --- sysdescrparser/sysdescrparser.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sysdescrparser/sysdescrparser.py b/sysdescrparser/sysdescrparser.py index 1b5872d..df95e57 100644 --- a/sysdescrparser/sysdescrparser.py +++ b/sysdescrparser/sysdescrparser.py @@ -12,6 +12,7 @@ from cisco_nxos import CiscoNXOS from cisco_iosxe import CiscoIOSXE from cisco_iosxr import CiscoIOSXR +from mikrotik_routeros import MikroTikRouterOS from juniper_junos import JuniperJunos from juniper_screenos import JuniperScreenOS from brocade_ironware import BrocadeIronWare @@ -100,6 +101,11 @@ def sysdescrparser(sysdescr): if obj.parse(): return obj # + # mikrotik routeros + obj = MikroTikRouterOs(sysdescr) + if obj.parse(): + return obj + # # juniper junos # obj = JuniperJunos(sysdescr) From af8a8985a59f6a5db73bfab7daeefe025857b8a4 Mon Sep 17 00:00:00 2001 From: yzdann <1543472-yzdann@users.noreply.gitlab.com> Date: Wed, 8 Jan 2020 12:37:04 +0330 Subject: [PATCH 17/43] add r to start of regex string --- sysdescrparser/mikrotik_routeros.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysdescrparser/mikrotik_routeros.py b/sysdescrparser/mikrotik_routeros.py index b86f682..04f0a58 100644 --- a/sysdescrparser/mikrotik_routeros.py +++ b/sysdescrparser/mikrotik_routeros.py @@ -25,7 +25,7 @@ def __init__(self, raw): def parse(self): """Parse.""" - regex = "RouterOS\s+([\d.]+)\s+\((\w+)\)\s+on\s+([\w\-\+]+)" + regex = r"RouterOS\s+([\d.]+)\s+\((\w+)\)\s+on\s+([\w\-\+]+)" pat = re.compile(regex) res = pat.search(self.raw) if res: From c6bde1089de9e71d8212150576f9bbd993aeff3c Mon Sep 17 00:00:00 2001 From: yzdann <1543472-yzdann@users.noreply.gitlab.com> Date: Wed, 8 Jan 2020 12:38:03 +0330 Subject: [PATCH 18/43] 0.1.16 release --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 2fc717a..75ddcb9 100644 --- a/setup.py +++ b/setup.py @@ -66,7 +66,7 @@ def run_tests(self): setup( name="snmpsysdescrparser", - version="0.1.14", + version="0.1.16", description='SNMP sysDescr parser.', long_description=README, author='Yazdan', From a3246b5d8a542c42043db7436d9297b35e537ef3 Mon Sep 17 00:00:00 2001 From: yzdann <1543472-yzdann@users.noreply.gitlab.com> Date: Wed, 8 Jan 2020 12:45:43 +0330 Subject: [PATCH 19/43] :poop: 0.1.17 from now i will run some test :) --- setup.py | 2 +- sysdescrparser/sysdescrparser.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 75ddcb9..720ac04 100644 --- a/setup.py +++ b/setup.py @@ -66,7 +66,7 @@ def run_tests(self): setup( name="snmpsysdescrparser", - version="0.1.16", + version="0.1.17", description='SNMP sysDescr parser.', long_description=README, author='Yazdan', diff --git a/sysdescrparser/sysdescrparser.py b/sysdescrparser/sysdescrparser.py index df95e57..f44a497 100644 --- a/sysdescrparser/sysdescrparser.py +++ b/sysdescrparser/sysdescrparser.py @@ -102,7 +102,7 @@ def sysdescrparser(sysdescr): return obj # # mikrotik routeros - obj = MikroTikRouterOs(sysdescr) + obj = MikroTikRouterOS(sysdescr) if obj.parse(): return obj # From 2dcf44e5b3fa78d6d9d2e6d3b71d94d2fd10045f Mon Sep 17 00:00:00 2001 From: yzdann <1543472-yzdann@users.noreply.gitlab.com> Date: Wed, 8 Jan 2020 12:55:30 +0330 Subject: [PATCH 20/43] add some test for MikroTik RouterOS --- samples/sample_data.json | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/samples/sample_data.json b/samples/sample_data.json index e1b21d6..df7fbe1 100644 --- a/samples/sample_data.json +++ b/samples/sample_data.json @@ -135,6 +135,22 @@ "version": "3.6.0[00]" }, + { + "raw": "RouterOS 6.43.4 (stable) on RB750", + "vendor": "MikroTik", + "os": "RouterOS", + "model": "RB750", + "version": "6.43.4" + }, + + { + "raw": "RouterOS 6.43.4 (stable) on RB951-2n", + "vendor": "MikroTik", + "os": "RouterOS", + "model": "RB951-2n", + "version": "6.43.4" + }, + { "raw": "Juniper Networks, Inc. ex2200-24t-4g internet router, kernel JUNOS 10.2R1.8 #0: 2010-05-27 20:13:49 UTC", "vendor": "JUNIPER", From 1a49dc5b3c9d6095946c50856f8490d842ebe194 Mon Sep 17 00:00:00 2001 From: yzdann <1543472-yzdann@users.noreply.gitlab.com> Date: Wed, 8 Jan 2020 13:16:34 +0330 Subject: [PATCH 21/43] add one more test for MikroTik RouterOS --- samples/sample_data.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/samples/sample_data.json b/samples/sample_data.json index df7fbe1..e3d5e6e 100644 --- a/samples/sample_data.json +++ b/samples/sample_data.json @@ -151,6 +151,14 @@ "version": "6.43.4" }, + { + "raw": "RouterOS 6.47 (stable) on CCR1036-12G-4S", + "vendor": "MikroTik", + "os": "RouterOS", + "model": "CCR1036-12G-4S", + "version": "6.47" + }, + { "raw": "Juniper Networks, Inc. ex2200-24t-4g internet router, kernel JUNOS 10.2R1.8 #0: 2010-05-27 20:13:49 UTC", "vendor": "JUNIPER", From 5fa6a5032bf709322294ff960b3cc379f5d5e8b3 Mon Sep 17 00:00:00 2001 From: yzdann <1543472-yzdann@users.noreply.gitlab.com> Date: Mon, 27 Jan 2020 16:32:42 +0330 Subject: [PATCH 22/43] :bug: mikrotik routeros parser ignore dash in version e.g. (long-term) --- sysdescrparser/mikrotik_routeros.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysdescrparser/mikrotik_routeros.py b/sysdescrparser/mikrotik_routeros.py index 04f0a58..6b7f251 100644 --- a/sysdescrparser/mikrotik_routeros.py +++ b/sysdescrparser/mikrotik_routeros.py @@ -25,7 +25,7 @@ def __init__(self, raw): def parse(self): """Parse.""" - regex = r"RouterOS\s+([\d.]+)\s+\((\w+)\)\s+on\s+([\w\-\+]+)" + regex = r"RouterOS\s+([\d.]+)\s+\(([\w|-]+)\)\s+on\s+([\w\-\+]+)" pat = re.compile(regex) res = pat.search(self.raw) if res: From 90a8487ba560cdf5972c48ace30836f7baf90359 Mon Sep 17 00:00:00 2001 From: yzdann <1543472-yzdann@users.noreply.gitlab.com> Date: Mon, 27 Jan 2020 16:34:26 +0330 Subject: [PATCH 23/43] add RouterOS test for long-term version --- samples/sample_data.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/samples/sample_data.json b/samples/sample_data.json index e3d5e6e..d958e9c 100644 --- a/samples/sample_data.json +++ b/samples/sample_data.json @@ -159,6 +159,14 @@ "version": "6.47" }, + { + "raw": "RouterOS 6.44.5 (long-term) on CCR1036-12G-4S", + "vendor": "MikroTik", + "os": "RouterOS", + "model": "CCR1036-12G-4S", + "version": "6.44.5" + }, + { "raw": "Juniper Networks, Inc. ex2200-24t-4g internet router, kernel JUNOS 10.2R1.8 #0: 2010-05-27 20:13:49 UTC", "vendor": "JUNIPER", From 4537b95183501d299f2d5e976f6043bf30083dbe Mon Sep 17 00:00:00 2001 From: yzdann <1543472-yzdann@users.noreply.gitlab.com> Date: Mon, 27 Jan 2020 16:39:55 +0330 Subject: [PATCH 24/43] update version in setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 720ac04..7bb0f4d 100644 --- a/setup.py +++ b/setup.py @@ -66,7 +66,7 @@ def run_tests(self): setup( name="snmpsysdescrparser", - version="0.1.17", + version="0.1.18", description='SNMP sysDescr parser.', long_description=README, author='Yazdan', From b385f98791031f425faf0b9cca3fd6ea6e6c5236 Mon Sep 17 00:00:00 2001 From: amirmohammadshakeri <44241934+mramirsha@users.noreply.github.com> Date: Wed, 29 Apr 2020 18:38:08 +0430 Subject: [PATCH 25/43] create pythonpackage.yml --- .github/workflows/pythonpackage.yml | 39 +++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/pythonpackage.yml diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml new file mode 100644 index 0000000..b425371 --- /dev/null +++ b/.github/workflows/pythonpackage.yml @@ -0,0 +1,39 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Python package + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.5, 3.6, 3.7, 3.8] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest From 6c3d9ac8a67d8bc66903b08902c6ebda4a522faa Mon Sep 17 00:00:00 2001 From: mramirsha Date: Sun, 10 May 2020 10:25:37 +0430 Subject: [PATCH 26/43] add cisco asa parser --- sysdescrparser/cisco_asa.py | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 sysdescrparser/cisco_asa.py diff --git a/sysdescrparser/cisco_asa.py b/sysdescrparser/cisco_asa.py new file mode 100644 index 0000000..50d4b3f --- /dev/null +++ b/sysdescrparser/cisco_asa.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- + +"""sysdescrparser.cisco_iosxe.""" + +import re +from cisco import Cisco + + +# pylint: disable=no-member +class CiscoASA(Cisco): + """Class CiscoASA. + + SNMP sysDescr for CiscoASA. + + """ + + def __init__(self, raw): + """Constructor.""" + super(CiscoASA, self).__init__(raw) + self.os = 'ASA' + self.model = self.UNKNOWN + self.version = self.UNKNOWN + + def parse(self): + """Parse.""" + # Cisco Adaptive Security Appliance Version 8.4(7)31 + regex = (r'Cisco Adaptive Security Appliance ' + r'Version (\d.*)') + pat = re.compile(regex) + res = pat.search(self.raw) + if res: + self.version = res.group(1) + return self + + return False + + + From a9913dfe1367bbcd264fed231414cab00611dd0f Mon Sep 17 00:00:00 2001 From: mramirsha Date: Sun, 10 May 2020 10:40:05 +0430 Subject: [PATCH 27/43] add cisco asa parser --- sysdescrparser/sysdescrparser.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sysdescrparser/sysdescrparser.py b/sysdescrparser/sysdescrparser.py index f44a497..8cf0003 100644 --- a/sysdescrparser/sysdescrparser.py +++ b/sysdescrparser/sysdescrparser.py @@ -8,6 +8,7 @@ sys.path.append(os.path.dirname(__file__)) # pylint: disable=C0413 +from cisco_asa import CiscoASA from cisco_ios import CiscoIOS from cisco_nxos import CiscoNXOS from cisco_iosxe import CiscoIOSXE @@ -77,6 +78,12 @@ def sysdescrparser(sysdescr): """ # + # cisco asa + # + obj = CiscoASA(sysdescr) + if obj.parse(): + return obj + # # cisco nxos # obj = CiscoNXOS(sysdescr) From b2278dad92407915e72a3d5ebb4b7b0c144c20c4 Mon Sep 17 00:00:00 2001 From: mramirsha Date: Sun, 10 May 2020 13:44:02 +0430 Subject: [PATCH 28/43] some change --- sysdescrparser/cisco_asa.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sysdescrparser/cisco_asa.py b/sysdescrparser/cisco_asa.py index 50d4b3f..ff6c17a 100644 --- a/sysdescrparser/cisco_asa.py +++ b/sysdescrparser/cisco_asa.py @@ -23,7 +23,6 @@ def __init__(self, raw): def parse(self): """Parse.""" - # Cisco Adaptive Security Appliance Version 8.4(7)31 regex = (r'Cisco Adaptive Security Appliance ' r'Version (\d.*)') pat = re.compile(regex) From c28d1575d94e13bae1af98e569cb191debda237d Mon Sep 17 00:00:00 2001 From: mramirsha Date: Sun, 10 May 2020 14:18:50 +0430 Subject: [PATCH 29/43] add cisco asa parser --- sysdescrparser/cisco_asa.py | 37 ++++++++++++++++++++++++++++++++ sysdescrparser/sysdescrparser.py | 7 ++++++ 2 files changed, 44 insertions(+) create mode 100644 sysdescrparser/cisco_asa.py diff --git a/sysdescrparser/cisco_asa.py b/sysdescrparser/cisco_asa.py new file mode 100644 index 0000000..ff6c17a --- /dev/null +++ b/sysdescrparser/cisco_asa.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- + +"""sysdescrparser.cisco_iosxe.""" + +import re +from cisco import Cisco + + +# pylint: disable=no-member +class CiscoASA(Cisco): + """Class CiscoASA. + + SNMP sysDescr for CiscoASA. + + """ + + def __init__(self, raw): + """Constructor.""" + super(CiscoASA, self).__init__(raw) + self.os = 'ASA' + self.model = self.UNKNOWN + self.version = self.UNKNOWN + + def parse(self): + """Parse.""" + regex = (r'Cisco Adaptive Security Appliance ' + r'Version (\d.*)') + pat = re.compile(regex) + res = pat.search(self.raw) + if res: + self.version = res.group(1) + return self + + return False + + + diff --git a/sysdescrparser/sysdescrparser.py b/sysdescrparser/sysdescrparser.py index f44a497..8cf0003 100644 --- a/sysdescrparser/sysdescrparser.py +++ b/sysdescrparser/sysdescrparser.py @@ -8,6 +8,7 @@ sys.path.append(os.path.dirname(__file__)) # pylint: disable=C0413 +from cisco_asa import CiscoASA from cisco_ios import CiscoIOS from cisco_nxos import CiscoNXOS from cisco_iosxe import CiscoIOSXE @@ -77,6 +78,12 @@ def sysdescrparser(sysdescr): """ # + # cisco asa + # + obj = CiscoASA(sysdescr) + if obj.parse(): + return obj + # # cisco nxos # obj = CiscoNXOS(sysdescr) From a10a1ad70b6407a6eeca449278273695d83a7062 Mon Sep 17 00:00:00 2001 From: mramirsha Date: Sun, 10 May 2020 14:24:57 +0430 Subject: [PATCH 30/43] delete github workflow --- .github/workflows/pythonpackage.yml | 39 ----------------------------- 1 file changed, 39 deletions(-) delete mode 100644 .github/workflows/pythonpackage.yml diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml deleted file mode 100644 index b425371..0000000 --- a/.github/workflows/pythonpackage.yml +++ /dev/null @@ -1,39 +0,0 @@ -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - -name: Python package - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - - runs-on: ubuntu-latest - strategy: - matrix: - python-version: [3.5, 3.6, 3.7, 3.8] - - steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest - run: | - pytest From 19eeb9feb2a4fd93473482739e3ecd71d36fde8e Mon Sep 17 00:00:00 2001 From: mramirsha Date: Sun, 10 May 2020 14:49:31 +0430 Subject: [PATCH 31/43] change os name --- sysdescrparser/cisco_asa.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysdescrparser/cisco_asa.py b/sysdescrparser/cisco_asa.py index ff6c17a..cd5ebf4 100644 --- a/sysdescrparser/cisco_asa.py +++ b/sysdescrparser/cisco_asa.py @@ -17,7 +17,7 @@ class CiscoASA(Cisco): def __init__(self, raw): """Constructor.""" super(CiscoASA, self).__init__(raw) - self.os = 'ASA' + self.os = 'Adaptive_Security_Appliance' self.model = self.UNKNOWN self.version = self.UNKNOWN From 45fa4147a7b3e17d74c3093131aab4822766d895 Mon Sep 17 00:00:00 2001 From: Ali Nazari Date: Sat, 30 Jan 2021 14:29:38 +0330 Subject: [PATCH 32/43] added fortinet file and FortiNet class --- sysdescrparser/fortinet.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 sysdescrparser/fortinet.py diff --git a/sysdescrparser/fortinet.py b/sysdescrparser/fortinet.py new file mode 100644 index 0000000..728e6de --- /dev/null +++ b/sysdescrparser/fortinet.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- + +"""sysdescrparser.FortiNet.""" + +from sysdescr import SysDescr + + +# pylint: disable=no-name-in-module +class FortiNet(SysDescr): + + """Class FortiNet. + + This class is only for vendor definition. + + """ + + def __init__(self, raw): + """Constructor.""" + super(FortiNet, self).__init__(raw) + self.vendor = 'fortinet' + self.model = self.UNKNOWN + self.os = self.UNKNOWN + self.version = self.UNKNOWN + + def parse(self): + """Parsing for sysDescr value.""" + return self From a92a67dc76eb8250bf373030a15537e58444b654 Mon Sep 17 00:00:00 2001 From: Ali Nazari Date: Sat, 30 Jan 2021 15:13:32 +0330 Subject: [PATCH 33/43] added fortinet_fortios file and FortiOs class --- sysdescrparser/fortinet_fortios.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 sysdescrparser/fortinet_fortios.py diff --git a/sysdescrparser/fortinet_fortios.py b/sysdescrparser/fortinet_fortios.py new file mode 100644 index 0000000..d34fca1 --- /dev/null +++ b/sysdescrparser/fortinet_fortios.py @@ -0,0 +1,29 @@ +import re +from fortinet import FortiNet + + +class FortiOs(FortiNet): + """Class FortiOs. + + SNMP sysDescr for fortigate. + + """ + + def __init__(self, raw): + """Constructor.""" + super(FortiOs, self).__init__(raw) + self.os = 'fortios' + self.model = self.UNKNOWN + self.version = self.UNKNOWN + + def parse(self): + """Parse.""" + regex = r'Fortinet Firewall (.*) v((\d\.)*\d)' + pat = re.compile(regex) + res = pat.search(self.raw) + if res: + self.model = res.group(1) + self.version = res.group(2) + return self + + return False From e5eebda2c2762373776011b88e0685df0fb08f89 Mon Sep 17 00:00:00 2001 From: Ali Nazari Date: Sat, 30 Jan 2021 15:15:44 +0330 Subject: [PATCH 34/43] add FortiOs --- sysdescrparser/sysdescrparser.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sysdescrparser/sysdescrparser.py b/sysdescrparser/sysdescrparser.py index 8cf0003..dc1588a 100644 --- a/sysdescrparser/sysdescrparser.py +++ b/sysdescrparser/sysdescrparser.py @@ -31,6 +31,7 @@ from freebsd import FreeBSD from iij_seil import IIJSeil from yamaha_rtx import YamahaRTX +from fortinet_fortios import FortiOs from unknown import Unknown @@ -215,6 +216,12 @@ def sysdescrparser(sysdescr): if obj.parse(): return obj # + # fortigate + # + obj = FortiOs(sysdescr) + if obj.parse(): + return obj + # # Unknown # obj = Unknown(sysdescr) From 1ce5aabb8fab928df9c0ac647cf56025062c286f Mon Sep 17 00:00:00 2001 From: yzdann <22779039+yzdann@users.noreply.github.com> Date: Tue, 2 Feb 2021 21:14:23 +0330 Subject: [PATCH 35/43] Bump version 0.1.19 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 7bb0f4d..bd64469 100644 --- a/setup.py +++ b/setup.py @@ -66,7 +66,7 @@ def run_tests(self): setup( name="snmpsysdescrparser", - version="0.1.18", + version="0.1.19", description='SNMP sysDescr parser.', long_description=README, author='Yazdan', From c57d595707fec902f7a5bbf2a52089f6448610c4 Mon Sep 17 00:00:00 2001 From: yzdann <22779039+yzdann@users.noreply.github.com> Date: Tue, 2 Feb 2021 21:31:48 +0330 Subject: [PATCH 36/43] Bump version to 0.1.20 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index bd64469..a6a2474 100644 --- a/setup.py +++ b/setup.py @@ -66,7 +66,7 @@ def run_tests(self): setup( name="snmpsysdescrparser", - version="0.1.19", + version="0.1.20", description='SNMP sysDescr parser.', long_description=README, author='Yazdan', From 806ece536e02170d5f26096ea0994c4562369860 Mon Sep 17 00:00:00 2001 From: Carlos M Date: Fri, 19 Feb 2021 16:46:04 +0100 Subject: [PATCH 37/43] Added new vendor Aruba Added new class Aruba to sysdescrparser folder and its inizialization in sysdescrparser.py --- sysdescrparser/aruba.py | 38 ++++++++++++++++++++++++++++++++ sysdescrparser/sysdescrparser.py | 8 +++++++ 2 files changed, 46 insertions(+) create mode 100644 sysdescrparser/aruba.py diff --git a/sysdescrparser/aruba.py b/sysdescrparser/aruba.py new file mode 100644 index 0000000..0d944d4 --- /dev/null +++ b/sysdescrparser/aruba.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- + +"""sysdescrparser.aruba.""" + +import re +from sysdescr import SysDescr + + +# pylint: disable=no-name-in-module +# pylint: disable=no-member +class Aruba(SysDescr): + + """Class Aruba. + + This class is only for vendor definition. + + """ + + def __init__(self, raw): + """Constructor.""" + super(Aruba, self).__init__(raw) + self.vendor = 'ARUBA' + self.model = self.UNKNOWN + self.os = 'ArubaOS' + self.version = self.UNKNOWN + + def parse(self): + """Parsing for sysDescr value.""" + regex = (r'ArubaOS' + r'.* \(MODEL: (?:Aruba)?(.*)\), Version (.*)') + pat = re.compile(regex) + res = pat.search(self.raw) + if res: + self.model = res.group(1) + self.version = res.group(2) + return self + + return False diff --git a/sysdescrparser/sysdescrparser.py b/sysdescrparser/sysdescrparser.py index dc1588a..ccef6cc 100644 --- a/sysdescrparser/sysdescrparser.py +++ b/sysdescrparser/sysdescrparser.py @@ -8,6 +8,7 @@ sys.path.append(os.path.dirname(__file__)) # pylint: disable=C0413 +from aruba import Aruba from cisco_asa import CiscoASA from cisco_ios import CiscoIOS from cisco_nxos import CiscoNXOS @@ -77,8 +78,15 @@ def sysdescrparser(sysdescr): https://github.com/mtoshi/sysdescrparser/blob/master/README.rst + """ # + # aruba + # + obj = Aruba(sysdescr) + if obj.parse(): + return obj + # # cisco asa # obj = CiscoASA(sysdescr) From 78dc5e778fe3a8c1a6278d36d85a4dcdc1295abd Mon Sep 17 00:00:00 2001 From: Carlos M Date: Mon, 22 Feb 2021 09:31:57 +0100 Subject: [PATCH 38/43] Added samples Added some samples to sample_data.json --- samples/sample_data.json | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/samples/sample_data.json b/samples/sample_data.json index d958e9c..24e9325 100644 --- a/samples/sample_data.json +++ b/samples/sample_data.json @@ -887,6 +887,30 @@ "version": "Rev.8.03.92" }, + { + "raw": "ArubaOS (MODEL: 515), Version 8.6.0.4-8.6.0.4", + "vendor": "ARUBA", + "os": "ArubaOS", + "model": "515", + "version": "8.6.0.4-8.6.0.4" + }, + + { + "raw": "ArubaOS (MODEL: Aruba7010), Version 8.3.0.0 (64659)", + "vendor": "ARUBA", + "os": "ArubaOS", + "model": "7010", + "version": "8.3.0.0 (64659)" + }, + + { + "raw": "ArubaOS (MODEL: Aruba7210), Version 6.5.1.6 (60228)", + "vendor": "ARUBA", + "os": "ArubaOS", + "model": "7210", + "version": "6.5.1.6 (60228)" + }, + { "raw": "xxxxxxxxxxxxxxx", "vendor": "UNKNOWN", From 80a385d5becf6e2b231bf936b5c4a1198d82c04f Mon Sep 17 00:00:00 2001 From: yzdann <22779039+yzdann@users.noreply.github.com> Date: Mon, 22 Feb 2021 21:20:58 +0330 Subject: [PATCH 39/43] Bump version to 0.1.21 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a6a2474..1f1ac30 100644 --- a/setup.py +++ b/setup.py @@ -66,7 +66,7 @@ def run_tests(self): setup( name="snmpsysdescrparser", - version="0.1.20", + version="0.1.21", description='SNMP sysDescr parser.', long_description=README, author='Yazdan', From b447223afc9f07ba03a616d4045f937f450db3b8 Mon Sep 17 00:00:00 2001 From: Ricky Laney Date: Fri, 18 Mar 2022 07:45:00 -0400 Subject: [PATCH 40/43] Force the use of full module paths and simplify utils --- samples/sample.py | 2 +- sysdescrparser/__init__.py | 8 +-- sysdescrparser/a10.py | 2 +- sysdescrparser/a10_acos.py | 2 +- sysdescrparser/arista.py | 2 +- sysdescrparser/arista_eos.py | 2 +- sysdescrparser/aruba.py | 2 +- sysdescrparser/brocade.py | 2 +- sysdescrparser/brocade_ironware.py | 2 +- sysdescrparser/brocade_networkos.py | 2 +- sysdescrparser/brocade_serveriron.py | 2 +- sysdescrparser/cisco.py | 2 +- sysdescrparser/cisco_asa.py | 2 +- sysdescrparser/cisco_ios.py | 2 +- sysdescrparser/cisco_iosxe.py | 2 +- sysdescrparser/cisco_iosxr.py | 2 +- sysdescrparser/cisco_nxos.py | 2 +- sysdescrparser/citrix.py | 2 +- sysdescrparser/citrix_netscaler.py | 2 +- sysdescrparser/extreme.py | 2 +- sysdescrparser/extreme_xos.py | 2 +- sysdescrparser/fortinet.py | 2 +- sysdescrparser/fortinet_fortios.py | 2 +- sysdescrparser/foundry.py | 2 +- sysdescrparser/foundry_ironware.py | 2 +- sysdescrparser/freebsd.py | 2 +- sysdescrparser/hp.py | 2 +- sysdescrparser/hp_procurve.py | 2 +- sysdescrparser/iij.py | 2 +- sysdescrparser/iij_seil.py | 2 +- sysdescrparser/juniper.py | 2 +- sysdescrparser/juniper_junos.py | 2 +- sysdescrparser/juniper_screenos.py | 2 +- sysdescrparser/linux.py | 4 +- sysdescrparser/mikrotik_routeros.py | 2 +- sysdescrparser/paloalto.py | 2 +- sysdescrparser/paloalto_panos.py | 2 +- sysdescrparser/sun.py | 2 +- sysdescrparser/sun_sunos.py | 2 +- sysdescrparser/sysdescrparser.py | 62 ++++++++++----------- sysdescrparser/tests/test_sysdescrparser.py | 4 +- sysdescrparser/unknown.py | 2 +- sysdescrparser/utils/__init__.py | 12 +++- sysdescrparser/utils/utils.py | 10 ---- sysdescrparser/yamaha.py | 2 +- sysdescrparser/yamaha_rtx.py | 2 +- 46 files changed, 87 insertions(+), 93 deletions(-) delete mode 100644 sysdescrparser/utils/utils.py diff --git a/samples/sample.py b/samples/sample.py index e4087fd..515c116 100644 --- a/samples/sample.py +++ b/samples/sample.py @@ -4,7 +4,7 @@ import os import json -from sysdescrparser import sysdescrparser +from sysdescrparser.sysdescrparser import sysdescrparser def main(): diff --git a/sysdescrparser/__init__.py b/sysdescrparser/__init__.py index 27067a4..9544d8b 100644 --- a/sysdescrparser/__init__.py +++ b/sysdescrparser/__init__.py @@ -2,10 +2,4 @@ """Sysdescrparser.""" -import sys - -# pylint: disable=unused-import -if sys.version_info.major == 2: - from sysdescrparser import sysdescrparser -else: - from sysdescrparser.sysdescrparser import sysdescrparser +# Removed lifting to force full path use diff --git a/sysdescrparser/a10.py b/sysdescrparser/a10.py index 3a2805e..66a8905 100644 --- a/sysdescrparser/a10.py +++ b/sysdescrparser/a10.py @@ -2,7 +2,7 @@ """sysdescrparser.a10.""" -from sysdescr import SysDescr +from sysdescrparser.sysdescr import SysDescr # pylint: disable=no-name-in-module diff --git a/sysdescrparser/a10_acos.py b/sysdescrparser/a10_acos.py index 22c3f00..59850ef 100644 --- a/sysdescrparser/a10_acos.py +++ b/sysdescrparser/a10_acos.py @@ -4,7 +4,7 @@ import re -from a10 import A10 +from sysdescrparser.a10 import A10 # pylint: disable=no-member diff --git a/sysdescrparser/arista.py b/sysdescrparser/arista.py index 74a9998..ebd7532 100644 --- a/sysdescrparser/arista.py +++ b/sysdescrparser/arista.py @@ -2,7 +2,7 @@ """sysdescrparser.arista.""" -from sysdescr import SysDescr +from sysdescrparser.sysdescr import SysDescr # pylint: disable=no-name-in-module diff --git a/sysdescrparser/arista_eos.py b/sysdescrparser/arista_eos.py index ba726b6..58434c0 100644 --- a/sysdescrparser/arista_eos.py +++ b/sysdescrparser/arista_eos.py @@ -4,7 +4,7 @@ import re -from arista import Arista +from sysdescrparser.arista import Arista # pylint: disable=no-member diff --git a/sysdescrparser/aruba.py b/sysdescrparser/aruba.py index 0d944d4..a279df9 100644 --- a/sysdescrparser/aruba.py +++ b/sysdescrparser/aruba.py @@ -3,7 +3,7 @@ """sysdescrparser.aruba.""" import re -from sysdescr import SysDescr +from sysdescrparser.sysdescr import SysDescr # pylint: disable=no-name-in-module diff --git a/sysdescrparser/brocade.py b/sysdescrparser/brocade.py index dd536b8..65bc637 100644 --- a/sysdescrparser/brocade.py +++ b/sysdescrparser/brocade.py @@ -2,7 +2,7 @@ """sysdescrparser.brocade.""" -from sysdescr import SysDescr +from sysdescrparser.sysdescr import SysDescr # pylint: disable=no-name-in-module diff --git a/sysdescrparser/brocade_ironware.py b/sysdescrparser/brocade_ironware.py index d13f637..814a852 100644 --- a/sysdescrparser/brocade_ironware.py +++ b/sysdescrparser/brocade_ironware.py @@ -4,7 +4,7 @@ import re -from brocade import Brocade +from sysdescrparser.brocade import Brocade # pylint: disable=no-member diff --git a/sysdescrparser/brocade_networkos.py b/sysdescrparser/brocade_networkos.py index 5a6a7f2..e9b1f55 100644 --- a/sysdescrparser/brocade_networkos.py +++ b/sysdescrparser/brocade_networkos.py @@ -4,7 +4,7 @@ import re -from brocade import Brocade +from sysdescrparser.brocade import Brocade # pylint: disable=no-member diff --git a/sysdescrparser/brocade_serveriron.py b/sysdescrparser/brocade_serveriron.py index 1960aea..4a949a5 100644 --- a/sysdescrparser/brocade_serveriron.py +++ b/sysdescrparser/brocade_serveriron.py @@ -4,7 +4,7 @@ import re -from brocade import Brocade +from sysdescrparser.brocade import Brocade # pylint: disable=no-member diff --git a/sysdescrparser/cisco.py b/sysdescrparser/cisco.py index e40ed3c..3d5d836 100644 --- a/sysdescrparser/cisco.py +++ b/sysdescrparser/cisco.py @@ -2,7 +2,7 @@ """sysdescrparser.cisco.""" -from sysdescr import SysDescr +from sysdescrparser.sysdescr import SysDescr # pylint: disable=no-name-in-module diff --git a/sysdescrparser/cisco_asa.py b/sysdescrparser/cisco_asa.py index cd5ebf4..1fa09d3 100644 --- a/sysdescrparser/cisco_asa.py +++ b/sysdescrparser/cisco_asa.py @@ -3,7 +3,7 @@ """sysdescrparser.cisco_iosxe.""" import re -from cisco import Cisco +from sysdescrparser.cisco import Cisco # pylint: disable=no-member diff --git a/sysdescrparser/cisco_ios.py b/sysdescrparser/cisco_ios.py index a6172a2..559cb05 100644 --- a/sysdescrparser/cisco_ios.py +++ b/sysdescrparser/cisco_ios.py @@ -4,7 +4,7 @@ import re -from cisco import Cisco +from sysdescrparser.cisco import Cisco # pylint: disable=no-member diff --git a/sysdescrparser/cisco_iosxe.py b/sysdescrparser/cisco_iosxe.py index deec10f..ac680b6 100644 --- a/sysdescrparser/cisco_iosxe.py +++ b/sysdescrparser/cisco_iosxe.py @@ -4,7 +4,7 @@ import re -from cisco import Cisco +from sysdescrparser.cisco import Cisco # pylint: disable=no-member diff --git a/sysdescrparser/cisco_iosxr.py b/sysdescrparser/cisco_iosxr.py index e28c0f6..0387de5 100644 --- a/sysdescrparser/cisco_iosxr.py +++ b/sysdescrparser/cisco_iosxr.py @@ -4,7 +4,7 @@ import re -from cisco import Cisco +from sysdescrparser.cisco import Cisco # pylint: disable=no-member diff --git a/sysdescrparser/cisco_nxos.py b/sysdescrparser/cisco_nxos.py index 64181c7..fb7f397 100644 --- a/sysdescrparser/cisco_nxos.py +++ b/sysdescrparser/cisco_nxos.py @@ -4,7 +4,7 @@ import re -from cisco import Cisco +from sysdescrparser.cisco import Cisco # pylint: disable=no-member diff --git a/sysdescrparser/citrix.py b/sysdescrparser/citrix.py index 8abe3e1..8dcc04a 100644 --- a/sysdescrparser/citrix.py +++ b/sysdescrparser/citrix.py @@ -2,7 +2,7 @@ """sysdescrparser.citrix.""" -from sysdescr import SysDescr +from sysdescrparser.sysdescr import SysDescr # pylint: disable=no-name-in-module diff --git a/sysdescrparser/citrix_netscaler.py b/sysdescrparser/citrix_netscaler.py index 5548e80..f302145 100644 --- a/sysdescrparser/citrix_netscaler.py +++ b/sysdescrparser/citrix_netscaler.py @@ -4,7 +4,7 @@ import re -from citrix import Citrix +from sysdescrparser.citrix import Citrix # pylint: disable=no-member diff --git a/sysdescrparser/extreme.py b/sysdescrparser/extreme.py index efec554..d280bf1 100644 --- a/sysdescrparser/extreme.py +++ b/sysdescrparser/extreme.py @@ -2,7 +2,7 @@ """sysdescrparser.extreme.""" -from sysdescr import SysDescr +from sysdescrparser.sysdescr import SysDescr # pylint: disable=no-name-in-module diff --git a/sysdescrparser/extreme_xos.py b/sysdescrparser/extreme_xos.py index b4b083b..83971aa 100644 --- a/sysdescrparser/extreme_xos.py +++ b/sysdescrparser/extreme_xos.py @@ -4,7 +4,7 @@ import re -from extreme import Extreme +from sysdescrparser.extreme import Extreme # pylint: disable=no-member diff --git a/sysdescrparser/fortinet.py b/sysdescrparser/fortinet.py index 728e6de..b7cfb93 100644 --- a/sysdescrparser/fortinet.py +++ b/sysdescrparser/fortinet.py @@ -2,7 +2,7 @@ """sysdescrparser.FortiNet.""" -from sysdescr import SysDescr +from sysdescrparser.sysdescr import SysDescr # pylint: disable=no-name-in-module diff --git a/sysdescrparser/fortinet_fortios.py b/sysdescrparser/fortinet_fortios.py index d34fca1..3ecd89c 100644 --- a/sysdescrparser/fortinet_fortios.py +++ b/sysdescrparser/fortinet_fortios.py @@ -1,5 +1,5 @@ import re -from fortinet import FortiNet +from sysdescrparser.fortinet import FortiNet class FortiOs(FortiNet): diff --git a/sysdescrparser/foundry.py b/sysdescrparser/foundry.py index 111c1c7..27994c2 100644 --- a/sysdescrparser/foundry.py +++ b/sysdescrparser/foundry.py @@ -2,7 +2,7 @@ """sysdescrparser.foundry.""" -from sysdescr import SysDescr +from sysdescrparser.sysdescr import SysDescr # pylint: disable=no-name-in-module diff --git a/sysdescrparser/foundry_ironware.py b/sysdescrparser/foundry_ironware.py index e6a5705..b9ef632 100644 --- a/sysdescrparser/foundry_ironware.py +++ b/sysdescrparser/foundry_ironware.py @@ -4,7 +4,7 @@ import re -from foundry import Foundry +from sysdescrparser.foundry import Foundry # pylint: disable=no-member diff --git a/sysdescrparser/freebsd.py b/sysdescrparser/freebsd.py index dbf88a8..9fe49c0 100644 --- a/sysdescrparser/freebsd.py +++ b/sysdescrparser/freebsd.py @@ -3,7 +3,7 @@ """sysdescrparser.freebsd.""" import re -from sysdescr import SysDescr +from sysdescrparser.sysdescr import SysDescr # pylint: disable=no-name-in-module diff --git a/sysdescrparser/hp.py b/sysdescrparser/hp.py index c7b0954..15abf7e 100644 --- a/sysdescrparser/hp.py +++ b/sysdescrparser/hp.py @@ -2,7 +2,7 @@ """sysdescrparser.hp.""" -from sysdescr import SysDescr +from sysdescrparser.sysdescr import SysDescr # pylint: disable=no-name-in-module diff --git a/sysdescrparser/hp_procurve.py b/sysdescrparser/hp_procurve.py index cba287e..7474ccf 100644 --- a/sysdescrparser/hp_procurve.py +++ b/sysdescrparser/hp_procurve.py @@ -4,7 +4,7 @@ import re -from hp import HP +from sysdescrparser.hp import HP # pylint: disable=no-member diff --git a/sysdescrparser/iij.py b/sysdescrparser/iij.py index f432a8f..7e407bb 100644 --- a/sysdescrparser/iij.py +++ b/sysdescrparser/iij.py @@ -2,7 +2,7 @@ """sysdescrparser.iij.""" -from sysdescr import SysDescr +from sysdescrparser.sysdescr import SysDescr # pylint: disable=no-name-in-module diff --git a/sysdescrparser/iij_seil.py b/sysdescrparser/iij_seil.py index e48f37a..43f4965 100644 --- a/sysdescrparser/iij_seil.py +++ b/sysdescrparser/iij_seil.py @@ -4,7 +4,7 @@ import re -from iij import IIJ +from sysdescrparser.iij import IIJ # pylint: disable=no-member diff --git a/sysdescrparser/juniper.py b/sysdescrparser/juniper.py index 87ed389..136bf97 100644 --- a/sysdescrparser/juniper.py +++ b/sysdescrparser/juniper.py @@ -2,7 +2,7 @@ """sysdescrparser.juniper.""" -from sysdescr import SysDescr +from sysdescrparser.sysdescr import SysDescr # pylint: disable=no-name-in-module diff --git a/sysdescrparser/juniper_junos.py b/sysdescrparser/juniper_junos.py index 0dd7087..b93cfac 100644 --- a/sysdescrparser/juniper_junos.py +++ b/sysdescrparser/juniper_junos.py @@ -4,7 +4,7 @@ import re -from juniper import Juniper +from sysdescrparser.juniper import Juniper # pylint: disable=no-member diff --git a/sysdescrparser/juniper_screenos.py b/sysdescrparser/juniper_screenos.py index 1d78751..4952e9f 100644 --- a/sysdescrparser/juniper_screenos.py +++ b/sysdescrparser/juniper_screenos.py @@ -4,7 +4,7 @@ import re -from juniper import Juniper +from sysdescrparser.juniper import Juniper # pylint: disable=no-member diff --git a/sysdescrparser/linux.py b/sysdescrparser/linux.py index 831d823..7941747 100644 --- a/sysdescrparser/linux.py +++ b/sysdescrparser/linux.py @@ -3,8 +3,8 @@ """sysdescrparser.linux.""" import re -from sysdescr import SysDescr -from utils.utils import os_version_names_regex, extract_version_number +from sysdescrparser.sysdescr import SysDescr +from sysdescrparser.utils import os_version_names_regex, extract_version_number # pylint: disable=no-name-in-module diff --git a/sysdescrparser/mikrotik_routeros.py b/sysdescrparser/mikrotik_routeros.py index 6b7f251..9c3752e 100644 --- a/sysdescrparser/mikrotik_routeros.py +++ b/sysdescrparser/mikrotik_routeros.py @@ -2,7 +2,7 @@ """sysdescrparser.mikrotik_routeros.""" -from sysdescr import SysDescr +from sysdescrparser.sysdescr import SysDescr import re diff --git a/sysdescrparser/paloalto.py b/sysdescrparser/paloalto.py index 98335bb..54a2323 100644 --- a/sysdescrparser/paloalto.py +++ b/sysdescrparser/paloalto.py @@ -2,7 +2,7 @@ """sysdescrparser.paloalto.""" -from sysdescr import SysDescr +from sysdescrparser.sysdescr import SysDescr # pylint: disable=no-name-in-module diff --git a/sysdescrparser/paloalto_panos.py b/sysdescrparser/paloalto_panos.py index 78a6d7e..ab6175d 100644 --- a/sysdescrparser/paloalto_panos.py +++ b/sysdescrparser/paloalto_panos.py @@ -4,7 +4,7 @@ import re -from paloalto import PaloAlto +from sysdescrparser.paloalto import PaloAlto # pylint: disable=no-member diff --git a/sysdescrparser/sun.py b/sysdescrparser/sun.py index 5bd3c21..613cddd 100644 --- a/sysdescrparser/sun.py +++ b/sysdescrparser/sun.py @@ -2,7 +2,7 @@ """sysdescrparser.sun.""" -from sysdescr import SysDescr +from sysdescrparser.sysdescr import SysDescr # pylint: disable=no-name-in-module diff --git a/sysdescrparser/sun_sunos.py b/sysdescrparser/sun_sunos.py index 0c53b2a..545bb6d 100644 --- a/sysdescrparser/sun_sunos.py +++ b/sysdescrparser/sun_sunos.py @@ -4,7 +4,7 @@ import re -from sun import Sun +from sysdescrparser.sun import Sun # pylint: disable=no-member diff --git a/sysdescrparser/sysdescrparser.py b/sysdescrparser/sysdescrparser.py index ccef6cc..137d750 100644 --- a/sysdescrparser/sysdescrparser.py +++ b/sysdescrparser/sysdescrparser.py @@ -3,37 +3,37 @@ """sysdescrparser.""" -import sys -import os -sys.path.append(os.path.dirname(__file__)) - -# pylint: disable=C0413 -from aruba import Aruba -from cisco_asa import CiscoASA -from cisco_ios import CiscoIOS -from cisco_nxos import CiscoNXOS -from cisco_iosxe import CiscoIOSXE -from cisco_iosxr import CiscoIOSXR -from mikrotik_routeros import MikroTikRouterOS -from juniper_junos import JuniperJunos -from juniper_screenos import JuniperScreenOS -from brocade_ironware import BrocadeIronWare -from brocade_serveriron import BrocadeServerIron -from brocade_networkos import BrocadeNetworkOS -from foundry_ironware import FoundryIronWare -from arista_eos import AristaEOS -from hp_procurve import HPProCurve -from extreme_xos import ExtremeXOS -from paloalto_panos import PaloAltoPANOS -from a10_acos import A10ACOS -from citrix_netscaler import CitrixNetscaler -from linux import Linux -from sun_sunos import SunSUNOS -from freebsd import FreeBSD -from iij_seil import IIJSeil -from yamaha_rtx import YamahaRTX -from fortinet_fortios import FortiOs -from unknown import Unknown +# Why this? +# import sys +# import os +# sys.path.append(os.path.dirname(__file__)) + +from sysdescrparser.aruba import Aruba +from sysdescrparser.cisco_asa import CiscoASA +from sysdescrparser.cisco_ios import CiscoIOS +from sysdescrparser.cisco_nxos import CiscoNXOS +from sysdescrparser.cisco_iosxe import CiscoIOSXE +from sysdescrparser.cisco_iosxr import CiscoIOSXR +from sysdescrparser.mikrotik_routeros import MikroTikRouterOS +from sysdescrparser.juniper_junos import JuniperJunos +from sysdescrparser.juniper_screenos import JuniperScreenOS +from sysdescrparser.brocade_ironware import BrocadeIronWare +from sysdescrparser.brocade_serveriron import BrocadeServerIron +from sysdescrparser.brocade_networkos import BrocadeNetworkOS +from sysdescrparser.foundry_ironware import FoundryIronWare +from sysdescrparser.arista_eos import AristaEOS +from sysdescrparser.hp_procurve import HPProCurve +from sysdescrparser.extreme_xos import ExtremeXOS +from sysdescrparser.paloalto_panos import PaloAltoPANOS +from sysdescrparser.a10_acos import A10ACOS +from sysdescrparser.citrix_netscaler import CitrixNetscaler +from sysdescrparser.linux import Linux +from sysdescrparser.sun_sunos import SunSUNOS +from sysdescrparser.freebsd import FreeBSD +from sysdescrparser.iij_seil import IIJSeil +from sysdescrparser.yamaha_rtx import YamahaRTX +from sysdescrparser.fortinet_fortios import FortiOs +from sysdescrparser.unknown import Unknown def sysdescrparser(sysdescr): diff --git a/sysdescrparser/tests/test_sysdescrparser.py b/sysdescrparser/tests/test_sysdescrparser.py index c2967f1..5dd5773 100644 --- a/sysdescrparser/tests/test_sysdescrparser.py +++ b/sysdescrparser/tests/test_sysdescrparser.py @@ -5,8 +5,8 @@ import unittest import os import json -from sysdescrparser import sysdescrparser -from sysdescr import SysDescr +from sysdescrparser.sysdescrparser import sysdescrparser +from sysdescrparser.sysdescr import SysDescr class UnitTests(unittest.TestCase): diff --git a/sysdescrparser/unknown.py b/sysdescrparser/unknown.py index 9089dd2..227a5ee 100644 --- a/sysdescrparser/unknown.py +++ b/sysdescrparser/unknown.py @@ -3,7 +3,7 @@ """sysdescrparser.unknown.""" -from sysdescr import SysDescr +from sysdescrparser.sysdescr import SysDescr class Unknown(SysDescr): diff --git a/sysdescrparser/utils/__init__.py b/sysdescrparser/utils/__init__.py index 16281fe..2291a58 100644 --- a/sysdescrparser/utils/__init__.py +++ b/sysdescrparser/utils/__init__.py @@ -1 +1,11 @@ -from .utils import * +def os_version_names_regex(os_dict): + os_version_names = os_dict.keys() + return "|".join(os_version_names) + + +def extract_version_number(os_dict, version_name): + version_name = version_name.lower() + version_number = os_dict[version_name] + version_number = str(version_number) + return version_number + diff --git a/sysdescrparser/utils/utils.py b/sysdescrparser/utils/utils.py deleted file mode 100644 index 6f24d37..0000000 --- a/sysdescrparser/utils/utils.py +++ /dev/null @@ -1,10 +0,0 @@ -def os_version_names_regex(os_dict): - os_version_names = os_dict.keys() - return "|".join(os_version_names) - - -def extract_version_number(os_dict, version_name): - version_name = version_name.lower() - version_number = os_dict[version_name] - version_number = str(version_number) - return version_number diff --git a/sysdescrparser/yamaha.py b/sysdescrparser/yamaha.py index 4d7d349..7858473 100644 --- a/sysdescrparser/yamaha.py +++ b/sysdescrparser/yamaha.py @@ -2,7 +2,7 @@ """sysdescrparser.yamaha.""" -from sysdescr import SysDescr +from sysdescrparser.sysdescr import SysDescr # pylint: disable=no-name-in-module diff --git a/sysdescrparser/yamaha_rtx.py b/sysdescrparser/yamaha_rtx.py index 23fd0a3..dbb4293 100644 --- a/sysdescrparser/yamaha_rtx.py +++ b/sysdescrparser/yamaha_rtx.py @@ -4,7 +4,7 @@ import re -from yamaha import Yamaha +from sysdescrparser.yamaha import Yamaha # pylint: disable=no-member From 30d9f07d324a4db2cb577b91c8e827f95173529c Mon Sep 17 00:00:00 2001 From: Ricky Laney Date: Fri, 18 Mar 2022 08:19:29 -0400 Subject: [PATCH 41/43] Update URLS --- .travis.yml | 5 +++-- README.rst | 14 +++++++------- setup.py | 15 ++++++--------- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3e70880..23f85b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,9 @@ language: python sudo: false env: -- TOXENV=py27 -- TOXENV=py36 +- TOXENV=py38 +- TOXENV=py39 +- TOXENV=py310 install: - pip install virtualenv tox docutils coveralls diff --git a/README.rst b/README.rst index 5fe40e9..a1134b1 100644 --- a/README.rst +++ b/README.rst @@ -17,17 +17,17 @@ If you have any need to handle the equipment that this module does not support, then please send the sysDescr value to this package author. Or, please contact using function of the such as github pull request. -.. image:: https://secure.travis-ci.org/mtoshi/sysdescrparser.svg?branch=master - :target: http://travis-ci.org/mtoshi/sysdescrparser -.. image:: https://coveralls.io/repos/mtoshi/sysdescrparser/badge.svg?branch=master - :target: https://coveralls.io/r/mtoshi/sysdescrparser?branch=master +.. image:: https://secure.travis-ci.org/rlaneyjr/sysdescrparser.svg?branch=master + :target: http://travis-ci.org/rlaneyjr/sysdescrparser +.. image:: https://coveralls.io/repos/rlaneyjr/sysdescrparser/badge.svg?branch=master + :target: https://coveralls.io/r/rlaneyjr/sysdescrparser?branch=master .. image:: https://img.shields.io/pypi/v/sysdescrparser.svg :target: https://pypi.python.org/pypi/sysdescrparser/ :alt: Latest Version Requirements ------------- -* Python2.7, 3.5, 3.6, 3.7, PyPy. +* Python3.8, 3.9, 3.10, PyPy. Instration ----------- @@ -37,7 +37,7 @@ Instration or - $ git clone https://github.com/mtoshi/sysdescrparser + $ git clone https://github.com/rlaneyjr/sysdescrparser $ cd sysdescrparser $ sudo python setup.py install @@ -88,7 +88,7 @@ Parsing logic and Support Vendor and OS ---------------------------------------- * About parsing logic and support of vendor and os. Of course you are able to see this python code and also see how it works easily from sample data. - https://github.com/mtoshi/sysdescrparser/blob/master/samples/sample_data.json + https://github.com/rlaneyjr/sysdescrparser/blob/master/samples/sample_data.json It will be able to understand almost. (Sometimes, using hard code. And also using UNKNOWN values.) This sample data is also used directly by code test. diff --git a/setup.py b/setup.py index 1f1ac30..c962150 100644 --- a/setup.py +++ b/setup.py @@ -40,13 +40,10 @@ def run_tests(self): classifiers = [ "Development Status :: 3 - Alpha", "Programming Language :: Python", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.3", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: System :: Networking", @@ -66,12 +63,12 @@ def run_tests(self): setup( name="snmpsysdescrparser", - version="0.1.21", - description='SNMP sysDescr parser.', + version="0.1.22", + description='SNMP sysDescr parser fork for Windows Support', long_description=README, author='Yazdan', author_email='yzdannn@gmail.com', - url='https://github.com/yzdann/sysdescrparser', + url='https://github.com/rlaneyjr/sysdescrparser', license='MIT', classifiers=classifiers, packages=find_packages(exclude=EXCLUDE_FROM_PACKAGES), From 9f12feb0339c61ecbe896db93db1a7104702c359 Mon Sep 17 00:00:00 2001 From: Ricky Laney Date: Fri, 18 Mar 2022 08:27:09 -0400 Subject: [PATCH 42/43] Fixe TOX envs --- .gitignore | 1 + tox.ini | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 7648488..814e49c 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ dist/ htmlcov/ migrations/ test_result.txt +.python-version diff --git a/tox.ini b/tox.ini index 02ace34..8235a08 100644 --- a/tox.ini +++ b/tox.ini @@ -1,9 +1,8 @@ [tox] envlist = - py27, - py35, - py36, - py37, + py38, + py39, + py310, PyPy, pylint, docs From 616d0e92918e2fa53ee9b6df69c6120ce174c2df Mon Sep 17 00:00:00 2001 From: Ricky Laney Date: Mon, 21 Mar 2022 11:20:51 -0400 Subject: [PATCH 43/43] Fixed URL links --- sysdescrparser/sysdescrparser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sysdescrparser/sysdescrparser.py b/sysdescrparser/sysdescrparser.py index 137d750..d6b6d6f 100644 --- a/sysdescrparser/sysdescrparser.py +++ b/sysdescrparser/sysdescrparser.py @@ -72,11 +72,11 @@ def sysdescrparser(sysdescr): Currently supported Vendor and OS. - https://github.com/mtoshi/sysdescrparser/blob/master/samples/sample_data.json + https://github.com/rlaneyjr/sysdescrparser/blob/master/samples/sample_data.json See also: - https://github.com/mtoshi/sysdescrparser/blob/master/README.rst + https://github.com/rlaneyjr/sysdescrparser/blob/master/README.rst """