Adds command `image metadef object show
`
Depends-on: https://review.opendev.org/c/openstack/openstacksdk/+/858350 Change-Id: I97bcb0ccee9d25fb26475ec9e10660556e6072a6
This commit is contained in:
parent
0439f17ed3
commit
78ef009a3a
@ -36,7 +36,7 @@ md-object-create,image metadef object create,Create a new metadata definitions o
|
||||
md-object-delete,,Delete a specific metadata definitions object inside a namespace.
|
||||
md-object-list,,List metadata definitions objects inside a specific namespace.
|
||||
md-object-property-show,,Describe a specific metadata definitions property inside an object.
|
||||
md-object-show,,Describe a specific metadata definitions object inside a namespace.
|
||||
md-object-show,image metadef object show,Describe a specific metadata definitions object inside a namespace.
|
||||
md-object-update,,Update metadata definitions object inside a namespace.
|
||||
md-property-create,image metadef property create,Create a new metadata definitions property inside a namespace.
|
||||
md-property-delete,,Delete a specific metadata definitions property inside a namespace.
|
||||
|
|
@ -1,4 +1,4 @@
|
||||
# Copyright 2012-2013 OpenStack Foundation
|
||||
# Copyright 2023 Red Hat
|
||||
#
|
||||
# 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
|
||||
@ -73,3 +73,35 @@ class CreateMetadefObjects(command.ShowOne):
|
||||
fields, value = _format_object(data)
|
||||
|
||||
return fields, value
|
||||
|
||||
|
||||
class ShowMetadefObjects(command.ShowOne):
|
||||
_description = _(
|
||||
"Describe a specific metadata definitions" "object inside a namespace"
|
||||
)
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
"namespace_name",
|
||||
metavar="<namespace_name>",
|
||||
help=_("Namespace (name) for the namespace"),
|
||||
)
|
||||
parser.add_argument(
|
||||
"object_name",
|
||||
metavar="<object_name>",
|
||||
help=_("Name of an object."),
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
image_client = self.app.client_manager.image
|
||||
|
||||
namespace_name = parsed_args.namespace_name
|
||||
object_name = parsed_args.object_name
|
||||
|
||||
data = image_client.get_metadef_object(object_name, namespace_name)
|
||||
|
||||
fields, value = _format_object(data)
|
||||
|
||||
return fields, value
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright 2012-2013 OpenStack Foundation
|
||||
# Copyright 2023 Red Hat
|
||||
#
|
||||
# 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
|
||||
@ -41,7 +41,6 @@ class TestMetadefObjectsCreate(fakes.TestImagev2):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.image_client.create_metadef_object.return_value = (
|
||||
self._metadef_objects
|
||||
)
|
||||
@ -55,6 +54,49 @@ class TestMetadefObjectsCreate(fakes.TestImagev2):
|
||||
]
|
||||
verifylist = []
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.assertEqual(self.expected_columns, columns)
|
||||
self.assertEqual(self.expected_data, data)
|
||||
|
||||
|
||||
class TestMetadefObjectsShow(fakes.TestImagev2):
|
||||
_metadef_namespace = fakes.create_one_metadef_namespace()
|
||||
_metadef_objects = fakes.create_one_metadef_object()
|
||||
|
||||
expected_columns = (
|
||||
'created_at',
|
||||
'description',
|
||||
'name',
|
||||
'namespace_name',
|
||||
'properties',
|
||||
'required',
|
||||
'updated_at',
|
||||
)
|
||||
expected_data = (
|
||||
_metadef_objects.created_at,
|
||||
_metadef_objects.description,
|
||||
_metadef_objects.name,
|
||||
_metadef_objects.namespace_name,
|
||||
_metadef_objects.properties,
|
||||
_metadef_objects.required,
|
||||
_metadef_objects.updated_at,
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.image_client.get_metadef_object.return_value = (
|
||||
self._metadef_objects
|
||||
)
|
||||
self.cmd = metadef_objects.ShowMetadefObjects(self.app, None)
|
||||
|
||||
def test_object_show(self):
|
||||
arglist = [
|
||||
self._metadef_namespace.namespace,
|
||||
self._metadef_objects.name,
|
||||
]
|
||||
verifylist = []
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Add ``image metadef object show`` command to show the
|
||||
metadata definitions objects inside a specific namespace
|
@ -398,6 +398,7 @@ openstack.image.v2 =
|
||||
image_metadef_namespace_show = openstackclient.image.v2.metadef_namespaces:ShowMetadefNameSpace
|
||||
|
||||
image_metadef_object_create = openstackclient.image.v2.metadef_objects:CreateMetadefObjects
|
||||
image_metadef_object_show = openstackclient.image.v2.metadef_objects:ShowMetadefObjects
|
||||
|
||||
image_metadef_property_create = openstackclient.image.v2.metadef_properties:CreateMetadefProperty
|
||||
image_metadef_property_list = openstackclient.image.v2.metadef_properties:ListMetadefProperties
|
||||
|
Loading…
Reference in New Issue
Block a user