Files
python-saharaclient/savannaclient/api/shell.py
Matthew Farrellee 1f6aa0df14 Add initial Savanna CLI
This commit provides the framework for the Savanna CLI. It is based on
the python-novaclient. novaclient was chosen because of its maturity
and the ubiquity in which it has been previously copied, i.e. we're in
the same boat as most everyone else. The goal is to keep modifications
in Savanna's copy to a minimum. To that end, much of the novaclient
code is retained, though commented out when it is not applicable.

A simple plugins-list/show command is provided with the framework for
demonstration and testing purposes.

Change-Id: I6bbbc86135d6cb16e088dd76261fdef29c2cb929
Implements: blueprint python-savannaclient-cli
2013-12-26 08:09:53 -05:00

46 lines
1.3 KiB
Python

# Copyright 2013 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from savannaclient.nova import utils
#
# Plugins
# ~~~~~~~
# plugins-list
#
# plugins-show --name <plugin> [--version <version>]
#
def do_plugins_list(cs, args):
"""Print a list of available plugins."""
plugins = cs.plugins.list()
columns = ('name', 'versions', 'title')
utils.print_list(plugins, columns)
@utils.arg('--name',
metavar='<plugin>',
required=True,
help='Name of plugin')
# TODO(mattf) - savannaclient does not support query w/ version
#@utils.arg('--version',
# metavar='<version>',
# help='Optional version')
def do_plugins_show(cs, args):
"""Show details of a plugin."""
plugin = cs.plugins.get(args.name)
utils.print_dict(plugin._info)