Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Incomplete
-
Affects Version/s: 0.7(4)
-
Fix Version/s: 15.05
-
Component/s: SA
-
Labels:
-
Environment:
NOC 0.7(4) OS Linux saiga 2.6.32-5-amd64 #1 SMP Thu Mar 22 17:26:33 UTC 2012 x86_64 OS Brand Debian GNU/Linux 6.0.4 (squeeze) Python 2.7.3 (default, Aug 21 2012, 15:46:37) [GCC 4.4.5] PostgreSQL PostgreSQL 8.4.12 MongoDB 2.0.7 (64bit) Python Path .:..:/opt/noc/scripts:/usr/local/python-2.7.3/lib/python2.7/site-packages/setuptools-0.6c9-py2.7.egg:/usr/local/python-2.7.3/lib/python2.7/site-packages/psycopg2-2.4.5-py2.7-linux-x86_64.egg:/usr/local/python-2.7.3/lib/python2.7/site-packages/pycrypto-2.6-py2.7-linux-x86_64.egg:/usr/local/python-2.7.3/lib/python2.7/site-packages/python_cjson-1.0.5-py2.7-linux-x86_64.egg:/usr/local/python-2.7.3/lib/python2.7/site-packages/gmpy-1.15-py2.7-linux-x86_64.egg:/usr/local/python-2.7.3/lib/python2.7/site-packages/netifaces-0.8-py2.7-linux-x86_64.egg:/usr/local/python-2.7.3/lib/python2.7/site-packages/docutils-0.9.1-py2.7.egg:/usr/local/python-2.7.3/lib/python2.7/site-packages/pymongo-2.3-py2.7-linux-x86_64.egg:/usr/local/python-2.7.3/lib/python27.zip:/usr/local/python-2.7.3/lib/python2.7:/usr/local/python-2.7.3/lib/python2.7/plat-linux2:/usr/local/python-2.7.3/lib/python2.7/lib-tk:/usr/local/python-2.7.3/lib/python2.7/lib-old:/usr/local/python-2.7.3/lib/python2.7/lib-dynload:/usr/local/python-2.7.3/lib/python2.7/site-packages psycopg2 2.4.5 (dt dec pq3 ext) pymongo 2.3 Sphinx 1.0.7 protobuf 2.4.1 tornado 2.2 python-creole 0.2.4 mongoengine 0.6.20 django 1.4.1 docutils 0.7 Pygments 1.2.2 Jinja2 2.2.1 coverage 3.5.1 pysnmp 4.2.1 pyasn1 0.1.2 south 0.7.3 django-tagging 0.3.1 NOC 0.7(4) OS Linux saiga 2.6.32-5-amd64 #1 SMP Thu Mar 22 17:26:33 UTC 2012 x86_64 OS Brand Debian GNU/Linux 6.0.4 (squeeze) Python 2.7.3 (default, Aug 21 2012, 15:46:37) [GCC 4.4.5] PostgreSQL PostgreSQL 8.4.12 MongoDB 2.0.7 (64bit) Python Path .:..:/opt/noc/scripts:/usr/local/python-2.7.3/lib/python2.7/site-packages/setuptools-0.6c9-py2.7.egg:/usr/local/python-2.7.3/lib/python2.7/site-packages/psycopg2-2.4.5-py2.7-linux-x86_64.egg:/usr/local/python-2.7.3/lib/python2.7/site-packages/pycrypto-2.6-py2.7-linux-x86_64.egg:/usr/local/python-2.7.3/lib/python2.7/site-packages/python_cjson-1.0.5-py2.7-linux-x86_64.egg:/usr/local/python-2.7.3/lib/python2.7/site-packages/gmpy-1.15-py2.7-linux-x86_64.egg:/usr/local/python-2.7.3/lib/python2.7/site-packages/netifaces-0.8-py2.7-linux-x86_64.egg:/usr/local/python-2.7.3/lib/python2.7/site-packages/docutils-0.9.1-py2.7.egg:/usr/local/python-2.7.3/lib/python2.7/site-packages/pymongo-2.3-py2.7-linux-x86_64.egg:/usr/local/python-2.7.3/lib/python27.zip:/usr/local/python-2.7.3/lib/python2.7:/usr/local/python-2.7.3/lib/python2.7/plat-linux2:/usr/local/python-2.7.3/lib/python2.7/lib-tk:/usr/local/python-2.7.3/lib/python2.7/lib-old:/usr/local/python-2.7.3/lib/python2.7/lib-dynload:/usr/local/python-2.7.3/lib/python2.7/site-packages psycopg2 2.4.5 (dt dec pq3 ext) pymongo 2.3 Sphinx 1.0.7 protobuf 2.4.1 tornado 2.2 python-creole 0.2.4 mongoengine 0.6.20 django 1.4.1 docutils 0.7 Pygments 1.2.2 Jinja2 2.2.1 coverage 3.5.1 pysnmp 4.2.1 pyasn1 0.1.2 south 0.7.3 django-tagging 0.3.1
-
Difficulty:Easy
Description
Несколько патчей для профиля Huawei.VRP
- поддержка сбора serial number (вывод display elabel) и сохранения его в attributes.serial для mo
- поддержка snmp_ifindex для get_interface_status, get_interfaces
- поддержка интерфейсов с default description для inventory (5.3, 5.7)
- улучшенный промпт
NOC-738 NOC-702 можно закрывать
diff -r 987a7df9cd59 sa/profiles/Huawei/VRP/__init__.py --- a/sa/profiles/Huawei/VRP/__init__.py Wed Oct 10 14:56:14 2012 +0400 +++ b/sa/profiles/Huawei/VRP/__init__.py Tue Oct 16 23:57:08 2012 +0300 @@ -20,7 +20,7 @@ (r"^ ---- More ----", " "), (r"[Cc]ontinue?\S+", "y\n\r") ] - pattern_prompt = r"^[<#\[]\S+?[>#\]]" + pattern_prompt = r"^[<#\[](?P<hostname>\S+?)[>#\]]" pattern_syntax_error = r"Error: " command_more = " " config_volatile = ["^%.*?$"] diff -r 987a7df9cd59 sa/profiles/Huawei/VRP/get_interface_status.py --- a/sa/profiles/Huawei/VRP/get_interface_status.py Wed Oct 10 14:56:14 2012 +0400 +++ b/sa/profiles/Huawei/VRP/get_interface_status.py Tue Oct 16 23:57:08 2012 +0300 @@ -30,11 +30,12 @@ try: # Get interface status r = [] - # IF-MIB::ifName, IF-MIB::ifOperStatus - for n, s in self.snmp.join_tables("1.3.6.1.2.1.31.1.1.1.1", - "1.3.6.1.2.1.2.2.1.8", bulk=True): - # ifOperStatus up(1) - r += [{"interface":n, "status":int(s) == 1}] + # IF-MIB::ifIndex, IF-MIB::ifName, IF-MIB::ifOperStatus, IF-MIB::ifAlias + for j, i, n, s, d in self.join_four_tables(self.snmp, + "1.3.6.1.2.1.2.2.1.1", "1.3.6.1.2.1.31.1.1.1.1", + "1.3.6.1.2.1.2.2.1.8", "1.3.6.1.2.1.31.1.1.1.18", + bulk=True): + r += [{"snmp_ifindex":i, "interface":n, "status":int(s) == 1, "description":d}] return r except self.snmp.TimeOutError: pass @@ -68,3 +69,22 @@ "status": match_int.group("status").lower() == "up" }] return r + ## + ## Generator returning a rows of 4 snmp tables joined by index, function copied from Edgecore.ES profile + ## + def join_four_tables(self, snmp, oid1, oid2, oid3, oid4, + community_suffix=None, bulk=False, min_index=None, max_index=None, + cached=False): + t1 = snmp.get_table(oid1, community_suffix=community_suffix, bulk=bulk, + min_index=min_index, max_index=max_index, cached=cached) + t2 = snmp.get_table(oid2, community_suffix=community_suffix, bulk=bulk, + min_index=min_index, max_index=max_index, cached=cached) + t3 = snmp.get_table(oid3, community_suffix=community_suffix, bulk=bulk, + min_index=min_index, max_index=max_index, cached=cached) + t4 = snmp.get_table(oid4, community_suffix=community_suffix, bulk=bulk, + min_index=min_index, max_index=max_index, cached=cached) + for k1, v1 in t1.items(): + try: + yield (k1, v1, t2[k1], t3[k1], t4[k1]) + except KeyError: + pass diff -r 987a7df9cd59 sa/profiles/Huawei/VRP/get_interfaces.py --- a/sa/profiles/Huawei/VRP/get_interfaces.py Wed Oct 10 14:56:14 2012 +0400 +++ b/sa/profiles/Huawei/VRP/get_interfaces.py Tue Oct 16 23:57:08 2012 +0300 @@ -24,7 +24,7 @@ rx_dis_int = re.compile(r"^(?P<interface>\S+?)\s+current\s+state\s+:\s+(?:administratively\s+)?(?P<admin_status>up|down)\n" r"(?:Line\s+protocol\s+current\s+state\s+:\s+(?P<oper_status>up|down)\n)?" r"(?:Last line protocol up time :[^\n]+\n)?" - r"(?:Description\s*:\s*(?P<desc>[^\n,]+)(?:, (?:Switch|Router) Port)?\n)?" + r"(?:Description\s*:\s*(?P<desc>.+)(?:, (?:Switch|Router) Port)?\n)?" r"(?:(?:Route|Switch) Port[^\n]+\n)?" r"(?:PVID[^\n]+\n)?" # vrp v5.3 r"(?:The Maximum Transmit Unit[^\n]+\n)?" # vrp v5.3 @@ -40,6 +40,7 @@ #rx_sec_ip = re.compile(r"Internet Address is (?P<ip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\/\d{1,2}) Sub", re.MULTILINE | re.IGNORECASE) rx_ospf = re.compile(r"^Interface:\s(?P<ip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+\((?P<name>\S+)\)\s+", re.MULTILINE) rx_huawei_interface_name = re.compile(r"^(?P<type>[a-z]{2})[a-z\-]*\s*(?P<number>\d+(/\d+(/\d+)?)?([.:]\d+(\.\d+)?)?)$", re.IGNORECASE) + rx_desc53 = re.compile(r"(?P<desc53>.+)(?:, (?:Route|Switch) Port)+", re.IGNORECASE) types = { "Aux": "physical", @@ -71,6 +72,23 @@ return ospfs def execute(self): + + name_ = {} + mac_ = {} + snmp_ifindex_ = {} + descr_ = {} + stat_ = {} + + # Get interface status + for p in self.scripts.get_interface_status(): + intf = p["interface"] + name_[intf] = intf + if "description" in p: + descr_[intf] = p["description"] + stat_[intf] = p["status"] + if "snmp_ifindex" in p: + snmp_ifindex_[intf] = p["snmp_ifindex"] + # Get switchports and fill tagged/untagged lists if they are not empty switchports = {} for sp in self.scripts.get_switchport(): @@ -127,10 +145,15 @@ "name": ifname, "admin_status": a_stat, "oper_status": o_stat, + "snmp_ifindex": snmp_ifindex_[ifname], } if match.group("desc") and match.group("desc") != "---": - sub["description"] = match.group("desc") + desc = match.group("desc") + desc53 = self.rx_desc53.search(desc) + if desc53: + desc = desc53.group("desc53") + sub["description"] = desc matchmac = self.rx_mac.search(hw) if matchmac: @@ -167,7 +190,11 @@ "subinterfaces": [sub] } if match.group("desc") and match.group("desc") != "---": - iface["description"] = match.group("desc") + desc = match.group("desc") + desc53 = self.rx_desc53.search(desc) + if desc53: + desc = desc53.group("desc53") + iface["description"] = desc if "mac" in sub: iface["mac"] = sub["mac"] diff -r 987a7df9cd59 sa/profiles/Huawei/VRP/get_version.py --- a/sa/profiles/Huawei/VRP/get_version.py Wed Oct 10 14:56:14 2012 +0400 +++ b/sa/profiles/Huawei/VRP/get_version.py Tue Oct 16 23:57:08 2012 +0300 @@ -19,7 +19,8 @@ rx_ver = re.compile(r"^VRP.+Software, Version (?P<version>[^ ,]+),? .*?\n\s*(?:Quidway|Huawei) (?P<platform>(?:NetEngine\s+)?\S+)[^\n]+uptime", re.MULTILINE | re.DOTALL | re.IGNORECASE) rx_ver_snmp = re.compile(r"Versatile Routing Platform Software.*?Version (?P<version>[^ ,]+),? .*?\n\s*(?:Quidway|Huawei) (?P<platform>(?:NetEngine\s+)?[^ \t\n\r\f\v\-]+)[^\n]+", re.MULTILINE | re.DOTALL | re.IGNORECASE) rx_ver_snmp2 = re.compile(r"(?P<platform>(?:\S+\s+)?S\d+(?:[A-Z]+-[A-Z]+)?(?:\d+\S+)?)\s+Huawei\sVersatile\sRouting\sPlatform\sSoftware.*Version\s(?P<version>\d+\.\d+)\s\(S\d+\s(?P<image>\S+)+\).*", re.MULTILINE | re.DOTALL | re.IGNORECASE) - rx_ver_snmp3 = re.compile(r"^\s*VRP.+Software, Version (?P<version>\S+) \((?P<platform>S\S+) (?P<image>\S+)", re.MULTILINE | re.DOTALL | re.IGNORECASE) + rx_ver_snmp3 = re.compile(r"^\s*VRP.+Software, Version (?P<version>\S+) \((?P<platform>S\S+) (?P<image>\S+)\)", re.MULTILINE | re.DOTALL | re.IGNORECASE) + rx_serial = re.compile(r"BarCode=(?P<serial>\w+).+Item=", re.MULTILINE | re.DOTALL | re.IGNORECASE) def execute(self): v = "" @@ -47,9 +48,18 @@ r = { "vendor": "Huawei", "platform": platform, - "version": match.group("version") + "version": match.group("version"), + "attributes": {} } if "image" in match.groupdict(): image = match.group("image") - r["attributes"] = {"image": image} + r["attributes"].update({"image": image}) + try: + v = self.cli("display elabel") + except self.CLISyntaxError: + raise self.NotSupportedError() + match = self.rx_serial.search(v) + if match: + serial = match.group("serial") + r["attributes"].update({"serial": serial}) return r