nova-manage: Deprecate 'project', 'account' commands

Most of these operations can be accomplished using the REST API [1],
with the 'quota_usage_refresh' command being the sole exception. This
particular command is duplicated in a new category - quota - thus
allowing us to fully deprecate the entire 'project' and 'account'
categories.

Note that the '(project|account) quota_usage_refresh' command has been
named 'quota refresh' and not 'quota usage_refresh'. This is because
cliff, which will be used by 'nova-manage' in the future, does not
support underscores in command names.

[1] https://developer.openstack.org/api-ref/compute/#quota-sets-os-quota-sets

Change-Id: Ic02a96802d2a38ed9c4e00991a6bd2088dfcffc6
This commit is contained in:
Stephen Finucane 2017-04-04 13:47:16 +01:00 committed by Matt Riedemann
parent f60d848e09
commit 3d269c5302
3 changed files with 94 additions and 3 deletions

View File

@ -218,9 +218,30 @@ Nova Shell
Runs the named script from the specified path with flags set.
.. _nova-manage-quota:
Nova Quota
~~~~~~~~~~
``nova-manage quota refresh``
Refresh the quota usage for a project or user.
Nova Project
~~~~~~~~~~~~
.. deprecated:: 16.0.0
Much of this information is available over the API, with the exception of
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 <nova-manage-quota>`
.. _API: https://developer.openstack.org/api-ref/compute/#quota-sets-os-quota-sets
``nova-manage project quota <project_id> [--user <user_id>] [--key <key>] [--value <value>]``
Create, update or display quotas for project/user. If a key is
@ -232,6 +253,12 @@ Nova Project
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 <nova-manage-quota>` command
performs the same actions and is not deprecated. That command should be
used instead.
SEE ALSO
========

View File

@ -205,9 +205,42 @@ def _db_error(caught_exception):
sys.exit(1)
class QuotaCommands(object):
"""Class for managing quotas."""
@args('--project', dest='project_id', metavar='<Project Id>',
help='Project Id', required=True)
@args('--user', dest='user_id', metavar='<User Id>',
help='User Id')
@args('--key', metavar='<key>', 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.
"""
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
class ProjectCommands(object):
"""Class for managing projects."""
# TODO(stephenfin): Remove this during the Queens cycle
description = ('DEPRECATED: The project commands are deprecated since '
'Pike as this information is available over the API. They '
'will be removed in an upcoming release.')
@args('--project', dest='project_id', metavar='<Project name>',
help='Project name')
@args('--user', dest='user_id', metavar='<User name>',
@ -286,8 +319,11 @@ class ProjectCommands(object):
"""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.
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.
"""
ctxt = context.get_admin_context()
@ -302,7 +338,13 @@ class ProjectCommands(object):
return 2
AccountCommands = ProjectCommands
class AccountCommands(ProjectCommands):
"""Class for managing projects."""
# TODO(stephenfin): Remove this during the Queens cycle
description = ('DEPRECATED: The account commands are deprecated since '
'Pike as this information is available over the API. They '
'will be removed in an upcoming release.')
class FloatingIpCommands(object):
@ -1571,6 +1613,7 @@ CATEGORIES = {
'network': NetworkCommands,
'project': ProjectCommands,
'shell': ShellCommands,
'quota': QuotaCommands,
}

View File

@ -1,15 +1,35 @@
---
upgrade:
- |
The ``nova-manage project quota_usage_refresh`` and its alias ``nova-manage
account quota_usage_refresh`` commands have been renamed ``nova-manage
quota refresh``. Aliases are provided but these are marked as deprecated
and will be removed in the next release of nova.
deprecations:
- |
A number of `nova-manage` commands have been deprecated. The commands,
along with the reasons for their deprecation, are listed below:
`account`
This allows for the creation, deletion, update and listing of user and
project quotas. Operators should use the equivalent resources in the
`REST API`__ instead.
The ``quota_usage_refresh`` sub-command has been renamed to ``nova-manage
quota refresh``. This new command should be used instead.
`agent`
This allows for the creation, deletion, update and listing of "agent
builds". Operators should use the equivalent resources in the `REST
API`__ instead.
`project`
This is an alias for `account` and has been deprecated for the same
reasons.
`shell`
This starts the Python interactive interpreter. It is a clone of the same
@ -19,4 +39,5 @@ deprecations:
These commands will be removed in their entirety during the Queens cycle.
__ https://developer.openstack.org/api-ref/compute/#quota-sets-os-quota-sets
__ https://developer.openstack.org/api-ref/compute/#guest-agents-os-agents