StormPath state: take backend as param for httperrors, deprecate requests_lib:True

This commit is contained in:
Ronald van Zantvoort 2016-11-08 00:07:43 +01:00
parent 5523417b52
commit 217523653f

View File

@ -9,6 +9,9 @@ Support for Stormpath.
from __future__ import absolute_import
import pprint
# Import salt libs
import salt.utils
def __virtual__():
'''
@ -54,10 +57,18 @@ def present(name, **kwargs):
Optional. Must be specified as a dict.
'''
# Because __opts__ is not available outside of functions
if __opts__.get('requests_lib', False):
backend = __opts__.get('backend', False)
if not backend and __opts__.get('requests_lib', False):
salt.utils.warn_until('Oxygen', '"requests_lib:True" has been replaced by "backend:requests", '
'please change your config')
backend = 'requests'
if backend == 'requests':
from requests.exceptions import HTTPError
else:
elif backend == 'urrlib2':
from urllib2 import HTTPError
else:
from tornado.httpclient import HTTPError
ret = {'name': name,
'changes': {},
@ -136,10 +147,18 @@ def absent(name, directory_id=None):
performance of this state.
'''
# Because __opts__ is not available outside of functions
if __opts__.get('requests_lib', False):
backend = __opts__.get('backend', False)
if not backend and __opts__.get('requests_lib', False):
salt.utils.warn_until('Oxygen', '"requests_lib:True" has been replaced by "backend:requests", '
'please change your config')
backend = 'requests'
if backend == 'requests':
from requests.exceptions import HTTPError
else:
elif backend == 'urrlib2':
from urllib2 import HTTPError
else:
from tornado.httpclient import HTTPError
ret = {'name': name,
'changes': {},