common: autogenerate docs

$namespace = openstack.common

The subcommand documents for $namespace were hardcoded and thus prone to
drift over time. This commit removes the hardcoded content and uses the
autoprogram-cliff directive to generate them automatically from the
subcommand configuration classes.

This incorporates a correction to `openstack versions show`: The command
`openstack versions show --help` showed a copy/paste error, using
<region-name> for the metavar for both --service and --status. Fix.

Change-Id: I7658fed40d71f4c20ee27908ade433534657cfe5
Co-Authored-By: Pierre Prinetti <pierreprinetti@redhat.com>
Co-Authored-By: Matt Riedemann <mriedem.os@gmail.com>
This commit is contained in:
Eric Fried 2019-10-29 16:22:18 -05:00
parent c7dbe85705
commit 4c0f3bfa89
9 changed files with 56 additions and 494 deletions

View File

@ -7,32 +7,5 @@ compute and network services.
Block Storage v2, Compute v2, Network v2
availability zone list
----------------------
List availability zones and their status
.. program availability zone list
.. code:: bash
openstack availability zone list
[--compute]
[--network]
[--volume]
[--long]
.. option:: --compute
List compute availability zones
.. option:: --network
List network availability zones
.. option:: --volume
List volume availability zones
.. option:: --long
List additional fields in output
.. autoprogram-cliff:: openstack.common
:command: availability zone list

View File

@ -6,24 +6,5 @@ Available for all services
.. _configuration-show:
configuration show
------------------
Show the current openstack client configuration. This command is a little
different from other show commands because it does not take a resource name
or id to show. The command line options, such as --os-cloud, can be used to
show different configurations.
.. program:: configuration show
.. code:: bash
openstack configuration show
[--mask | --unmask]
.. option:: --mask
Attempt to mask passwords (default)
.. option:: --unmask
Show password in clear text
.. autoprogram-cliff:: openstack.common
:command: configuration show

View File

@ -5,54 +5,6 @@ extension
Many OpenStack server APIs include API extensions that enable
additional functionality.
extension list
--------------
List API extensions
.. program:: extension list
.. code:: bash
openstack extension list
[--compute]
[--identity]
[--network]
[--volume]
[--long]
.. option:: --compute
List extensions for the Compute API
.. option:: --identity
List extensions for the Identity API
.. option:: --network
List extensions for the Network API
.. option:: --volume
List extensions for the Block Storage API
.. option:: --long
List additional fields in output
extension show
--------------
Show API extension
.. program:: extension show
.. code:: bash
openstack extension show
<extension>
.. _extension_show:
.. describe:: <extension>
Extension to display. Currently, only network extensions are supported.
(Name or Alias)
.. autoprogram-cliff:: openstack.common
:command: extension *

View File

@ -6,36 +6,6 @@ The Compute and Block Storage APIs have resource usage limits.
Compute v2, Block Storage v1
limits show
-----------
Show compute and block storage limits
.. program:: limits show
.. code:: bash
openstack limits show
--absolute | --rate
[--reserved]
[--project <project>]
[--domain <domain>]
.. option:: --absolute
Show absolute limits
.. option:: --rate
Show rate limits
.. option:: --reserved
Include reservations count [only valid with :option:`--absolute`]
.. option:: --project <project>
Show limits for a specific project (name or ID) [only valid with :option:`--absolute`]
.. option:: --domain <domain>
Domain the project belongs to (name or ID) [only valid with :option:`--absolute`]
.. autoprogram-cliff:: openstack.common
:command: limits *

View File

@ -6,37 +6,6 @@ Clean resources associated with a specific project.
Block Storage v1, v2; Compute v2; Image v1, v2
project purge
-------------
Clean resources associated with a project
.. program:: project purge
.. code:: bash
openstack project purge
[--dry-run]
[--keep-project]
[--auth-project | --project <project>]
[--project-domain <project-domain>]
.. option:: --dry-run
List a project's resources
.. option:: --keep-project
Clean project resources, but don't delete the project.
.. option:: --auth-project
Delete resources of the project used to authenticate
.. option:: --project <project>
Project to clean (name or ID)
.. option:: --project-domain <project-domain>
Domain the project belongs to (name or ID). This can be
used in case collisions between project names exist.
.. autoprogram-cliff:: openstack.common
:command: project purge

View File

@ -7,272 +7,5 @@ single object with multiple properties.
Block Storage v1, v2, Compute v2, Network v2
quota list
----------
List quotas for all projects with non-default quota values
.. program:: quota list
.. code:: bash
openstack quota list
--compute | --network | --volume
[--project <project>]
[--detail]
.. option:: --network
List network quotas
.. option:: --compute
List compute quotas
.. option:: --volume
List volume quotas
.. option:: --project <project>
List quotas for this project <project> (name or ID)
.. option:: --detail
Show details about quotas usage
quota set
---------
Set quotas for project
.. program:: quota set
.. code:: bash
openstack quota set
# Compute settings
[--cores <num-cores>]
[--fixed-ips <num-fixed-ips>]
[--floating-ips <num-floating-ips>]
[--injected-file-size <injected-file-bytes>]
[--injected-files <num-injected-files>]
[--instances <num-instances>]
[--key-pairs <num-key-pairs>]
[--properties <num-properties>]
[--ram <ram-mb>]
[--server-groups <num-server-groups>]
[--server-group-members <num-server-group-members>]
# Block Storage settings
[--backups <new-backups>]
[--backup-gigabytes <new-backup-gigabytes>]
[--gigabytes <new-gigabytes>]
[--per-volume-gigabytes <new-per-volume-gigabytes>]
[--snapshots <new-snapshots>]
[--volumes <new-volumes>]
[--volume-type <volume-type>]
# Network settings
[--floating-ips <num-floatingips>]
[--secgroup-rules <num-security-group-rules>]
[--secgroups <num-security-groups>]
[--networks <num-networks>]
[--subnets <num-subnets>]
[--ports <num-ports>]
[--routers <num-routers>]
[--rbac-policies <num-rbac-policies>]
[--subnetpools <num-subnetpools>]
<project>
Set quotas for class
.. code:: bash
openstack quota set
--class
# Compute settings
[--cores <num-cores>]
[--fixed-ips <num-fixed-ips>]
[--floating-ips <num-floating-ips>]
[--injected-file-size <injected-file-bytes>]
[--injected-files <num-injected-files>]
[--instances <num-instances>]
[--key-pairs <num-key-pairs>]
[--properties <num-properties>]
[--ram <ram-mb>]
[--server-groups <num-server-groups>]
[--server-group-members <num-server-group-members>]
# Block Storage settings
[--backups <new-backups>]
[--backup-gigabytes <new-backup-gigabytes>]
[--gigabytes <new-gigabytes>]
[--per-volume-gigabytes <new-per-volume-gigabytes>]
[--snapshots <new-snapshots>]
[--volumes <new-volumes>]
<class>
.. option:: --class
Set quotas for ``<class>``
.. option:: --properties <new-properties>
New value for the properties quota
.. option:: --ram <new-ram>
New value for the ram quota
.. option:: --secgroup-rules <new-secgroup-rules>
New value for the secgroup-rules quota
.. option:: --instances <new-instances>
New value for the instances quota
.. option:: --key-pairs <new-key-pairs>
New value for the key-pairs quota
.. option:: --fixed-ips <new-fixed-ips>
New value for the fixed-ips quota
.. option:: --secgroups <new-secgroups>
New value for the secgroups quota
.. option:: --injected-file-size <new-injected-file-size>
New value for the injected-file-size quota
.. option:: --server-groups <new-server-groups>
New value for the server-groups quota
.. option:: --server-group-members <new-server-group-members>
New value for the server-group-members quota
.. option:: --floating-ips <new-floating-ips>
New value for the floating-ips quota
.. option:: --injected-files <new-injected-files>
New value for the injected-files quota
.. option:: --cores <new-cores>
New value for the cores quota
.. option:: --injected-path-size <new-injected-path-size>
New value for the injected-path-size quota
.. option:: --backups <new-backups>
New value for the backups quota
.. option:: --backup-gigabytes <new-backup-gigabytes>
New value for the backup gigabytes quota
.. option:: --gigabytes <new-gigabytes>
New value for the gigabytes quota
.. option:: --per-volume-gigabytes <new-per-volume-gigabytes>
New value for the gigabytes quota of per volume
.. option:: --volumes <new-volumes>
New value for the volumes quota
.. option:: --snapshots <new-snapshots>
New value for the snapshots quota
.. option:: --volume-type <volume-type>
Set quotas for a specific <volume-type>. The supported quotas are:
gigabytes, snapshots, volumes.
.. option:: --networks <num-networks>
New value for the networks quota
.. option:: --subnets <num-subnets>
New value for the subnets quota
.. option:: --ports <num-ports>
New value for the ports quota
.. option:: --routers <num-routers>
New value for the routers quota
.. option:: --rbac-policies <num-rbac-policies>
New value for the rbac-policies quota
.. option:: --vips <num-vips>
New value for the vips quota
.. option:: --subnetpools <num-subnetpools>
New value for the subnetpools quota
.. option:: --members <num-members>
New value for the members quota
.. option:: --health-monitors <num-health-monitors>
New value for the health-monitors quota
quota show
----------
Show quotas for project or class. Specify ``--os-compute-api-version 2.50`` or
higher to see ``server-groups`` and ``server-group-members`` output for a given
quota class.
.. program:: quota show
.. code:: bash
openstack quota show
[--default]
[<project>]
.. option:: --default
Show default quotas for :ref:`\<project\> <quota_show-project>`
.. _quota_show-project:
.. describe:: <project>
Show quotas for this project (name or ID)
.. code:: bash
openstack quota show
--class
[<class>]
.. option:: --class
Show quotas for :ref:`\<class\> <quota_show-class>`
.. _quota_show-class:
.. describe:: <class>
Show quotas for this class (name or ID)
.. autoprogram-cliff:: openstack.common
:command: quota *

View File

@ -4,48 +4,5 @@ versions
Get a list of every version of every service in a given cloud.
versions show
-------------
Show service versions:
.. program:: versions show
.. code:: bash
openstack versions show
[--all-interfaces]
[--interface <interface>]
[--region-name <region-name>]
[--service <service>]
[--status <status>]
.. option:: --all-interfaces
Return results for every interface of every service.
[Mutually exclusive with --interface]
.. option:: --interface <interface>
Limit results to only those on given interface.
[Default 'public'. Mutually exclusive with --all-interfaces]
.. option:: --region-name <region-name>
Limit results to only those from a given region.
.. option:: --service <service>
Limit results to only those for service. The argument should be either
an exact match to what is in the catalog or a known official value or
alias from `service-types-authority`_.
.. option:: --status <status>
Limit results to only those in the given state. Valid values are:
- SUPPORTED
- CURRENT
- DEPRECATED
- EXPERIMENTAL
.. _service-types-authority: https://service-types.openstack.org/
.. autoprogram-cliff:: openstack.common
:command: versions show

View File

@ -24,6 +24,7 @@ from osc_lib import utils
import six
from openstackclient.i18n import _
from openstackclient.network import common
LOG = logging.getLogger(__name__)
@ -457,18 +458,37 @@ class ListQuota(command.Lister, BaseQuota):
return ((), ())
class SetQuota(command.Command):
class SetQuota(common.NetDetectionMixin, command.Command):
_description = _("Set quotas for project or class")
def _build_options_list(self):
if self.app.client_manager.is_network_endpoint_enabled():
return itertools.chain(COMPUTE_QUOTAS.items(),
help_fmt = _('New value for the %s quota')
# Compute and volume quota options are always the same
rets = [(k, v, help_fmt % v) for k, v in itertools.chain(
COMPUTE_QUOTAS.items(),
VOLUME_QUOTAS.items(),
NETWORK_QUOTAS.items())
else:
return itertools.chain(COMPUTE_QUOTAS.items(),
VOLUME_QUOTAS.items(),
NOVA_NETWORK_QUOTAS.items())
)]
# For docs build, we want to produce helps for both neutron and
# nova-network options. They overlap, so we have to figure out which
# need to be tagged as specific to one network type or the other.
if self.is_docs_build:
# NOTE(efried): This takes advantage of the fact that we know the
# nova-net options are a subset of the neutron options. If that
# ever changes, this algorithm will need to be adjusted accordingly
inv_compute = set(NOVA_NETWORK_QUOTAS.values())
for k, v in NETWORK_QUOTAS.items():
_help = help_fmt % v
if v not in inv_compute:
# This one is unique to neutron
_help = self.enhance_help_neutron(_help)
rets.append((k, v, _help))
elif self.is_neutron:
rets.extend(
[(k, v, help_fmt % v) for k, v in NETWORK_QUOTAS.items()])
elif self.is_nova_network:
rets.extend(
[(k, v, help_fmt % v) for k, v in NOVA_NETWORK_QUOTAS.items()])
return rets
def get_parser(self, prog_name):
parser = super(SetQuota, self).get_parser(prog_name)
@ -484,13 +504,13 @@ class SetQuota(command.Command):
default=False,
help=_('Set quotas for <class>'),
)
for k, v in self._build_options_list():
for k, v, h in self._build_options_list():
parser.add_argument(
'--%s' % v,
metavar='<%s>' % v,
dest=k,
type=int,
help=_('New value for the %s quota') % v,
help=h,
)
parser.add_argument(
'--volume-type',

View File

@ -46,14 +46,21 @@ class ShowVersions(command.Lister):
parser.add_argument(
'--service',
metavar='<service>',
help=_('Show versions for a specific service.'),
help=_('Show versions for a specific service. The argument should '
'be either an exact match to what is in the catalog or a '
'known official value or alias from '
'service-types-authority '
'(https://service-types.openstack.org/)'),
)
parser.add_argument(
'--status',
metavar='<status>',
help=_('Show versions for a specific status.'
' [Valid values are SUPPORTED, CURRENT,'
' DEPRECATED, EXPERIMENTAL]'),
help=_("""Show versions for a specific status. Valid values are:
- SUPPORTED
- CURRENT
- DEPRECATED
- EXPERIMENTAL""")
)
return parser