1616
1717"""Command-line interface to the OpenStack APIs"""
1818
19+ import argparse
1920import getpass
2021import logging
2122import sys
@@ -131,6 +132,16 @@ def run(self, argv):
131132 self .log .info ("END return value: %s" , ret_val )
132133
133134 def init_profile (self ):
135+ # NOTE(dtroyer): Remove this 'if' block when the --profile global
136+ # option is removed
137+ if osprofiler_profiler and self .options .old_profile :
138+ self .log .warning (
139+ 'The --profile option is deprecated, '
140+ 'please use --os-profile instead'
141+ )
142+ if not self .options .profile :
143+ self .options .profile = self .options .old_profile
144+
134145 self .do_profile = osprofiler_profiler and self .options .profile
135146 if self .do_profile :
136147 osprofiler_profiler .init (self .options .profile )
@@ -144,7 +155,7 @@ def close_profile(self):
144155 # bigger than most big default one (CRITICAL) or something like
145156 # that (PROFILE = 60 for instance), but not sure we need it here.
146157 self .log .warning ("Trace ID: %s" % trace_id )
147- self .log .warning ("To display trace use next command:\n "
158+ self .log .warning ("Display trace with command:\n "
148159 "osprofiler trace show --html %s " % trace_id )
149160
150161 def run_subcommand (self , argv ):
@@ -242,16 +253,22 @@ def build_option_parser(self, description, version):
242253
243254 # osprofiler HMAC key argument
244255 if osprofiler_profiler :
245- parser .add_argument ('--profile' ,
246- metavar = 'hmac-key' ,
247- help = 'HMAC key to use for encrypting context '
248- 'data for performance profiling of operation. '
249- 'This key should be the value of one of the '
250- 'HMAC keys configured in osprofiler '
251- 'middleware in the projects user would like '
252- 'to profile. It needs to be specified in '
253- 'configuration files of the required '
254- 'projects.' )
256+ parser .add_argument (
257+ '--os-profile' ,
258+ metavar = 'hmac-key' ,
259+ dest = 'profile' ,
260+ help = 'HMAC key for encrypting profiling context data' ,
261+ )
262+ # NOTE(dtroyer): This global option should have been named
263+ # --os-profile as --profile interferes with at
264+ # least one existing command option. Deprecate
265+ # --profile and remove after Apr 2017.
266+ parser .add_argument (
267+ '--profile' ,
268+ metavar = 'hmac-key' ,
269+ dest = 'old_profile' ,
270+ help = argparse .SUPPRESS ,
271+ )
255272
256273 return clientmanager .build_plugin_option_parser (parser )
257274
0 commit comments