Rename --profile to --os-profile

* The --profile global option is deprecated but will be supported
  through at least April 2017.
* Update man page

Closes-bug: #1571812
Change-Id: I2e623411a56096b4cc352f4eedbf770632ae2cc3
This commit is contained in:
Dean Troyer 2016-04-18 14:39:21 -05:00
parent 3f2ed7d19f
commit 530fe42589
4 changed files with 44 additions and 17 deletions

View File

@ -129,11 +129,11 @@ OPTIONS
:option:`--os-interface` <interface> :option:`--os-interface` <interface>
Interface type. Valid options are `public`, `admin` and `internal`. Interface type. Valid options are `public`, `admin` and `internal`.
:option: `--profile` <hmac-key> :option:`--os-profile` <hmac-key>
HMAC key to use for encrypting context data for performance profiling of Performance profiling HMAC key for encrypting context data
requested operation. This key should be the value of one of the HMAC keys
defined in the configuration files of OpenStack services, user would like This key should be the value of one of the HMAC keys defined in the
to trace through. configuration files of OpenStack services to be traced.
:option:`--log-file` <LOGFILE> :option:`--log-file` <LOGFILE>
Specify a file to log output. Disabled by default. Specify a file to log output. Disabled by default.

View File

@ -16,6 +16,7 @@
"""Command-line interface to the OpenStack APIs""" """Command-line interface to the OpenStack APIs"""
import argparse
import getpass import getpass
import logging import logging
import sys import sys
@ -131,6 +132,16 @@ class OpenStackShell(app.App):
self.log.info("END return value: %s", ret_val) self.log.info("END return value: %s", ret_val)
def init_profile(self): def init_profile(self):
# NOTE(dtroyer): Remove this 'if' block when the --profile global
# option is removed
if osprofiler_profiler and self.options.old_profile:
self.log.warning(
'The --profile option is deprecated, '
'please use --os-profile instead'
)
if not self.options.profile:
self.options.profile = self.options.old_profile
self.do_profile = osprofiler_profiler and self.options.profile self.do_profile = osprofiler_profiler and self.options.profile
if self.do_profile: if self.do_profile:
osprofiler_profiler.init(self.options.profile) osprofiler_profiler.init(self.options.profile)
@ -144,7 +155,7 @@ class OpenStackShell(app.App):
# bigger than most big default one (CRITICAL) or something like # bigger than most big default one (CRITICAL) or something like
# that (PROFILE = 60 for instance), but not sure we need it here. # that (PROFILE = 60 for instance), but not sure we need it here.
self.log.warning("Trace ID: %s" % trace_id) self.log.warning("Trace ID: %s" % trace_id)
self.log.warning("To display trace use next command:\n" self.log.warning("Display trace with command:\n"
"osprofiler trace show --html %s " % trace_id) "osprofiler trace show --html %s " % trace_id)
def run_subcommand(self, argv): def run_subcommand(self, argv):
@ -242,16 +253,22 @@ class OpenStackShell(app.App):
# osprofiler HMAC key argument # osprofiler HMAC key argument
if osprofiler_profiler: if osprofiler_profiler:
parser.add_argument('--profile', parser.add_argument(
metavar='hmac-key', '--os-profile',
help='HMAC key to use for encrypting context ' metavar='hmac-key',
'data for performance profiling of operation. ' dest='profile',
'This key should be the value of one of the ' help='HMAC key for encrypting profiling context data',
'HMAC keys configured in osprofiler ' )
'middleware in the projects user would like ' # NOTE(dtroyer): This global option should have been named
'to profile. It needs to be specified in ' # --os-profile as --profile interferes with at
'configuration files of the required ' # least one existing command option. Deprecate
'projects.') # --profile and remove after Apr 2017.
parser.add_argument(
'--profile',
metavar='hmac-key',
dest='old_profile',
help=argparse.SUPPRESS,
)
return clientmanager.build_plugin_option_parser(parser) return clientmanager.build_plugin_option_parser(parser)

View File

@ -112,7 +112,7 @@ global_options = {
'--os-default-domain': (DEFAULT_DOMAIN_NAME, True, True), '--os-default-domain': (DEFAULT_DOMAIN_NAME, True, True),
'--os-cacert': ('/dev/null', True, True), '--os-cacert': ('/dev/null', True, True),
'--timing': (True, True, False), '--timing': (True, True, False),
'--profile': ('SECRET_KEY', True, False), '--os-profile': ('SECRET_KEY', True, False),
'--os-interface': (DEFAULT_INTERFACE, True, True) '--os-interface': (DEFAULT_INTERFACE, True, True)
} }

View File

@ -0,0 +1,10 @@
---
upgrade:
- |
Deprecate global option ``--profile`` in favor of ``--os-profile``.
``--profile`` interferes with existing command options with the same name.
Unfortunately it appeared in a release so we must follow the deprecation
process and wait one year (April 2017) before removing it.
[Bug `1571812 <https://bugs.launchpad.net/python-openstackclient/+bug/1571812>`_]