mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Properly parse a PSQL server version, even beta versions. Fixes #6352.
This commit is contained in:
parent
d64dfdc70a
commit
0180c7b1fd
@ -19,6 +19,7 @@ Module to provide Postgres compatibility to salt.
|
|||||||
|
|
||||||
# Import python libs
|
# Import python libs
|
||||||
import datetime
|
import datetime
|
||||||
|
import distutils
|
||||||
import pipes
|
import pipes
|
||||||
import logging
|
import logging
|
||||||
import csv
|
import csv
|
||||||
@ -101,6 +102,18 @@ def version(user=None, host=None, port=None, maintenance_db=None,
|
|||||||
return line
|
return line
|
||||||
|
|
||||||
|
|
||||||
|
def _parsed_version(user=None, host=None, port=None, maintenance_db=None,
|
||||||
|
password=None, runas=None):
|
||||||
|
'''
|
||||||
|
Returns the sever version properly parsed and int casted for internal usage
|
||||||
|
'''
|
||||||
|
|
||||||
|
psql_version = version(
|
||||||
|
user, host, port, maintenance_db, password, runas
|
||||||
|
)
|
||||||
|
return distutils.version.LooseVersion(psql_version).version
|
||||||
|
|
||||||
|
|
||||||
def _connection_defaults(user=None, host=None, port=None, maintenance_db=None,
|
def _connection_defaults(user=None, host=None, port=None, maintenance_db=None,
|
||||||
password=None):
|
password=None):
|
||||||
'''
|
'''
|
||||||
@ -362,13 +375,13 @@ def user_list(user=None, host=None, port=None, maintenance_db=None,
|
|||||||
|
|
||||||
ret = {}
|
ret = {}
|
||||||
|
|
||||||
ver = version(user=user,
|
ver = _parsed_version(user=user,
|
||||||
host=host,
|
host=host,
|
||||||
port=port,
|
port=port,
|
||||||
maintenance_db=maintenance_db,
|
maintenance_db=maintenance_db,
|
||||||
password=password,
|
password=password,
|
||||||
runas=runas).split('.')
|
runas=runas)
|
||||||
if len(ver) >= 2 and int(ver[0]) >= 9 and int(ver[1]) >= 1:
|
if len(ver) >= 2 and ver[0] >= 9 and ver[1] >= 1:
|
||||||
query = (
|
query = (
|
||||||
'SELECT rolname as "name", rolsuper as "superuser", '
|
'SELECT rolname as "name", rolsuper as "superuser", '
|
||||||
'rolinherit as "inherits privileges", '
|
'rolinherit as "inherits privileges", '
|
||||||
|
Loading…
Reference in New Issue
Block a user