From f2606322f72d94a80941d00f19c7c01d81966cab Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Wed, 15 Mar 2017 16:24:17 -0700 Subject: [PATCH] Deprecate useless quota_usage_refresh from nova-manage Since we no longer use usage records, we don't need the nova-manage command to sync usage records with actual resource consumption. Co-Authored-By: melanie witt Part of blueprint cells-count-resources-to-check-quota-in-api Change-Id: I55f7a2b6e15eec6e6ec97be23903325ad22bd4d4 --- doc/source/cli/nova-manage.rst | 25 +++++----- nova/cmd/manage.py | 46 +++++-------------- nova/tests/unit/test_nova_manage.py | 21 --------- ...a-refresh-deprecated-08040cb2e62fdc6b.yaml | 6 +++ 4 files changed, 29 insertions(+), 69 deletions(-) create mode 100644 releasenotes/notes/quota-refresh-deprecated-08040cb2e62fdc6b.yaml diff --git a/doc/source/cli/nova-manage.rst b/doc/source/cli/nova-manage.rst index b1db93789234..f4736f19f8da 100644 --- a/doc/source/cli/nova-manage.rst +++ b/doc/source/cli/nova-manage.rst @@ -230,9 +230,14 @@ Nova Shell Nova Quota ~~~~~~~~~~ +.. deprecated:: 16.0.0 + + This will be removed in 17.0.0 (Queens) + ``nova-manage quota refresh`` - Refresh the quota usage for a project or user. + This command has been deprecated and is now a no-op since quota usage is + counted from resources instead of being tracked separately. Nova Project ~~~~~~~~~~~~ @@ -243,9 +248,10 @@ Nova Project the ``quota_usage_refresh`` command. Operators should use the `API`_ for all other operations. - This command group will be removed in 17.0.0 (Queens). Users of the - ``quota_usage_refresh`` subcommand should instead use :ref:`nova-manage - quota refresh ` + This command group will be removed in 17.0.0 (Queens). The + ``quota_usage_refresh`` subcommand has been deprecated and is now a no-op + since quota usage is counted from resources instead of being tracked + separately. .. _API: https://developer.openstack.org/api-ref/compute/#quota-sets-os-quota-sets @@ -256,15 +262,8 @@ Nova Project ``nova-manage project quota_usage_refresh [--user ] [--key ]`` - Refresh the quota usages for the project/user so that the - usage record matches the actual used. If a key is not specified - then all quota usages relevant to the project/user are refreshed. - - .. seealso:: - - The :ref:`nova-manage quota refresh ` command - performs the same actions and is not deprecated. That command should be - used instead. + This command has been deprecated and is now a no-op since quota usage is + counted from resources instead of being tracked separately. SEE ALSO ======== diff --git a/nova/cmd/manage.py b/nova/cmd/manage.py index f8016c2f6865..e87c71fe40c9 100644 --- a/nova/cmd/manage.py +++ b/nova/cmd/manage.py @@ -209,29 +209,21 @@ def _db_error(caught_exception): class QuotaCommands(object): """Class for managing quotas.""" + # TODO(melwitt): Remove this during the Queens cycle + description = ('DEPRECATED: The quota commands are deprecated since ' + 'Pike as quota usage is counted from resources instead ' + 'of being tracked separately. They will be removed in an ' + 'upcoming release.') + @args('--project', dest='project_id', metavar='', help='Project Id', required=True) @args('--user', dest='user_id', metavar='', help='User Id') @args('--key', metavar='', help='Key') def refresh(self, project_id, user_id=None, key=None): - """Refresh the quotas for a project or user. - - If no quota key is provided, all the quota usages will be refreshed. - If a valid quota key is provided and it does not exist, it will be - created. Otherwise, it will be refreshed. + """DEPRECATED: This command is deprecated and no longer does anything. """ - ctxt = context.get_admin_context() - - keys = None - if key: - keys = [key] - - try: - QUOTAS.usage_refresh(ctxt, project_id, user_id, keys) - except exception.QuotaUsageRefreshNotAllowed as e: - print(e.format_message()) - return 2 + pass class ProjectCommands(object): @@ -317,26 +309,10 @@ class ProjectCommands(object): help='User Id') @args('--key', metavar='', help='Key') def quota_usage_refresh(self, project_id, user_id=None, key=None): - """Refresh the quotas for project/user - - If no quota key is provided, all the quota usages will be refreshed. - If a valid quota key is provided and it does not exist, it will be - created. Otherwise, it will be refreshed. - - DEPRECATED: This command is deprecated. Use ``nova-manage quota - refresh`` instead. + """DEPRECATED: This command is deprecated and no longer does anything. """ - ctxt = context.get_admin_context() - - keys = None - if key: - keys = [key] - - try: - QUOTAS.usage_refresh(ctxt, project_id, user_id, keys) - except exception.QuotaUsageRefreshNotAllowed as e: - print(e.format_message()) - return 2 + # TODO(melwitt): Remove this during the Queens cycle + pass class AccountCommands(ProjectCommands): diff --git a/nova/tests/unit/test_nova_manage.py b/nova/tests/unit/test_nova_manage.py index 9a249484939b..f139cb886955 100644 --- a/nova/tests/unit/test_nova_manage.py +++ b/nova/tests/unit/test_nova_manage.py @@ -354,27 +354,6 @@ class ProjectCommandsTestCase(test.TestCase): def test_quota_update_invalid_key(self): self.assertEqual(2, self.commands.quota('admin', 'volumes1', '10')) - def test_quota_usage_refresh_all_user_keys(self): - self.assertIsNone(self.commands.quota_usage_refresh( - 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', - 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaab')) - - def test_quota_usage_refresh_all_project_keys(self): - self.assertIsNone(self.commands.quota_usage_refresh( - 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa')) - - def test_quota_usage_refresh_invalid_user_key(self): - self.assertEqual(2, self.commands.quota_usage_refresh( - 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', - 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaab', - 'fixed_ip')) - - def test_quota_usage_refresh_invalid_project_key(self): - self.assertEqual(2, self.commands.quota_usage_refresh( - 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', - None, - 'ram')) - class DBCommandsTestCase(test.NoDBTestCase): def setUp(self): diff --git a/releasenotes/notes/quota-refresh-deprecated-08040cb2e62fdc6b.yaml b/releasenotes/notes/quota-refresh-deprecated-08040cb2e62fdc6b.yaml new file mode 100644 index 000000000000..018d1c68a8f4 --- /dev/null +++ b/releasenotes/notes/quota-refresh-deprecated-08040cb2e62fdc6b.yaml @@ -0,0 +1,6 @@ +--- +deprecations: + - | + The ``nova-manage quota refresh`` command has been deprecated and is now a + no-op since quota usage is counted from resources instead of being tracked + separately. The command will be removed during the Queens cycle.