From e6f5c28e0ebdac8e9b00c16ad9917107648e8b8f Mon Sep 17 00:00:00 2001 From: Aaron-DH Date: Sun, 12 Feb 2017 16:42:33 +0800 Subject: [PATCH] Remove deprecated APIs and method in cloudkitty Remove deprecated model `ModuleEnableState` and use `ModuleInfo` instead. Also remove code of billingController, billingProcess and billing datemodels. Change-Id: Ie229edf736ef80b70d66649a1b26d68c69758e45 --- cloudkitty/api/v1/controllers/billing.py | 41 ------------ cloudkitty/api/v1/datamodels/billing.py | 31 --------- cloudkitty/billing/__init__.py | 38 ----------- cloudkitty/billing/hash/__init__.py | 31 --------- .../billing/hash/controllers/__init__.py | 31 --------- cloudkitty/billing/hash/controllers/field.py | 18 ----- cloudkitty/billing/hash/controllers/group.py | 18 ----- .../billing/hash/controllers/mapping.py | 18 ----- cloudkitty/billing/hash/controllers/root.py | 18 ----- .../billing/hash/controllers/service.py | 18 ----- .../billing/hash/datamodels/__init__.py | 31 --------- cloudkitty/billing/hash/datamodels/field.py | 18 ----- cloudkitty/billing/hash/datamodels/group.py | 18 ----- cloudkitty/billing/hash/datamodels/mapping.py | 18 ----- cloudkitty/billing/hash/datamodels/service.py | 18 ----- cloudkitty/billing/hash/db/__init__.py | 31 --------- cloudkitty/billing/hash/db/api.py | 18 ----- .../billing/hash/db/sqlalchemy/__init__.py | 31 --------- cloudkitty/billing/hash/db/sqlalchemy/api.py | 18 ----- .../billing/hash/db/sqlalchemy/migration.py | 18 ----- .../billing/hash/db/sqlalchemy/models.py | 18 ----- cloudkitty/billing/noop.py | 18 ----- cloudkitty/collector/meta.py | 2 +- cloudkitty/db/api.py | 39 +++++------ cloudkitty/db/sqlalchemy/api.py | 67 ++++++++----------- cloudkitty/rating/__init__.py | 2 +- cloudkitty/tests/test_rating.py | 6 +- ...ecated-api-endpoints-26606e322b8a225e.yaml | 5 ++ 28 files changed, 56 insertions(+), 582 deletions(-) delete mode 100644 cloudkitty/api/v1/controllers/billing.py delete mode 100644 cloudkitty/api/v1/datamodels/billing.py delete mode 100644 cloudkitty/billing/__init__.py delete mode 100644 cloudkitty/billing/hash/__init__.py delete mode 100644 cloudkitty/billing/hash/controllers/__init__.py delete mode 100644 cloudkitty/billing/hash/controllers/field.py delete mode 100644 cloudkitty/billing/hash/controllers/group.py delete mode 100644 cloudkitty/billing/hash/controllers/mapping.py delete mode 100644 cloudkitty/billing/hash/controllers/root.py delete mode 100644 cloudkitty/billing/hash/controllers/service.py delete mode 100644 cloudkitty/billing/hash/datamodels/__init__.py delete mode 100644 cloudkitty/billing/hash/datamodels/field.py delete mode 100644 cloudkitty/billing/hash/datamodels/group.py delete mode 100644 cloudkitty/billing/hash/datamodels/mapping.py delete mode 100644 cloudkitty/billing/hash/datamodels/service.py delete mode 100644 cloudkitty/billing/hash/db/__init__.py delete mode 100644 cloudkitty/billing/hash/db/api.py delete mode 100644 cloudkitty/billing/hash/db/sqlalchemy/__init__.py delete mode 100644 cloudkitty/billing/hash/db/sqlalchemy/api.py delete mode 100644 cloudkitty/billing/hash/db/sqlalchemy/migration.py delete mode 100644 cloudkitty/billing/hash/db/sqlalchemy/models.py delete mode 100644 cloudkitty/billing/noop.py create mode 100644 releasenotes/notes/remove-deprecated-api-endpoints-26606e322b8a225e.yaml diff --git a/cloudkitty/api/v1/controllers/billing.py b/cloudkitty/api/v1/controllers/billing.py deleted file mode 100644 index 8df0fd79..00000000 --- a/cloudkitty/api/v1/controllers/billing.py +++ /dev/null @@ -1,41 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2014 Objectif Libre -# -# 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. -# -# @author: Stéphane Albert -# -import warnings - -from cloudkitty.api.v1.controllers import rating as rating_api -from cloudkitty.api.v1.controllers.rating import ModulesController # noqa -from cloudkitty.api.v1.controllers.rating import ModulesExposer # noqa -from cloudkitty.api.v1.controllers.rating import UnconfigurableController # noqa - - -def deprecated(): - warnings.warn( - ('The billing controllers are deprecated. ' - 'Please use rating\'s one instead.'), - DeprecationWarning, - stacklevel=3) - - -deprecated() - - -class BillingController(rating_api.RatingController): - """The BillingController is exposed by the API. - - Deprecated, replaced by the RatingController. - """ diff --git a/cloudkitty/api/v1/datamodels/billing.py b/cloudkitty/api/v1/datamodels/billing.py deleted file mode 100644 index 2c1c476d..00000000 --- a/cloudkitty/api/v1/datamodels/billing.py +++ /dev/null @@ -1,31 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2014 Objectif Libre -# -# 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. -# -# @author: Stéphane Albert -# -import warnings - -from cloudkitty.api.v1.datamodels.rating import * # noqa - - -def deprecated(): - warnings.warn( - ('The billing datamodels are deprecated. ' - 'Please use rating\'s one instead.'), - DeprecationWarning, - stacklevel=3) - - -deprecated() diff --git a/cloudkitty/billing/__init__.py b/cloudkitty/billing/__init__.py deleted file mode 100644 index 8e682254..00000000 --- a/cloudkitty/billing/__init__.py +++ /dev/null @@ -1,38 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2014 Objectif Libre -# -# 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. -# -# @author: Stéphane Albert -# -import warnings - -from cloudkitty import rating - - -def deprecated(): - warnings.warn( - ('The billing processors are deprecated. ' - 'Please use rating\'s one instead.'), - DeprecationWarning, - stacklevel=3) - - -deprecated() - - -class BillingProcessorBase(rating.RatingProcessorBase): - """Provides the Cloudkitty integration code to the billing processors. - - Deprecated, please use RatingProcessorBase. - """ diff --git a/cloudkitty/billing/hash/__init__.py b/cloudkitty/billing/hash/__init__.py deleted file mode 100644 index 5ade53de..00000000 --- a/cloudkitty/billing/hash/__init__.py +++ /dev/null @@ -1,31 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2014 Objectif Libre -# -# 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. -# -# @author: Stéphane Albert -# -import warnings - -from cloudkitty.api.v1.datamodels.rating import * # noqa - - -def deprecated(): - warnings.warn( - ('The hashmap billing processors are deprecated. ' - 'Please use rating\'s one instead.'), - DeprecationWarning, - stacklevel=3) - - -deprecated() diff --git a/cloudkitty/billing/hash/controllers/__init__.py b/cloudkitty/billing/hash/controllers/__init__.py deleted file mode 100644 index ea8c2df3..00000000 --- a/cloudkitty/billing/hash/controllers/__init__.py +++ /dev/null @@ -1,31 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2015 Objectif Libre -# -# 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. -# -# @author: Stéphane Albert -# -import warnings - -from cloudkitty.rating.hash.controllers import * # noqa - - -def deprecated(): - warnings.warn( - ('The hashmap billing controllers are deprecated. ' - 'Please use rating\'s one instead.'), - DeprecationWarning, - stacklevel=3) - - -deprecated() diff --git a/cloudkitty/billing/hash/controllers/field.py b/cloudkitty/billing/hash/controllers/field.py deleted file mode 100644 index 53a1d466..00000000 --- a/cloudkitty/billing/hash/controllers/field.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2015 Objectif Libre -# -# 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. -# -# @author: Stéphane Albert -# -from cloudkitty.rating.hash.controllers.field import * # noqa diff --git a/cloudkitty/billing/hash/controllers/group.py b/cloudkitty/billing/hash/controllers/group.py deleted file mode 100644 index 4fd894bd..00000000 --- a/cloudkitty/billing/hash/controllers/group.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2015 Objectif Libre -# -# 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. -# -# @author: Stéphane Albert -# -from cloudkitty.rating.hash.controllers.group import * # noqa diff --git a/cloudkitty/billing/hash/controllers/mapping.py b/cloudkitty/billing/hash/controllers/mapping.py deleted file mode 100644 index 26194615..00000000 --- a/cloudkitty/billing/hash/controllers/mapping.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2015 Objectif Libre -# -# 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. -# -# @author: Stéphane Albert -# -from cloudkitty.rating.hash.controllers.mapping import * # noqa diff --git a/cloudkitty/billing/hash/controllers/root.py b/cloudkitty/billing/hash/controllers/root.py deleted file mode 100644 index 4785d2b4..00000000 --- a/cloudkitty/billing/hash/controllers/root.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2015 Objectif Libre -# -# 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. -# -# @author: Stéphane Albert -# -from cloudkitty.rating.hash.controllers.root import * # noqa diff --git a/cloudkitty/billing/hash/controllers/service.py b/cloudkitty/billing/hash/controllers/service.py deleted file mode 100644 index 38df1708..00000000 --- a/cloudkitty/billing/hash/controllers/service.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2015 Objectif Libre -# -# 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. -# -# @author: Stéphane Albert -# -from cloudkitty.rating.hash.controllers.service import * # noqa diff --git a/cloudkitty/billing/hash/datamodels/__init__.py b/cloudkitty/billing/hash/datamodels/__init__.py deleted file mode 100644 index 768d668f..00000000 --- a/cloudkitty/billing/hash/datamodels/__init__.py +++ /dev/null @@ -1,31 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2015 Objectif Libre -# -# 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. -# -# @author: Stéphane Albert -# -import warnings - -from cloudkitty.rating.hash.datamodels import * # noqa - - -def deprecated(): - warnings.warn( - ('The hashmap billing datamodels are deprecated. ' - 'Please use rating\'s one instead.'), - DeprecationWarning, - stacklevel=3) - - -deprecated() diff --git a/cloudkitty/billing/hash/datamodels/field.py b/cloudkitty/billing/hash/datamodels/field.py deleted file mode 100644 index 59642b30..00000000 --- a/cloudkitty/billing/hash/datamodels/field.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2015 Objectif Libre -# -# 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. -# -# @author: Stéphane Albert -# -from cloudkitty.rating.hash.datamodels.field import * # noqa diff --git a/cloudkitty/billing/hash/datamodels/group.py b/cloudkitty/billing/hash/datamodels/group.py deleted file mode 100644 index b91eca4e..00000000 --- a/cloudkitty/billing/hash/datamodels/group.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2015 Objectif Libre -# -# 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. -# -# @author: Stéphane Albert -# -from cloudkitty.rating.hash.datamodels.group import * # noqa diff --git a/cloudkitty/billing/hash/datamodels/mapping.py b/cloudkitty/billing/hash/datamodels/mapping.py deleted file mode 100644 index b55c6790..00000000 --- a/cloudkitty/billing/hash/datamodels/mapping.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2015 Objectif Libre -# -# 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. -# -# @author: Stéphane Albert -# -from cloudkitty.rating.hash.datamodels.mapping import * # noqa diff --git a/cloudkitty/billing/hash/datamodels/service.py b/cloudkitty/billing/hash/datamodels/service.py deleted file mode 100644 index 74c1face..00000000 --- a/cloudkitty/billing/hash/datamodels/service.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2015 Objectif Libre -# -# 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. -# -# @author: Stéphane Albert -# -from cloudkitty.rating.hash.datamodels.service import * # noqa diff --git a/cloudkitty/billing/hash/db/__init__.py b/cloudkitty/billing/hash/db/__init__.py deleted file mode 100644 index 68e8a560..00000000 --- a/cloudkitty/billing/hash/db/__init__.py +++ /dev/null @@ -1,31 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2014 Objectif Libre -# -# 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. -# -# @author: Stéphane Albert -# -import warnings - -from cloudkitty.rating.hash.db import * # noqa - - -def deprecated(): - warnings.warn( - ('The hashmap db API is deprecated. ' - 'Please use rating\'s one instead.'), - DeprecationWarning, - stacklevel=3) - - -deprecated() diff --git a/cloudkitty/billing/hash/db/api.py b/cloudkitty/billing/hash/db/api.py deleted file mode 100644 index 050383c3..00000000 --- a/cloudkitty/billing/hash/db/api.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2014 Objectif Libre -# -# 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. -# -# @author: Stéphane Albert -# -from cloudkitty.rating.hash.db.api import * # noqa diff --git a/cloudkitty/billing/hash/db/sqlalchemy/__init__.py b/cloudkitty/billing/hash/db/sqlalchemy/__init__.py deleted file mode 100644 index 6a66454f..00000000 --- a/cloudkitty/billing/hash/db/sqlalchemy/__init__.py +++ /dev/null @@ -1,31 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2014 Objectif Libre -# -# 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. -# -# @author: Stéphane Albert -# -import warnings - -from cloudkitty.rating.hash.db.sqlalchemy import * # noqa - - -def deprecated(): - warnings.warn( - ('The hashmap db API is deprecated. ' - 'Please use rating\'s one instead.'), - DeprecationWarning, - stacklevel=3) - - -deprecated() diff --git a/cloudkitty/billing/hash/db/sqlalchemy/api.py b/cloudkitty/billing/hash/db/sqlalchemy/api.py deleted file mode 100644 index 2cb0e751..00000000 --- a/cloudkitty/billing/hash/db/sqlalchemy/api.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2014 Objectif Libre -# -# 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. -# -# @author: Stéphane Albert -# -from cloudkitty.rating.hash.db.api.sqlalchemy.api import * # noqa diff --git a/cloudkitty/billing/hash/db/sqlalchemy/migration.py b/cloudkitty/billing/hash/db/sqlalchemy/migration.py deleted file mode 100644 index e480a5fa..00000000 --- a/cloudkitty/billing/hash/db/sqlalchemy/migration.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2014 Objectif Libre -# -# 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. -# -# @author: Stéphane Albert -# -from cloudkitty.rating.hash.db.api.sqlalchemy.migration import * # noqa diff --git a/cloudkitty/billing/hash/db/sqlalchemy/models.py b/cloudkitty/billing/hash/db/sqlalchemy/models.py deleted file mode 100644 index c42d251a..00000000 --- a/cloudkitty/billing/hash/db/sqlalchemy/models.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2014 Objectif Libre -# -# 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. -# -# @author: Stéphane Albert -# -from cloudkitty.rating.hash.db.api.sqlalchemy.models import * # noqa diff --git a/cloudkitty/billing/noop.py b/cloudkitty/billing/noop.py deleted file mode 100644 index 642f5ee9..00000000 --- a/cloudkitty/billing/noop.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2014 Objectif Libre -# -# 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. -# -# @author: Stéphane Albert -# -from cloudkitty.rating.noop import * # noqa diff --git a/cloudkitty/collector/meta.py b/cloudkitty/collector/meta.py index ecd2582d..9c8e03e9 100644 --- a/cloudkitty/collector/meta.py +++ b/cloudkitty/collector/meta.py @@ -42,7 +42,7 @@ class MetaCollector(collector.BaseCollector): self._mappings[db_mapping.service] = db_mapping.collector def _check_enabled(self, name): - enable_state = db_api.get_instance().get_module_enable_state() + enable_state = db_api.get_instance().get_module_info() return enable_state.get_state('collector_{}'.format(name)) def _load_collectors(self): diff --git a/cloudkitty/db/api.py b/cloudkitty/db/api.py index 2638c7d7..944de664 100644 --- a/cloudkitty/db/api.py +++ b/cloudkitty/db/api.py @@ -71,28 +71,7 @@ class State(object): @six.add_metaclass(abc.ABCMeta) -class ModuleEnableState(object): - """Base class for module state management.""" - - @abc.abstractmethod - def get_state(self, name): - """Retrieve the module state. - - :param name: Name of the module - :return bool: State of the module - """ - - @abc.abstractmethod - def set_state(self, name, state): - """Set the module state. - - :param name: Name of the module - :param value: State of the module - """ - - -@six.add_metaclass(abc.ABCMeta) -class ModuleInfo(ModuleEnableState): +class ModuleInfo(object): """Base class for module info management.""" @abc.abstractmethod @@ -111,6 +90,22 @@ class ModuleInfo(ModuleEnableState): :param priority: New priority of the module """ + @abc.abstractmethod + def get_state(self, name): + """Retrieve the module state. + + :param name: Name of the module + :return bool: State of the module + """ + + @abc.abstractmethod + def set_state(self, name, state): + """Set the module state. + + :param name: Name of the module + :param value: State of the module + """ + class NoSuchMapping(Exception): """Raised when the mapping doesn't exist.""" diff --git a/cloudkitty/db/sqlalchemy/api.py b/cloudkitty/db/sqlalchemy/api.py index 1ec6b411..3dd9a475 100644 --- a/cloudkitty/db/sqlalchemy/api.py +++ b/cloudkitty/db/sqlalchemy/api.py @@ -81,40 +81,7 @@ class State(api.State): session.add(db_state) -class ModuleEnableState(api.ModuleEnableState): - """Deprecated, use ModuleInfo instead. - - """ - def get_state(self, name): - session = db.get_session() - try: - q = utils.model_query( - models.ModuleStateInfo, - session) - q = q.filter(models.ModuleStateInfo.name == name) - res = q.value(models.ModuleStateInfo.state) - return bool(res) - except sqlalchemy.orm.exc.NoResultFound: - return None - - def set_state(self, name, state): - session = db.get_session() - with session.begin(): - try: - q = utils.model_query( - models.ModuleStateInfo, - session) - q = q.filter(models.ModuleStateInfo.name == name) - q = q.with_lockmode('update') - db_state = q.one() - db_state.state = state - except sqlalchemy.orm.exc.NoResultFound: - db_state = models.ModuleStateInfo(name=name, state=state) - session.add(db_state) - return bool(db_state.state) - - -class ModuleInfo(ModuleEnableState): +class ModuleInfo(api.ModuleInfo): """Base class for module info management.""" def get_priority(self, name): @@ -147,6 +114,34 @@ class ModuleInfo(ModuleEnableState): session.add(db_state) return int(db_state.priority) + def get_state(self, name): + session = db.get_session() + try: + q = utils.model_query( + models.ModuleStateInfo, + session) + q = q.filter(models.ModuleStateInfo.name == name) + res = q.value(models.ModuleStateInfo.state) + return bool(res) + except sqlalchemy.orm.exc.NoResultFound: + return None + + def set_state(self, name, state): + session = db.get_session() + with session.begin(): + try: + q = utils.model_query( + models.ModuleStateInfo, + session) + q = q.filter(models.ModuleStateInfo.name == name) + q = q.with_lockmode('update') + db_state = q.one() + db_state.state = state + except sqlalchemy.orm.exc.NoResultFound: + db_state = models.ModuleStateInfo(name=name, state=state) + session.add(db_state) + return bool(db_state.state) + class ServiceToCollectorMapping(object): """Base class for service to collector mapping.""" @@ -222,10 +217,6 @@ class DBAPIManager(object): def get_state(): return State() - @staticmethod - def get_module_enable_state(): - return ModuleEnableState() - @staticmethod def get_module_info(): return ModuleInfo() diff --git a/cloudkitty/rating/__init__.py b/cloudkitty/rating/__init__.py index 590b1658..186e43d0 100644 --- a/cloudkitty/rating/__init__.py +++ b/cloudkitty/rating/__init__.py @@ -60,7 +60,7 @@ class RatingProcessorBase(object): :returns: bool if module is enabled """ api = db_api.get_instance() - module_db = api.get_module_enable_state() + module_db = api.get_module_info() return module_db.get_state(self.module_name) or False @property diff --git a/cloudkitty/tests/test_rating.py b/cloudkitty/tests/test_rating.py index be36070d..dee06c5a 100644 --- a/cloudkitty/tests/test_rating.py +++ b/cloudkitty/tests/test_rating.py @@ -78,7 +78,7 @@ class RatingTest(tests.TestCase): rpcmock.return_value = self._fake_rpc self._module.set_state(True) db_api = ck_db_api.get_instance() - module_db = db_api.get_module_enable_state() + module_db = db_api.get_module_info() self.assertTrue(module_db.get_state('fake')) def test_disable_module(self): @@ -86,12 +86,12 @@ class RatingTest(tests.TestCase): rpcmock.return_value = self._fake_rpc self._module.set_state(False) db_api = ck_db_api.get_instance() - module_db = db_api.get_module_enable_state() + module_db = db_api.get_module_info() self.assertFalse(module_db.get_state('fake')) def test_enabled_property(self): db_api = ck_db_api.get_instance() - module_db = db_api.get_module_enable_state() + module_db = db_api.get_module_info() module_db.set_state('fake', True) self.assertTrue(self._module.enabled) module_db.set_state('fake', False) diff --git a/releasenotes/notes/remove-deprecated-api-endpoints-26606e322b8a225e.yaml b/releasenotes/notes/remove-deprecated-api-endpoints-26606e322b8a225e.yaml new file mode 100644 index 00000000..0c7e6774 --- /dev/null +++ b/releasenotes/notes/remove-deprecated-api-endpoints-26606e322b8a225e.yaml @@ -0,0 +1,5 @@ +--- +other: + - | + The deprecated 'Billing' API endpoint has been removed, and its code has + been deleted from the CloudKitty repository.