diff --git a/aodh/api/controllers/v2/base.py b/aodh/api/controllers/v2/base.py index fd1b49fa4..5e152c6d3 100644 --- a/aodh/api/controllers/v2/base.py +++ b/aodh/api/controllers/v2/base.py @@ -21,6 +21,7 @@ import ast import datetime import functools +import inspect from oslo_utils import strutils from oslo_utils import timeutils @@ -29,7 +30,6 @@ import wsme from wsme import types as wtypes from aodh.i18n import _ -from aodh.utils import get_func_valid_keys operation_kind = ('lt', 'le', 'eq', 'ne', 'ge', 'gt') @@ -87,7 +87,7 @@ class Base(wtypes.DynamicBase): return cls(links=links, **(m.as_dict())) def as_dict(self, db_model): - valid_keys = get_func_valid_keys(db_model.__init__) + valid_keys = inspect.getfullargspec(db_model.__init__)[0] if 'self' in valid_keys: valid_keys.remove('self') return self.as_dict_from_keys(valid_keys) diff --git a/aodh/api/controllers/v2/utils.py b/aodh/api/controllers/v2/utils.py index 8923f404e..ebf8a9ce8 100644 --- a/aodh/api/controllers/v2/utils.py +++ b/aodh/api/controllers/v2/utils.py @@ -20,6 +20,7 @@ import copy import datetime +import inspect from oslo_utils import timeutils import pecan @@ -28,7 +29,6 @@ import wsme from aodh.api.controllers.v2 import base from aodh.api import rbac -from aodh.utils import get_func_valid_keys def get_auth_project(on_behalf_of=None): @@ -63,7 +63,7 @@ def sanitize_query(query, db_func, on_behalf_of=None): _verify_query_segregation(q, auth_project) proj_q = [i for i in q if i.field == 'project_id'] - valid_keys = get_func_valid_keys(db_func) + valid_keys = inspect.getfullargspec(db_func)[0] if not proj_q and 'on_behalf_of' not in valid_keys: # The user is restricted, but they didn't specify a project # so add it for them. @@ -112,7 +112,7 @@ def validate_query(query, db_func, internal_keys=None, internal_keys = internal_keys or [] _verify_query_segregation(query) - valid_keys = get_func_valid_keys(db_func) + valid_keys = inspect.getfullargspec(db_func)[0] if 'alarm_type' in valid_keys: valid_keys.remove('alarm_type') valid_keys.append('type') diff --git a/aodh/storage/base.py b/aodh/storage/base.py index a095379cd..edef4dd50 100644 --- a/aodh/storage/base.py +++ b/aodh/storage/base.py @@ -15,9 +15,9 @@ """Base classes for storage engines """ import copy +import inspect import aodh -from aodh.utils import get_func_valid_keys def update_nested(original_dict, updates): @@ -62,7 +62,7 @@ class Model: @classmethod def get_field_names(cls): - fields = get_func_valid_keys(cls.__init__) + fields = inspect.getfullargspec(cls.__init__)[0] return set(fields) - {"self"} diff --git a/aodh/utils.py b/aodh/utils.py deleted file mode 100644 index 20fdc91eb..000000000 --- a/aodh/utils.py +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright 2019 - Nokia Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -import inspect - - -def get_func_valid_keys(func): - return inspect.getfullargspec(func)[0]