diff options
| author | Dean Troyer <dtroyer@gmail.com> | 2015-01-14 18:44:10 -0600 |
|---|---|---|
| committer | Dean Troyer <dtroyer@gmail.com> | 2015-01-15 00:04:55 -0600 |
| commit | bc11c4d7d8fef1d8eef3bb8f5fa18e27b9ea2964 (patch) | |
| tree | 74fa8f01f52c5fcd826dc83239f22bbce316a62f /openstackclient | |
| parent | 4a8a2fb27d9f4f4142b019be75e48e872b72b116 (diff) | |
| download | python-openstackclient-bc11c4d7d8fef1d8eef3bb8f5fa18e27b9ea2964.tar.gz | |
Deprecate project usage list command
Rather than pointing the 'project usage list' entry point directly to
ListUsage, this makes a ListProjectUsage subclass to alias the desired
command and still allow for changing behaviour or issuing a deprecation
messages. This implementation simply sets a new 'deprecated' attribute
in the command class that cliff will use to skip this command when
generating help output.
The actual skipping of the command in help output is dependant on
https://review.openstack.org/147349 merging in cliff, this review will
simply have no effect on help output until a version of cliff with
that update is present.
The deprecation message printed is somewhat generic until
https://review.openstack.org/147381 is merged in cliff.
Until that is merged, the deprecation message will not have the name
of the actual command given by the user in it, but rather the text
'this command'.
Closes-bug: #1406654
Change-Id: Ie08d4f88d71a660fca1862405351109cd0aa86b6
Diffstat (limited to 'openstackclient')
| -rw-r--r-- | openstackclient/compute/v2/usage.py | 29 | ||||
| -rw-r--r-- | openstackclient/shell.py | 3 |
2 files changed, 25 insertions, 7 deletions
diff --git a/openstackclient/compute/v2/usage.py b/openstackclient/compute/v2/usage.py index 308241cf..31b90c22 100644 --- a/openstackclient/compute/v2/usage.py +++ b/openstackclient/compute/v2/usage.py @@ -27,7 +27,7 @@ from openstackclient.common import utils class ListUsage(lister.Lister): - """List resource usage per project. """ + """List resource usage per project""" log = logging.getLogger(__name__ + ".ListUsage") @@ -38,7 +38,7 @@ class ListUsage(lister.Lister): metavar="<start>", default=None, help="Usage range start date, ex 2012-01-20" - " (default: 4 weeks ago)." + " (default: 4 weeks ago)" ) parser.add_argument( "--end", @@ -119,7 +119,7 @@ class ListUsage(lister.Lister): class ShowUsage(show.ShowOne): - """Show resource usage for a single project. """ + """Show resource usage for a single project""" log = logging.getLogger(__name__ + ".ShowUsage") @@ -129,20 +129,20 @@ class ShowUsage(show.ShowOne): "--project", metavar="<project>", default=None, - help="Name or ID of project to show usage for." + help="Name or ID of project to show usage for" ) parser.add_argument( "--start", metavar="<start>", default=None, help="Usage range start date, ex 2012-01-20" - " (default: 4 weeks ago)." + " (default: 4 weeks ago)" ) parser.add_argument( "--end", metavar="<end>", default=None, - help="Usage range end date, ex 2012-01-20 (default: tomorrow)." + help="Usage range end date, ex 2012-01-20 (default: tomorrow)" ) return parser @@ -188,3 +188,20 @@ class ShowUsage(show.ShowOne): info['CPU Hours'] = float("%.2f" % usage.total_vcpus_usage) info['Disk GB-Hours'] = float("%.2f" % usage.total_local_gb_usage) return zip(*sorted(six.iteritems(info))) + + +# This is out of order due to the subclass, will eventually be removed + +class ListProjectUsage(ListUsage): + """List resource usage per project""" + + deprecated = True + + log = logging.getLogger('DEPRECATED:') + + def take_action(self, parsed_args): + self.log.warning( + "%s is deprecated, use 'usage list'", + getattr(self, 'cmd_name', 'this command'), + ) + return super(ListProjectUsage, self).take_action(parsed_args) diff --git a/openstackclient/shell.py b/openstackclient/shell.py index ac5556af..246f51b1 100644 --- a/openstackclient/shell.py +++ b/openstackclient/shell.py @@ -303,7 +303,8 @@ class OpenStackShell(app.App): def prepare_to_run_command(self, cmd): """Set up auth and API versions""" self.log.info( - 'command: %s.%s', + 'command: %s -> %s.%s', + getattr(cmd, 'cmd_name', '<none>'), cmd.__class__.__module__, cmd.__class__.__name__, ) |
