Add package show to openstack CLI
usage: openstack package show [-h] [-f {json,shell,table,value,yaml}] [-c COLUMN] [--max-width <integer>] [--fit-width] [--print-empty] [--noindent] [--prefix PREFIX] <ID> Display details for a package. Partially implements: blueprint openstack-client-plugin-support Change-Id: I4373469a98f11194eb9d3dfe78898eef0bd36c3d
This commit is contained in:
parent
9c867d8dde
commit
2fbfc68f8a
|
@ -25,6 +25,7 @@ from osc_lib.command import command
|
||||||
from osc_lib import exceptions as exc
|
from osc_lib import exceptions as exc
|
||||||
from osc_lib import utils
|
from osc_lib import utils
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
|
|
||||||
from muranoclient.apiclient import exceptions
|
from muranoclient.apiclient import exceptions
|
||||||
from muranoclient.common import exceptions as common_exceptions
|
from muranoclient.common import exceptions as common_exceptions
|
||||||
|
@ -631,3 +632,44 @@ class ImportBundle(command.Lister):
|
||||||
columns,
|
columns,
|
||||||
) for s in imported_list)
|
) for s in imported_list)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class ShowPackage(command.ShowOne):
|
||||||
|
"""Display details for a package."""
|
||||||
|
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(ShowPackage, self).get_parser(prog_name)
|
||||||
|
parser.add_argument(
|
||||||
|
"id",
|
||||||
|
metavar="<ID>",
|
||||||
|
help=("Package ID to show."),
|
||||||
|
)
|
||||||
|
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
LOG.debug("take_action({0})".format(parsed_args))
|
||||||
|
client = self.app.client_manager.application_catalog
|
||||||
|
|
||||||
|
try:
|
||||||
|
package = client.packages.get(parsed_args.id)
|
||||||
|
except common_exceptions.HTTPNotFound:
|
||||||
|
raise exceptions.CommandError("Package with id %s not "
|
||||||
|
"found" % parsed_args.id)
|
||||||
|
else:
|
||||||
|
to_display = dict(
|
||||||
|
id=package.id,
|
||||||
|
type=package.type,
|
||||||
|
owner_id=package.owner_id,
|
||||||
|
name=package.name,
|
||||||
|
fully_qualified_name=package.fully_qualified_name,
|
||||||
|
is_public=package.is_public,
|
||||||
|
enabled=package.enabled,
|
||||||
|
class_definitions=jsonutils.dumps(package.class_definitions,
|
||||||
|
indent=2),
|
||||||
|
categories=jsonutils.dumps(package.categories, indent=2),
|
||||||
|
tags=jsonutils.dumps(package.tags, indent=2),
|
||||||
|
description=package.description
|
||||||
|
)
|
||||||
|
|
||||||
|
return self.dict2columns(to_display)
|
||||||
|
|
|
@ -688,3 +688,27 @@ class TestBundleImport(TestPackage):
|
||||||
], any_order=True,
|
], any_order=True,
|
||||||
)
|
)
|
||||||
shutil.rmtree(tmp_dir)
|
shutil.rmtree(tmp_dir)
|
||||||
|
|
||||||
|
|
||||||
|
class TestShowPackage(TestPackage):
|
||||||
|
def setUp(self):
|
||||||
|
super(TestShowPackage, self).setUp()
|
||||||
|
|
||||||
|
# Command to test
|
||||||
|
self.cmd = osc_pkg.ShowPackage(self.app, None)
|
||||||
|
|
||||||
|
def test_package_show(self):
|
||||||
|
arglist = ['fake']
|
||||||
|
verifylist = [('id', 'fake')]
|
||||||
|
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
|
# Check that columns are correct
|
||||||
|
expected_columns = ('categories', 'class_definitions', 'description',
|
||||||
|
'enabled', 'fully_qualified_name', 'id',
|
||||||
|
'is_public', 'name', 'owner_id', 'tags', 'type')
|
||||||
|
self.assertEqual(expected_columns, columns)
|
||||||
|
|
||||||
|
self.package_mock.get.assert_called_with('fake')
|
||||||
|
|
|
@ -56,6 +56,7 @@ openstack.application_catalog.v1 =
|
||||||
package_list = muranoclient.osc.v1.package:ListPackages
|
package_list = muranoclient.osc.v1.package:ListPackages
|
||||||
package_delete = muranoclient.osc.v1.package:DeletePackage
|
package_delete = muranoclient.osc.v1.package:DeletePackage
|
||||||
package_import = muranoclient.osc.v1.package:ImportPackage
|
package_import = muranoclient.osc.v1.package:ImportPackage
|
||||||
|
package_show = muranoclient.osc.v1.package:ShowPackage
|
||||||
|
|
||||||
bundle_import = muranoclient.osc.v1.package:ImportBundle
|
bundle_import = muranoclient.osc.v1.package:ImportBundle
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue