Add "image metadef property show" command
Change-Id: I326735014dfcb4477b109a99aa31f71b07b91c7b
This commit is contained in:
parent
5fb922e469
commit
190f06a963
@ -41,7 +41,7 @@ md-object-update,,Update metadata definitions object inside a namespace.
|
||||
md-property-create,,Create a new metadata definitions property inside a namespace.
|
||||
md-property-delete,,Delete a specific metadata definitions property inside a namespace.
|
||||
md-property-list,image metadef property list,List metadata definitions properties inside a specific namespace.
|
||||
md-property-show,,Describe a specific metadata definitions property inside a namespace.
|
||||
md-property-show,image metadef property show,Describe a specific metadata definitions property inside a namespace.
|
||||
md-property-update,,Update metadata definitions property inside a namespace.
|
||||
md-resource-type-associate,,Associate resource type with a metadata definitions namespace.
|
||||
md-resource-type-deassociate,,Deassociate resource type with a metadata definitions namespace.
|
||||
|
|
@ -44,3 +44,55 @@ class ListMetadefProperties(command.Lister):
|
||||
for prop in props
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
class ShowMetadefProperty(command.ShowOne):
|
||||
_description = _("Describe a specific property from 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(
|
||||
"property_name",
|
||||
metavar="<property_name>",
|
||||
help=_("Property to show"),
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
image_client = self.app.client_manager.image
|
||||
data = image_client.get_metadef_property(
|
||||
parsed_args.property_name, parsed_args.namespace_name
|
||||
)
|
||||
data = data.to_dict(ignore_none=True, original_names=True)
|
||||
info = {
|
||||
key: data[key]
|
||||
for key in [
|
||||
'namespace_name',
|
||||
'name',
|
||||
'type',
|
||||
'title',
|
||||
'description',
|
||||
'operators',
|
||||
'default',
|
||||
'is_readonly',
|
||||
'minimum',
|
||||
'maximum',
|
||||
'enum',
|
||||
'pattern',
|
||||
'min_length',
|
||||
'max_length',
|
||||
'items',
|
||||
'require_unique_items',
|
||||
'min_items',
|
||||
'max_items',
|
||||
'allow_additional_items',
|
||||
]
|
||||
if key in data
|
||||
}
|
||||
|
||||
return zip(*sorted(info.items()))
|
||||
|
@ -40,3 +40,36 @@ class TestMetadefPropertyList(image_fakes.TestImagev2):
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(getattr(self.datalist[0], 'name'), next(data)[0])
|
||||
|
||||
|
||||
class TestMetadefPropertyShow(image_fakes.TestImagev2):
|
||||
_metadef_property = image_fakes.create_one_metadef_property()
|
||||
|
||||
expected_columns = (
|
||||
'name',
|
||||
'title',
|
||||
'type',
|
||||
)
|
||||
expected_data = (
|
||||
_metadef_property.name,
|
||||
_metadef_property.title,
|
||||
_metadef_property.type,
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.image_client.get_metadef_property.return_value = (
|
||||
self._metadef_property
|
||||
)
|
||||
|
||||
self.cmd = metadef_properties.ShowMetadefProperty(self.app, None)
|
||||
|
||||
def test_metadef_property_show(self):
|
||||
arglist = ['my-namespace', 'my-property']
|
||||
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)
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Add ``image metadef property show`` command to show details
|
||||
about a metadef property inside a specific namespace.
|
@ -398,6 +398,7 @@ openstack.image.v2 =
|
||||
image_metadef_namespace_show = openstackclient.image.v2.metadef_namespaces:ShowMetadefNameSpace
|
||||
|
||||
image_metadef_property_list = openstackclient.image.v2.metadef_properties:ListMetadefProperties
|
||||
image_metadef_property_show = openstackclient.image.v2.metadef_properties:ShowMetadefProperty
|
||||
|
||||
image_metadef_resource_type_list = openstackclient.image.v2.metadef_resource_types:ListMetadefResourceTypes
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user