mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Gate requests import
This commit is contained in:
parent
1fb84450f4
commit
d5b15fc6ce
16 changed files with 151 additions and 17 deletions
|
@ -38,9 +38,14 @@ import base64
|
|||
from hashlib import sha1
|
||||
|
||||
# Import 3rd-party libs
|
||||
import requests
|
||||
from salt.ext.six.moves.urllib.parse import quote as _quote # pylint: disable=import-error,no-name-in-module
|
||||
|
||||
try:
|
||||
import requests
|
||||
HAS_REQUESTS = True
|
||||
except ImportError:
|
||||
HAS_REQUESTS = False
|
||||
|
||||
# Import salt cloud libs
|
||||
import salt.utils.cloud
|
||||
import salt.config as config
|
||||
|
@ -71,6 +76,9 @@ def __virtual__():
|
|||
'''
|
||||
Check for aliyun configurations
|
||||
'''
|
||||
if not HAS_REQUESTS:
|
||||
return False
|
||||
|
||||
if get_configured_provider() is False:
|
||||
return False
|
||||
|
||||
|
|
|
@ -28,9 +28,14 @@ import copy
|
|||
import time
|
||||
import json
|
||||
import pprint
|
||||
import requests
|
||||
import logging
|
||||
|
||||
try:
|
||||
import requests
|
||||
HAS_REQUESTS = True
|
||||
except ImportError:
|
||||
HAS_REQUESTS = False
|
||||
|
||||
# Import salt cloud libs
|
||||
import salt.utils.cloud
|
||||
import salt.config as config
|
||||
|
@ -51,6 +56,9 @@ def __virtual__():
|
|||
'''
|
||||
Check for DigitalOcean configurations
|
||||
'''
|
||||
if not HAS_REQUESTS:
|
||||
return False
|
||||
|
||||
if get_configured_provider() is False:
|
||||
return False
|
||||
|
||||
|
|
|
@ -26,9 +26,14 @@ import copy
|
|||
import time
|
||||
import json
|
||||
import pprint
|
||||
import requests
|
||||
import logging
|
||||
|
||||
try:
|
||||
import requests
|
||||
HAS_REQUESTS = True
|
||||
except ImportError:
|
||||
HAS_REQUESTS = False
|
||||
|
||||
# Import salt cloud libs
|
||||
import salt.utils.cloud
|
||||
import salt.config as config
|
||||
|
@ -51,6 +56,9 @@ def __virtual__():
|
|||
'''
|
||||
Check for DigitalOcean configurations
|
||||
'''
|
||||
if not HAS_REQUESTS:
|
||||
return False
|
||||
|
||||
if get_configured_provider() is False:
|
||||
return False
|
||||
|
||||
|
|
|
@ -82,10 +82,15 @@ import yaml
|
|||
# Import 3rd-party libs
|
||||
|
||||
# pylint: disable=import-error,no-name-in-module,redefined-builtin
|
||||
import requests
|
||||
import salt.ext.six as six
|
||||
from salt.ext.six.moves import map, range, zip
|
||||
from salt.ext.six.moves.urllib.parse import urlparse as _urlparse, urlencode as _urlencode
|
||||
|
||||
try:
|
||||
import requests
|
||||
HAS_REQUESTS = True
|
||||
except ImportError:
|
||||
HAS_REQUESTS = False
|
||||
# pylint: enable=import-error,no-name-in-module
|
||||
|
||||
# Import libs for talking to the EC2 API
|
||||
|
@ -176,6 +181,9 @@ def __virtual__():
|
|||
'''
|
||||
Set up the libcloud functions and check for EC2 configurations
|
||||
'''
|
||||
if not HAS_REQUESTS:
|
||||
return False
|
||||
|
||||
if get_configured_provider() is False:
|
||||
return False
|
||||
|
||||
|
|
|
@ -22,11 +22,16 @@ import json
|
|||
import logging
|
||||
|
||||
# Import 3rd-party Libs
|
||||
import requests
|
||||
from requests.exceptions import ConnectionError
|
||||
# pylint: disable=import-error,no-name-in-module
|
||||
from salt.ext.six.moves.urllib.parse import urljoin as _urljoin
|
||||
from salt.ext.six.moves import range
|
||||
|
||||
try:
|
||||
import requests
|
||||
HAS_REQUESTS = True
|
||||
except ImportError:
|
||||
HAS_REQUESTS = False
|
||||
# pylint: enable=import-error,no-name-in-module
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
@ -40,6 +45,9 @@ def __virtual__():
|
|||
|
||||
:return: The virtual name of the module.
|
||||
'''
|
||||
if not HAS_REQUESTS:
|
||||
return False
|
||||
|
||||
return __virtualname__
|
||||
|
||||
|
||||
|
|
|
@ -23,10 +23,15 @@ import logging
|
|||
|
||||
# Import 3rd-party libs
|
||||
import json
|
||||
import requests
|
||||
from requests.exceptions import ConnectionError
|
||||
# pylint: disable=import-error,no-name-in-module,redefined-builtin
|
||||
from salt.ext.six.moves.urllib.parse import urljoin as _urljoin
|
||||
|
||||
try:
|
||||
import requests
|
||||
HAS_REQUESTS = True
|
||||
except ImportError:
|
||||
HAS_REQUESTS = False
|
||||
# pylint: enable=import-error,no-name-in-module
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
@ -65,6 +70,9 @@ def __virtual__():
|
|||
|
||||
:return: The virtual name of the module.
|
||||
'''
|
||||
if not HAS_REQUESTS:
|
||||
return False
|
||||
|
||||
return __virtualname__
|
||||
|
||||
|
||||
|
|
|
@ -7,19 +7,31 @@ Wrapper around Server Density API
|
|||
'''
|
||||
from __future__ import absolute_import
|
||||
|
||||
import requests
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
from salt.ext.six.moves import map
|
||||
try:
|
||||
import requests
|
||||
HAS_REQUESTS = True
|
||||
except ImportError:
|
||||
HAS_REQUESTS = False
|
||||
|
||||
from salt.ext.six.moves import map
|
||||
from salt.exceptions import CommandExecutionError
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
Requires requests
|
||||
'''
|
||||
if not HAS_REQUESTS:
|
||||
return False
|
||||
|
||||
|
||||
def get_sd_auth(val, sd_auth_pillar_name='serverdensity'):
|
||||
'''
|
||||
Returns requested Server Density authentication value from pillar.
|
||||
|
|
|
@ -21,11 +21,17 @@ from __future__ import absolute_import
|
|||
import logging
|
||||
|
||||
# Import 3rd-party libs
|
||||
import requests
|
||||
from requests.exceptions import ConnectionError
|
||||
# pylint: disable=import-error,no-name-in-module,redefined-builtin
|
||||
from salt.ext.six.moves.urllib.parse import urljoin as _urljoin
|
||||
from salt.ext.six.moves import range
|
||||
|
||||
try:
|
||||
import requests
|
||||
from requests.exceptions import ConnectionError
|
||||
HAS_REQUESTS = True
|
||||
except ImportError:
|
||||
HAS_REQUESTS = False
|
||||
|
||||
# pylint: enable=import-error,no-name-in-module
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
@ -38,6 +44,9 @@ def __virtual__():
|
|||
|
||||
:return: The virtual name of the module.
|
||||
'''
|
||||
if not HAS_REQUESTS:
|
||||
return False
|
||||
|
||||
return __virtualname__
|
||||
|
||||
|
||||
|
|
|
@ -42,8 +42,12 @@ from __future__ import absolute_import
|
|||
|
||||
# Import python libs
|
||||
import logging
|
||||
import requests
|
||||
|
||||
try:
|
||||
import requests
|
||||
HAS_REQUESTS = True
|
||||
except ImportError:
|
||||
HAS_REQUESTS = False
|
||||
|
||||
__opts__ = {'foreman.url': 'http://foreman/api',
|
||||
'foreman.user': 'admin',
|
||||
|
@ -61,6 +65,14 @@ __opts__ = {'foreman.url': 'http://foreman/api',
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
Only return if all the modules are available
|
||||
'''
|
||||
if not HAS_REQUESTS:
|
||||
return False
|
||||
|
||||
|
||||
def ext_pillar(minion_id,
|
||||
pillar, # pylint: disable=W0613
|
||||
key=None,
|
||||
|
|
|
@ -281,6 +281,12 @@ import re
|
|||
from os.path import isfile, join
|
||||
from salt.ext.six.moves import input
|
||||
|
||||
try:
|
||||
import requests
|
||||
HAS_REQUESTS = True
|
||||
except ImportError:
|
||||
HAS_REQUESTS = False
|
||||
|
||||
# Import Salt libs
|
||||
import salt.utils
|
||||
|
||||
|
@ -342,6 +348,9 @@ def __virtual__():
|
|||
'''
|
||||
Only return if all the modules are available
|
||||
'''
|
||||
if not HAS_REQUESTS:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
|
|
@ -9,12 +9,25 @@ Requests is not a hard dependency for Salt
|
|||
from __future__ import absolute_import
|
||||
|
||||
# Import python libs
|
||||
import requests
|
||||
try:
|
||||
import requests
|
||||
HAS_REQUESTS = True
|
||||
except ImportError:
|
||||
HAS_REQUESTS = False
|
||||
|
||||
HAS_REST_EXAMPLE = True
|
||||
|
||||
__proxyenabled__ = ['rest_sample']
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
Only return if all the modules are available
|
||||
'''
|
||||
if not HAS_REQUESTS:
|
||||
return False
|
||||
|
||||
|
||||
class Proxyconn(object):
|
||||
'''
|
||||
Interface with the REST sample web service (rest.py at
|
||||
|
|
|
@ -74,7 +74,12 @@ import pprint
|
|||
import logging
|
||||
|
||||
# Import 3rd-party libs
|
||||
import requests
|
||||
try:
|
||||
import requests
|
||||
HAS_REQUESTS = True
|
||||
except ImportError:
|
||||
HAS_REQUESTS = False
|
||||
|
||||
from requests.exceptions import ConnectionError
|
||||
# pylint: disable=import-error
|
||||
from salt.ext.six.moves.urllib.parse import urljoin as _urljoin # pylint: disable=import-error,no-name-in-module
|
||||
|
@ -129,6 +134,9 @@ def __virtual__():
|
|||
|
||||
:return: The virtual name of the module.
|
||||
'''
|
||||
if not HAS_REQUESTS:
|
||||
return False
|
||||
|
||||
return __virtualname__
|
||||
|
||||
|
||||
|
|
|
@ -62,7 +62,12 @@ import pprint
|
|||
import logging
|
||||
|
||||
# Import 3rd-party libs
|
||||
import requests
|
||||
try:
|
||||
import requests
|
||||
HAS_REQUESTS = True
|
||||
except ImportError:
|
||||
HAS_REQUESTS = False
|
||||
|
||||
from requests.exceptions import ConnectionError
|
||||
# pylint: disable=import-error
|
||||
from salt.ext.six.moves.urllib.parse import urljoin as _urljoin # pylint: disable=import-error,no-name-in-module
|
||||
|
@ -113,6 +118,9 @@ def __virtual__():
|
|||
|
||||
:return: The virtual name of the module.
|
||||
'''
|
||||
if not HAS_REQUESTS:
|
||||
return False
|
||||
|
||||
return __virtualname__
|
||||
|
||||
|
||||
|
|
|
@ -24,7 +24,11 @@ import salt.utils.xmlutil as xml
|
|||
from salt._compat import ElementTree as ET
|
||||
|
||||
# Import 3rd-party libs
|
||||
import requests
|
||||
try:
|
||||
import requests
|
||||
HAS_REQUESTS = True # pylint: disable=W0612
|
||||
except ImportError:
|
||||
HAS_REQUESTS = False # pylint: disable=W0612
|
||||
# pylint: disable=import-error,redefined-builtin,no-name-in-module
|
||||
from salt.ext.six.moves import map, range, zip
|
||||
from salt.ext.six.moves.urllib.parse import urlencode, urlparse
|
||||
|
|
|
@ -10,10 +10,14 @@ from __future__ import absolute_import
|
|||
import json
|
||||
import logging
|
||||
import time
|
||||
import requests
|
||||
import pprint
|
||||
from salt.ext.six.moves import range
|
||||
import salt.ext.six as six
|
||||
try:
|
||||
import requests
|
||||
HAS_REQUESTS = True # pylint: disable=W0612
|
||||
except ImportError:
|
||||
HAS_REQUESTS = False # pylint: disable=W0612
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -14,7 +14,11 @@ import hmac
|
|||
import logging
|
||||
|
||||
# Import 3rd-party libs
|
||||
import requests
|
||||
try:
|
||||
import requests
|
||||
HAS_REQUESTS = True # pylint: disable=W0612
|
||||
except ImportError:
|
||||
HAS_REQUESTS = False # pylint: disable=W0612
|
||||
from salt.ext.six.moves.urllib.parse import urlencode # pylint: disable=no-name-in-module,import-error
|
||||
|
||||
# Import Salt libs
|
||||
|
@ -58,6 +62,9 @@ def query(key, keyid, method='GET', params=None, headers=None,
|
|||
these will not match Amazon's S3 wildcard certificates. Certificate
|
||||
verification is enabled by default.
|
||||
'''
|
||||
if not HAS_REQUESTS:
|
||||
log.error('There was an error: requests is required for s3 access')
|
||||
|
||||
if not headers:
|
||||
headers = {}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue