mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #26549 from rallytime/bp-26524
Back-port #26524 to 2015.5
This commit is contained in:
commit
4dbf61c5af
1 changed files with 13 additions and 0 deletions
|
@ -16,6 +16,7 @@ import hashlib
|
|||
import imp
|
||||
import json
|
||||
import logging
|
||||
import numbers
|
||||
import os
|
||||
import pprint
|
||||
import random
|
||||
|
@ -2020,9 +2021,21 @@ def compare_versions(ver1='', oper='==', ver2='', cmp_func=None):
|
|||
if cmp_result is None:
|
||||
return False
|
||||
|
||||
# Check if integer/long
|
||||
if not isinstance(cmp_result, numbers.Integral):
|
||||
log.error('The version comparison function did not return an '
|
||||
'integer/long.')
|
||||
return False
|
||||
|
||||
if oper == '!=':
|
||||
return cmp_result not in cmp_map['==']
|
||||
else:
|
||||
# Gracefully handle cmp_result not in (-1, 0, 1).
|
||||
if cmp_result < -1:
|
||||
cmp_result = -1
|
||||
elif cmp_result > 1:
|
||||
cmp_result = 1
|
||||
|
||||
return cmp_result in cmp_map[oper]
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue