From 29657f704bb9a80bb3584963b11d3c21fd1b31ec Mon Sep 17 00:00:00 2001 From: Ignatious Johnson Christopher Date: Fri, 3 Feb 2017 10:31:18 -0800 Subject: [PATCH] Ignore error when determining the package version if the pakcage is not installed and return None. Change-Id: Ife141f1fa08527e3e91c89086315d9f633174300 Closes-Bug: 1659550 --- fabfile/utils/fabos.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fabfile/utils/fabos.py b/fabfile/utils/fabos.py index bb56e2224..9efd42742 100644 --- a/fabfile/utils/fabos.py +++ b/fabfile/utils/fabos.py @@ -92,7 +92,10 @@ def get_release(pkg='contrail-install-packages', use_install_repo=False): cmd = "dpkg --info /opt/contrail/contrail_install_repo/%s*.deb | grep Version: | cut -d' ' -f3 | cut -d'-' -f1" %pkg else: cmd = "dpkg -s %s | grep Version: | cut -d' ' -f2 | cut -d'-' -f1" %pkg - pkg_ver = sudo(cmd) + # In case of nodes, where the expected pkg is not installed, Errors + # should be ignored and return None. + with settings(warn_only=True): + pkg_ver = sudo(cmd) if 'is not installed' in pkg_ver or 'is not available' in pkg_ver or 'No such file or directory' in pkg_ver: print "Package %s not installed." % pkg return None