Don't inspect oslo.context
When creating an oslo.context we inspected the __init__ string to figure out if roles were part of the context. This was added in oslo.context 2.2 and there needed to be compatibility between old and new. Now that requirements specify oslo.context >= 2.9 we don't need this clause any more, and it is causing release issues with older versions of positional. Remove the inspection and rely on newer versions of oslo.context. Closes-Bug: #1620963 Change-Id: I2fcb4f1718ae5e5b50e26d9dee0e0df2f1e6cf72
This commit is contained in:
parent
d1040279f8
commit
6c814fefbc
@ -13,7 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import inspect
|
||||
import oslo_context
|
||||
from oslo_policy import policy
|
||||
|
||||
@ -29,23 +28,12 @@ class RequestContext(oslo_context.context.RequestContext):
|
||||
accesses the system, as well as additional request information.
|
||||
"""
|
||||
|
||||
def __init__(self, roles=None, policy_enforcer=None, project=None,
|
||||
**kwargs):
|
||||
def __init__(self, policy_enforcer=None, project=None, **kwargs):
|
||||
# prefer usage of 'project' instead of 'tenant'
|
||||
if project:
|
||||
kwargs['tenant'] = project
|
||||
self.project = project
|
||||
self.policy_enforcer = policy_enforcer or policy.Enforcer(CONF)
|
||||
|
||||
# NOTE(edtubill): oslo_context 2.2.0 now has a roles attribute in
|
||||
# the RequestContext. This will make sure of backwards compatibility
|
||||
# with past oslo_context versions.
|
||||
argspec = inspect.getargspec(super(RequestContext, self).__init__)
|
||||
if 'roles' in argspec.args:
|
||||
kwargs['roles'] = roles
|
||||
else:
|
||||
self.roles = roles or []
|
||||
|
||||
super(RequestContext, self).__init__(**kwargs)
|
||||
|
||||
def to_dict(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user