Adds CLI support for ``glance md-namespace-properties-delete``
This patch modifies the command to delete all metadef properties inside a namespace. This operation can be called by `image metadef property delete` Change-Id: Iff9bda0dddfa157be0438a66d1d05da7b0b437c3 Depends-on: https://review.opendev.org/c/openstack/openstacksdk/+/902612
This commit is contained in:
parent
a79cb608b0
commit
5a95ba539c
|
@ -27,7 +27,7 @@ md-namespace-delete,image metadef namespace delete,Delete specified metadata def
|
|||
md-namespace-import,,Import a metadata definitions namespace from file or standard input.
|
||||
md-namespace-list,image metadef namespace list,List metadata definitions namespaces.
|
||||
md-namespace-objects-delete,,Delete all metadata definitions objects inside a specific namespace.
|
||||
md-namespace-properties-delete,,Delete all metadata definitions property inside a specific namespace.
|
||||
md-namespace-properties-delete,image metadef property delete ,Delete all metadata definitions property inside a specific namespace.
|
||||
md-namespace-resource-type-list,image metadef resource type association list,List resource types associated to specific namespace.
|
||||
md-namespace-show,image metadef namespace show,Describe a specific metadata definitions namespace.
|
||||
md-namespace-tags-delete,,Delete all metadata definitions tags inside a specific namespace.
|
||||
|
|
|
|
@ -124,14 +124,21 @@ class DeleteMetadefProperty(command.Command):
|
|||
parser.add_argument(
|
||||
"properties",
|
||||
metavar="<property>",
|
||||
nargs="+",
|
||||
help=_("Metadef propert(ies) to delete (name)"),
|
||||
nargs="*",
|
||||
help=_(
|
||||
"Metadef properties to delete (name)"
|
||||
"(omit this argument to delete all properties in the namespace)"
|
||||
),
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
image_client = self.app.client_manager.image
|
||||
|
||||
if not parsed_args.properties:
|
||||
return image_client.delete_all_metadef_properties(
|
||||
parsed_args.namespace
|
||||
)
|
||||
result = 0
|
||||
for prop in parsed_args.properties:
|
||||
try:
|
||||
|
|
|
@ -91,6 +91,7 @@ class TestMetadefPropertyDelete(image_fakes.TestImagev2):
|
|||
super().setUp()
|
||||
|
||||
self.cmd = metadef_properties.DeleteMetadefProperty(self.app, None)
|
||||
self.image_client.delete_all_metadef_properties.return_value = None
|
||||
|
||||
def test_metadef_property_delete(self):
|
||||
arglist = ['namespace', 'property']
|
||||
|
@ -111,15 +112,6 @@ class TestMetadefPropertyDelete(image_fakes.TestImagev2):
|
|||
[],
|
||||
)
|
||||
|
||||
arglist = ['namespace']
|
||||
self.assertRaises(
|
||||
tests_utils.ParserException,
|
||||
self.check_parser,
|
||||
self.cmd,
|
||||
arglist,
|
||||
[],
|
||||
)
|
||||
|
||||
def test_metadef_property_delete_exception(self):
|
||||
arglist = ['namespace', 'property']
|
||||
verifylist = []
|
||||
|
@ -133,6 +125,19 @@ class TestMetadefPropertyDelete(image_fakes.TestImagev2):
|
|||
exceptions.CommandError, self.cmd.take_action, parsed_args
|
||||
)
|
||||
|
||||
def test_property_delete_all(self):
|
||||
arglist = ['namespace']
|
||||
|
||||
verifylist = []
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.assertIsNone(result)
|
||||
self.image_client.delete_all_metadef_properties.assert_called_with(
|
||||
'namespace'
|
||||
)
|
||||
|
||||
|
||||
class TestMetadefPropertyList(image_fakes.TestImagev2):
|
||||
_metadef_property = [image_fakes.create_one_metadef_property()]
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
features:
|
||||
- |
|
||||
Modifies `image property delete` to delete
|
||||
all metadef properties inside a namespace.
|
Loading…
Reference in New Issue