Skip to content

Commit

Permalink
Ignore error when determining the package version
Browse files Browse the repository at this point in the history
if the pakcage is not installed and return None.

Change-Id: Ife141f1fa08527e3e91c89086315d9f633174300
Closes-Bug: 1659550
  • Loading branch information
cijohnson committed Feb 3, 2017
1 parent 2f8266a commit c6e5c24
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fabfile/utils/fabos.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,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
Expand Down

0 comments on commit c6e5c24

Please sign in to comment.