Use the requestsexceptions library

Change-Id: Idf277388a006ab0d0c6071f77bce3ca6879ee562
This commit is contained in:
James E. Blair 2015-11-03 09:33:40 -08:00 committed by Monty Taylor
parent 93d8b79900
commit 2b45428143
3 changed files with 10 additions and 24 deletions

View File

@ -5,6 +5,7 @@ decorator
jsonpatch
ipaddress
os-client-config>=1.9.0
requestsexceptions>=1.1.1
six
keystoneauth1>=1.0.0

View File

@ -13,32 +13,24 @@
# limitations under the License.
import logging
import warnings
import keystoneauth1.exceptions
import os_client_config
import pbr.version
# Disable the Rackspace warnings about deprecated certificates. We are aware
import warnings
try:
from requests.packages.urllib3.exceptions import SubjectAltNameWarning
except ImportError:
try:
from urllib3.exceptions import SubjectAltNameWarning
except ImportError:
SubjectAltNameWarning = None
if SubjectAltNameWarning:
warnings.filterwarnings('ignore', category=SubjectAltNameWarning)
import requestsexceptions
from shade.exc import * # noqa
from shade.openstackcloud import OpenStackCloud
from shade.operatorcloud import OperatorCloud
from shade import _log
__version__ = pbr.version.VersionInfo('shade').version_string()
if requestsexceptions.SubjectAltNameWarning:
warnings.filterwarnings(
'ignore', category=requestsexceptions.SubjectAltNameWarning)
def simple_logging(debug=False):
if debug:

View File

@ -21,6 +21,7 @@ import time
import warnings
from dogpile import cache
import requestsexceptions
from cinderclient.v1 import client as cinder_client
from designateclient.v1 import Client as designate_client
@ -49,15 +50,6 @@ from shade import task_manager
from shade import _tasks
from shade import _utils
# Importing these for later but not disabling for now
try:
from requests.packages.urllib3.exceptions import InsecureRequestWarning
except ImportError:
try:
from urllib3.exceptions import InsecureRequestWarning
except ImportError:
InsecureRequestWarning = None
OBJECT_MD5_KEY = 'x-object-meta-x-shade-md5'
OBJECT_SHA256_KEY = 'x-object-meta-x-shade-sha256'
IMAGE_MD5_KEY = 'owner_specified.shade.md5'
@ -172,7 +164,8 @@ class OpenStackCloud(object):
if not self.verify:
self.log.debug(
"Turning off Insecure SSL warnings since verify=False")
warnings.filterwarnings('ignore', category=InsecureRequestWarning)
category = requestsexceptions.InsecureRequestWarning
warnings.filterwarnings('ignore', category)
self._servers = []
self._servers_time = 0