From 577d20e8548d8402fe593a46e9f03ea90a792dc0 Mon Sep 17 00:00:00 2001 From: Dmitry Luhtionov Date: Thu, 17 Oct 2019 11:40:59 +0300 Subject: [PATCH] Fix Eltex.MA4000.get_inventory script --- sa/profiles/Eltex/MA4000/get_inventory.py | 32 ++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/sa/profiles/Eltex/MA4000/get_inventory.py b/sa/profiles/Eltex/MA4000/get_inventory.py index 1c56a0a990..d7eaeeef93 100644 --- a/sa/profiles/Eltex/MA4000/get_inventory.py +++ b/sa/profiles/Eltex/MA4000/get_inventory.py @@ -24,6 +24,11 @@ class Script(BaseScript): r"^\s*Hardware version:\s+(?P\S+)\s*\n", re.MULTILINE, ) + rx_gpon_port = re.compile(r"^\s*Gpon-port:\s+(.+)\n", re.MULTILINE) + rx_gpon_vendor = re.compile(r"^\s*SFP vendor:\s+(.+)\n", re.MULTILINE) + rx_gpon_part_no = re.compile(r"^\s*SFP product number:\s+(.+)\n", re.MULTILINE) + rx_gpon_rev = re.compile(r"^\s*SFP vendor revision:\s+(.+)\n", re.MULTILINE) + rx_sep = re.compile(r"\s\s+") def execute_cli(self, **kwargs): v = self.scripts.get_version() @@ -51,5 +56,30 @@ class Script(BaseScript): "revision": match.group("revision"), } res += [r] - + sfp = [] + c = self.cli("show interface gpon-port %s/all state" % i[0]) + match = self.rx_gpon_port.search(c) + if not match: + continue + items = self.rx_sep.split(match.group(1)) + for i in range(64): # Maximum value + try: + sfp += [{"number": items[i].strip(), "type": "XCVR"}] + except IndexError: + break + sfp_count = i + match = self.rx_gpon_vendor.search(c) + items = self.rx_sep.split(match.group(1)) + for i in range(sfp_count): + sfp[i]["vendor"] = items[i].strip() + match = self.rx_gpon_part_no.search(c) + items = self.rx_sep.split(match.group(1)) + for i in range(sfp_count): + sfp[i]["part_no"] = items[i].strip() + match = self.rx_gpon_rev.search(c) + items = self.rx_sep.split(match.group(1)) + for i in range(sfp_count): + sfp[i]["revision"] = items[i].strip() + for i in range(sfp_count): + res += [sfp[i]] return res -- GitLab