From d97d137ed88d4abbb07c19a304106f931f207729 Mon Sep 17 00:00:00 2001 From: Dmitry Luhtionov Date: Thu, 9 Jan 2020 17:27:54 +0200 Subject: [PATCH] Update Cisco.IOS profile to support old hardware --- sa/profiles/Cisco/IOS/get_chassis_id.py | 4 ++-- sa/profiles/Cisco/IOS/get_inventory.py | 14 +++++++++++++- sa/profiles/Cisco/IOS/profile.py | 4 ++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/sa/profiles/Cisco/IOS/get_chassis_id.py b/sa/profiles/Cisco/IOS/get_chassis_id.py index 8c5a057551..77ed65480f 100644 --- a/sa/profiles/Cisco/IOS/get_chassis_id.py +++ b/sa/profiles/Cisco/IOS/get_chassis_id.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # Cisco.IOS.get_chassis_id # --------------------------------------------------------------------- -# Copyright (C) 2007-2018 The NOC Project +# Copyright (C) 2007-2020 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -121,7 +121,7 @@ class Script(BaseScript): 7200, 7301 :return: """ - v = self.cli("show c%s | i MAC" % self.version["platform"]) + v = self.cli("show c%s00 | i MAC" % self.version["platform"][:2]) macs = [] for f, t in [ (mac, MAC(mac).shift(int(count) - 1)) for count, mac in self.rx_7200.findall(v) diff --git a/sa/profiles/Cisco/IOS/get_inventory.py b/sa/profiles/Cisco/IOS/get_inventory.py index 9c1dbc5a48..122573d87d 100644 --- a/sa/profiles/Cisco/IOS/get_inventory.py +++ b/sa/profiles/Cisco/IOS/get_inventory.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # Cisco.IOS.get_inventory # --------------------------------------------------------------------- -# Copyright (C) 2007-2019 The NOC Project +# Copyright (C) 2007-2020 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -373,6 +373,15 @@ class Script(BaseScript): and "Supervisor Engine" in descr ): return "SUP", self.slot_id, pid + if pid.startswith("PA-"): + # Port Adapter + return "PA", self.slot_id, pid + if "I/O Controller" in descr: + # I/O controller directly attached to chassis, without container + match = self.rx_slot_id.search(name) + if match: + return "IO", match.group("slot_id"), pid + return "IO", self.slot_id, pid else: if pid == "N/A" and "Gibraltar,G-20" in descr: # 2-port 100BASE-TX Fast Ethernet port adapter @@ -483,6 +492,9 @@ class Script(BaseScript): elif "Compact Flash Disk" in descr: # Compact Flash return "Flash | CF", name, pid + elif "PCMCIA Flash Disk" in descr: + # PCMCIA Flash + return "Flash | PCMCIA", name, pid # Unknown return None, None, None diff --git a/sa/profiles/Cisco/IOS/profile.py b/sa/profiles/Cisco/IOS/profile.py index 4cd8a2ae50..f159f28610 100644 --- a/sa/profiles/Cisco/IOS/profile.py +++ b/sa/profiles/Cisco/IOS/profile.py @@ -3,7 +3,7 @@ # Vendor: Cisco # OS: IOS # --------------------------------------------------------------------- -# Copyright (C) 2007-2019 The NOC Project +# Copyright (C) 2007-2020 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -56,7 +56,7 @@ class Profile(BaseProfile): rx_ver = re.compile(r"(\d+)\.(\d+)[\(.](\d+)[\).]\S*") matchers = { - "is_platform_7200": {"platform": {"$regex": r"7200|7301"}}, + "is_platform_7200": {"platform": {"$regex": r"720[0146]|730[14]"}}, "is_platform_7600": {"platform": {"$regex": r"76(0[3459](\-S)?|13)"}}, "is_platform_me3x00x": {"platform": {"$regex": r"^ME\-3[68]00X"}}, "is_isr_router": {"platform": {"$regex": r"^(19\d\d|29\d\d|39\d\d)$"}}, -- GitLab