From 30da9a344b576fead426940978966a92bc83a58b Mon Sep 17 00:00:00 2001 From: Stacy Smith Date: Wed, 11 Nov 2015 14:56:32 -0700 Subject: [PATCH 1/2] Handle new version output for 15.1+ releases on MX (FreeBSD10 based releases) --- lib/netconify/facts.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/netconify/facts.py b/lib/netconify/facts.py index 6f6bf4c..32ae64a 100644 --- a/lib/netconify/facts.py +++ b/lib/netconify/facts.py @@ -18,9 +18,18 @@ def version(self): self.swinfo = rsp # keep this since we may want it later # extract the version - pkginfo = rsp.xpath( - './/package-information[name = "junos"]/comment')[0].text - self.facts['version'] = re.findall(r'\[(.*)\]', pkginfo)[0] + # First try the tag present in >= 15.1 + swinfo = rsp.findtext('junos-version', default=None) + if not swinfo: + # For < 15.1, get version from the "junos" package. + pkginfo = rsp.xpath( + 'package-information[normalize-space(name)="junos"]/comment' + )[0].text + try: + swinfo = re.findall(r'\[(.*)\]', pkginfo)[0] + except: + swinfo = "0.0I0.0" + self.facts['version'] = swinfo # extract the host-name self.facts['hostname'] = rsp.xpath('.//host-name')[0].text From ce7ccca80310f45c4f4e897feabd479827d59961 Mon Sep 17 00:00:00 2001 From: Stacy Smith Date: Fri, 20 Nov 2015 10:36:19 -0700 Subject: [PATCH 2/2] The previous fix for issue #33 was incomplete. 1) It did not handle multi-RE platforms with the new (15.1+) XML tag for finding the Junos version. 2) It did not handle the # root shell prompt of FreeBSD 10+ based Junos releases. This commit addresses both of these issues. --- lib/netconify/facts.py | 4 ++-- lib/netconify/tty.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/netconify/facts.py b/lib/netconify/facts.py index 32ae64a..455d3b4 100644 --- a/lib/netconify/facts.py +++ b/lib/netconify/facts.py @@ -19,11 +19,11 @@ def version(self): # extract the version # First try the tag present in >= 15.1 - swinfo = rsp.findtext('junos-version', default=None) + swinfo = rsp.xpath('.//junos-version')[0].text if not swinfo: # For < 15.1, get version from the "junos" package. pkginfo = rsp.xpath( - 'package-information[normalize-space(name)="junos"]/comment' + './/package-information[normalize-space(name)="junos"]/comment' )[0].text try: swinfo = re.findall(r'\[(.*)\]', pkginfo)[0] diff --git a/lib/netconify/tty.py b/lib/netconify/tty.py index 1b5ac97..9aeda89 100644 --- a/lib/netconify/tty.py +++ b/lib/netconify/tty.py @@ -42,7 +42,7 @@ class Terminal(object): _re_pat_login, '(?Password:\s*$)', '(?Pogin incorrect)', - '(?P%\s*$)', + '(?P%|#\s*$)', '(?P[^\\-"]>\s*$)' ]