fix-service-py-version-parsing-sles.patch 1.4 KB

12345678910111213141516171819202122232425262728293031
  1. From 1539d14a40d976b94724b14a17aff77f9a273a9a Mon Sep 17 00:00:00 2001
  2. From: Tim Serong <tserong@suse.com>
  3. Date: Mon, 18 Aug 2014 23:00:39 +1000
  4. Subject: [PATCH] Fix service.py version parsing for SLE 11
  5. "osrelease" on SLES 11 is in the form "11 SP3", i.e. major version, then a space, then service pack number. This means we can't just split on '.' to get the major number for comparisons. Rather we need to split on non-digit characters to handle both space-delimited and dot-delimited release formats (yuck).
  6. ---
  7. salt/modules/service.py | 7 ++++++-
  8. 1 file changed, 6 insertions(+), 1 deletion(-)
  9. diff --git a/salt/modules/service.py b/salt/modules/service.py
  10. index d581916..dab0817 100644
  11. --- a/salt/modules/service.py
  12. +++ b/salt/modules/service.py
  13. @@ -49,7 +49,12 @@ def __virtual__():
  14. # SUSE >=12.0 uses systemd
  15. if __grains__.get('os_family', '') == 'SUSE':
  16. try:
  17. - if int(__grains__.get('osrelease', '').split('.')[0]) >= 12:
  18. + # osrelease might be in decimal format (e.g. "12.1"), or for
  19. + # SLES might include service pack (e.g. "11 SP3"), so split on
  20. + # non-digit characters, and the zeroth element is the major
  21. + # number (it'd be so much simpler if it was always "X.Y"...)
  22. + import re
  23. + if int(re.split('\D+', __grains__.get('osrelease', ''))[0]) >= 12:
  24. return False
  25. except ValueError:
  26. return False
  27. --
  28. 2.0.3