Consistenly use jsonutils instead of json
Under Python 2.6 jsonutils imports simplejson, which can not be used together with json. Using jsonutils everywhere avoids the conflict. Change-Id: I25ddae130bd42d2788a2f8cf37986b7e0d851827 Closes-Bug: #1325235
This commit is contained in:
parent
1ca41569b3
commit
9a77787932
|
@ -12,8 +12,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
|
||||
from keystoneclient.common import cms
|
||||
import six
|
||||
|
||||
|
@ -25,6 +23,7 @@ from keystone.contrib import federation
|
|||
from keystone import exception
|
||||
from keystone.openstack.common.gettextutils import _
|
||||
from keystone.openstack.common import importutils
|
||||
from keystone.openstack.common import jsonutils
|
||||
from keystone.openstack.common import log
|
||||
from keystone.openstack.common import timeutils
|
||||
|
||||
|
@ -468,7 +467,7 @@ class Auth(controller.V3Controller):
|
|||
if not (expires and isinstance(expires, six.text_type)):
|
||||
t['expires'] = timeutils.isotime(expires)
|
||||
data = {'revoked': tokens}
|
||||
json_data = json.dumps(data)
|
||||
json_data = jsonutils.dumps(data)
|
||||
signed_text = cms.cms_sign_text(json_data,
|
||||
CONF.signing.certfile,
|
||||
CONF.signing.keyfile)
|
||||
|
|
|
@ -20,20 +20,20 @@ import calendar
|
|||
import collections
|
||||
import grp
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import pwd
|
||||
|
||||
import passlib.hash
|
||||
import six
|
||||
from six import moves
|
||||
|
||||
from keystone.common import config
|
||||
from keystone.common import environment
|
||||
from keystone import exception
|
||||
from keystone.openstack.common.gettextutils import _
|
||||
from keystone.openstack.common import jsonutils
|
||||
from keystone.openstack.common import log
|
||||
from keystone.openstack.common import strutils
|
||||
from six import moves
|
||||
|
||||
|
||||
CONF = config.CONF
|
||||
|
@ -78,7 +78,7 @@ def read_cached_file(filename, cache_info, reload_func=None):
|
|||
return cache_info['data']
|
||||
|
||||
|
||||
class SmarterEncoder(json.JSONEncoder):
|
||||
class SmarterEncoder(jsonutils.json.JSONEncoder):
|
||||
"""Help for JSON encoding dict-like objects."""
|
||||
def default(self, obj):
|
||||
if not isinstance(obj, dict) and hasattr(obj, 'iteritems'):
|
||||
|
@ -184,7 +184,7 @@ def check_output(*popenargs, **kwargs):
|
|||
|
||||
def get_blob_from_credential(credential):
|
||||
try:
|
||||
blob = json.loads(credential.blob)
|
||||
blob = jsonutils.loads(credential.blob)
|
||||
except (ValueError, TypeError):
|
||||
raise exception.ValidationError(
|
||||
message=_('Invalid blob in credential'))
|
||||
|
@ -200,9 +200,9 @@ def convert_ec2_to_v3_credential(ec2credential):
|
|||
return {'id': hash_access_key(ec2credential.access),
|
||||
'user_id': ec2credential.user_id,
|
||||
'project_id': ec2credential.tenant_id,
|
||||
'blob': json.dumps(blob),
|
||||
'blob': jsonutils.dumps(blob),
|
||||
'type': 'ec2',
|
||||
'extra': json.dumps({})}
|
||||
'extra': jsonutils.dumps({})}
|
||||
|
||||
|
||||
def convert_v3_to_ec2_credential(credential):
|
||||
|
|
|
@ -13,13 +13,13 @@
|
|||
# under the License.
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
|
||||
from keystone.common import controller
|
||||
from keystone.common import dependency
|
||||
from keystone.common import driver_hints
|
||||
from keystone import exception
|
||||
from keystone.openstack.common.gettextutils import _
|
||||
from keystone.openstack.common import jsonutils
|
||||
|
||||
|
||||
@dependency.requires('credential_api')
|
||||
|
@ -36,7 +36,7 @@ class CredentialV3(controller.V3Controller):
|
|||
# a credential reference.
|
||||
if ref.get('type', '').lower() == 'ec2':
|
||||
try:
|
||||
blob = json.loads(ref.get('blob'))
|
||||
blob = jsonutils.loads(ref.get('blob'))
|
||||
except (ValueError, TypeError):
|
||||
raise exception.ValidationError(
|
||||
message=_('Invalid blob in credential'))
|
||||
|
@ -53,7 +53,7 @@ class CredentialV3(controller.V3Controller):
|
|||
# tokens when authentication via ec2tokens happens
|
||||
if trust_id is not None:
|
||||
blob['trust_id'] = trust_id
|
||||
ret_ref['blob'] = json.dumps(blob)
|
||||
ret_ref['blob'] = jsonutils.dumps(blob)
|
||||
return ret_ref
|
||||
else:
|
||||
return super(CredentialV3, self)._assign_unique_id(ref)
|
||||
|
@ -73,7 +73,7 @@ class CredentialV3(controller.V3Controller):
|
|||
blob = ref.get('blob')
|
||||
if isinstance(blob, dict):
|
||||
new_ref = ref.copy()
|
||||
new_ref['blob'] = json.dumps(blob)
|
||||
new_ref['blob'] = jsonutils.dumps(blob)
|
||||
return new_ref
|
||||
else:
|
||||
return ref
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
# under the License.
|
||||
|
||||
import datetime
|
||||
import json
|
||||
|
||||
from keystoneclient.common import cms
|
||||
import six
|
||||
|
@ -24,6 +23,7 @@ from keystone.common import wsgi
|
|||
from keystone import config
|
||||
from keystone import exception
|
||||
from keystone.openstack.common.gettextutils import _
|
||||
from keystone.openstack.common import jsonutils
|
||||
from keystone.openstack.common import log
|
||||
from keystone.openstack.common import timeutils
|
||||
from keystone.token import core
|
||||
|
@ -430,7 +430,7 @@ class Auth(controller.V2Controller):
|
|||
if expires and isinstance(expires, datetime.datetime):
|
||||
t['expires'] = timeutils.isotime(expires)
|
||||
data = {'revoked': tokens}
|
||||
json_data = json.dumps(data)
|
||||
json_data = jsonutils.dumps(data)
|
||||
signed_text = cms.cms_sign_text(json_data,
|
||||
CONF.signing.certfile,
|
||||
CONF.signing.keyfile)
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import sys
|
||||
|
||||
import six
|
||||
|
@ -23,6 +22,7 @@ from keystone import config
|
|||
from keystone.contrib import federation
|
||||
from keystone import exception
|
||||
from keystone.openstack.common.gettextutils import _
|
||||
from keystone.openstack.common import jsonutils
|
||||
from keystone import token
|
||||
from keystone.token import provider
|
||||
|
||||
|
@ -240,7 +240,7 @@ class V3TokenDataHelper(object):
|
|||
|
||||
if access_token:
|
||||
filtered_roles = []
|
||||
authed_role_ids = json.loads(access_token['role_ids'])
|
||||
authed_role_ids = jsonutils.loads(access_token['role_ids'])
|
||||
all_roles = self.assignment_api.list_roles()
|
||||
for role in all_roles:
|
||||
for authed_role in authed_role_ids:
|
||||
|
|
|
@ -14,14 +14,13 @@
|
|||
|
||||
"""Keystone PKI Token Provider"""
|
||||
|
||||
import json
|
||||
|
||||
from keystoneclient.common import cms
|
||||
|
||||
from keystone.common import environment
|
||||
from keystone import config
|
||||
from keystone import exception
|
||||
from keystone.openstack.common.gettextutils import _
|
||||
from keystone.openstack.common import jsonutils
|
||||
from keystone.openstack.common import log
|
||||
from keystone.token.providers import common
|
||||
|
||||
|
@ -38,7 +37,7 @@ class Provider(common.BaseProvider):
|
|||
# produces unicode. This can be removed if the client returns
|
||||
# str()
|
||||
# TODO(ayoung): Make to a byte_str for Python3
|
||||
token_id = str(cms.cms_sign_token(json.dumps(token_data),
|
||||
token_id = str(cms.cms_sign_token(jsonutils.dumps(token_data),
|
||||
CONF.signing.certfile,
|
||||
CONF.signing.keyfile))
|
||||
return token_id
|
||||
|
|
Loading…
Reference in New Issue