From cfe3612d0b349566eb1c3ab4ba5044e2ba7446af Mon Sep 17 00:00:00 2001 From: Dmitry Luhtionov Date: Thu, 30 Dec 2021 13:46:03 +0200 Subject: [PATCH 1/3] Fix Cisco.IOS.get_inventory script --- sa/profiles/Cisco/IOS/get_inventory.py | 32 ++++++++++++++++++++------ 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/sa/profiles/Cisco/IOS/get_inventory.py b/sa/profiles/Cisco/IOS/get_inventory.py index f812b3a3cb..50f2be23a1 100644 --- a/sa/profiles/Cisco/IOS/get_inventory.py +++ b/sa/profiles/Cisco/IOS/get_inventory.py @@ -1,7 +1,7 @@ # --------------------------------------------------------------------- # Cisco.IOS.get_inventory # --------------------------------------------------------------------- -# Copyright (C) 2007-2020 The NOC Project +# Copyright (C) 2007-2021 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -62,7 +62,8 @@ class Script(BaseScript): ) rx_c4900m = re.compile(r"^Cisco Systems, Inc. (?P\S+) \d+ slot switch") rx_slot_id = re.compile( - r"^.*(slot|[tr|b]ay|pem|supply|fan|module)(\s*:?)(?P[\d|\w]+).*", re.IGNORECASE + r"^.*(slot|[tr|b]ay|pem|supply|fan|module|disk|card)(\s*:?)(?P[\d|\w]+).*", + re.IGNORECASE, ) rx_psu1 = re.compile(r"(?:PS|Power Supply) (?P\d+) ") rx_psu2 = re.compile(r"Power Supply (?P\d+)$") @@ -272,12 +273,18 @@ class Script(BaseScript): # Cisco ISR series not have PID for motherboard if "1921" in name: return "MOTHERBOARD", None, "CISCO1921-MB" + elif "2921" in name: + return "MOTHERBOARD", None, "CISCO2921-MB" + elif "2811" in name: + return "MOTHERBOARD", None, "CISCO2811-MB" + elif "2821" in name: + return "MOTHERBOARD", None, "CISCO2821-MB" + elif "2851" in name: + return "MOTHERBOARD", None, "CISCO2851-MB" elif "2901" in name: return "MOTHERBOARD", None, "CISCO2901-MB" elif "2911" in name: return "MOTHERBOARD", None, "CISCO2911-MB" - elif "2921" in name: - return "MOTHERBOARD", None, "CISCO2921-MB" pid = "" match = self.rx_slot_id.search(name) if match: @@ -406,7 +413,12 @@ class Script(BaseScript): # 2-port 100BASE-TX Fast Ethernet port adapter pid = "CISCO7100-MB" if pid in ("ASR1001", "ASR1001-X"): - return "RP", self.slot_id, pid + "-RP" + if "Route Processor" in descr: + return "RP", self.slot_id, pid + "-RP" + elif "SPA Interface Processor" in descr: + return "SIP", self.slot_id, pid + "-SIP" + elif "Embedded Services Processor" in descr: + return "ESP", self.slot_id, pid + "-ESP" return "MOTHERBOARD", self.slot_id, pid elif ( pid.startswith("WS-X64") @@ -512,10 +524,16 @@ class Script(BaseScript): return "VTT", self.slot_id, pid elif "Compact Flash Disk" in descr: # Compact Flash - return "Flash | CF", name, pid + match = self.rx_slot_id.search(name) + if match: + self.slot_id = int(match.group("slot_id")) + return "Flash | CF", self.slot_id, pid elif "PCMCIA Flash Disk" in descr: # PCMCIA Flash - return "Flash | PCMCIA", name, pid + match = self.rx_slot_id.search(name) + if match: + self.slot_id = int(match.group("slot_id")) + return "Flash | PCMCIA", self.slot_id, pid elif name.startswith("StackPort"): match = self.rx_stack1.search(name) if match: -- GitLab From ce90e940602876efe7370ecf6978e9085fa01b60 Mon Sep 17 00:00:00 2001 From: Dmitry Luhtionov Date: Thu, 30 Dec 2021 14:29:47 +0200 Subject: [PATCH 2/3] Fix --- sa/profiles/Cisco/IOS/get_inventory.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sa/profiles/Cisco/IOS/get_inventory.py b/sa/profiles/Cisco/IOS/get_inventory.py index 50f2be23a1..be9b775391 100644 --- a/sa/profiles/Cisco/IOS/get_inventory.py +++ b/sa/profiles/Cisco/IOS/get_inventory.py @@ -417,6 +417,8 @@ class Script(BaseScript): return "RP", self.slot_id, pid + "-RP" elif "SPA Interface Processor" in descr: return "SIP", self.slot_id, pid + "-SIP" + elif "Shared Port Adapter" in descr: + return "SPA", self.slot_id, pid + "-SPA" elif "Embedded Services Processor" in descr: return "ESP", self.slot_id, pid + "-ESP" return "MOTHERBOARD", self.slot_id, pid -- GitLab From d6a6ed4dae5a1af3ef7aca1d830dc3ecf9dff81a Mon Sep 17 00:00:00 2001 From: Dmitry Luhtionov Date: Thu, 30 Dec 2021 14:48:31 +0200 Subject: [PATCH 3/3] Fix --- sa/profiles/Cisco/IOS/get_inventory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sa/profiles/Cisco/IOS/get_inventory.py b/sa/profiles/Cisco/IOS/get_inventory.py index be9b775391..1c6ad93e87 100644 --- a/sa/profiles/Cisco/IOS/get_inventory.py +++ b/sa/profiles/Cisco/IOS/get_inventory.py @@ -383,7 +383,7 @@ class Script(BaseScript): elif ("SUP" in pid or "S2U" in pid) and "supervisor" in descr: # Sup2 return "SUP", self.slot_id, pid - elif name.startswith("module "): + elif name.startswith("module ") or name.startswith("SPA subslot "): # Linecards or supervisors if pid.startswith("RSP") or ( (pid.startswith("WS-SUP") or pid.startswith("VS-S")) -- GitLab