Adds CLI support for `glance md-object-update
`
This patch adds a command "image metadef object update" which update metadata definitions object inside a namespace. Change-Id: I2dd8f54f9224abda5adc7a1b6a1c270c49d473a7
This commit is contained in:
parent
99c7f583df
commit
3cd5ad2c1b
@ -34,6 +34,9 @@ Image v2
|
|||||||
.. autoprogram-cliff:: openstack.image.v2
|
.. autoprogram-cliff:: openstack.image.v2
|
||||||
:command: image metadef object delete
|
:command: image metadef object delete
|
||||||
|
|
||||||
|
.. autoprogram-cliff:: openstack.image.v2
|
||||||
|
:command: image metadef object update
|
||||||
|
|
||||||
.. autoprogram-cliff:: openstack.image.v2
|
.. autoprogram-cliff:: openstack.image.v2
|
||||||
:command: image metadef property create
|
:command: image metadef property create
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ md-object-show,image metadef object show,Describe a specific metadata definition
|
|||||||
md-object-list,image metadef object list,List metadata definitions objects inside a specific namespace.
|
md-object-list,image metadef object list,List metadata definitions objects inside a specific namespace.
|
||||||
md-object-delete,image metadef object delete,Delete a specific metadata definitions object inside a namespace.
|
md-object-delete,image metadef object delete,Delete a specific metadata definitions object inside a namespace.
|
||||||
md-object-property-show,,Describe a specific metadata definitions property inside an object.
|
md-object-property-show,,Describe a specific metadata definitions property inside an object.
|
||||||
md-object-update,,Update metadata definitions object inside a namespace.
|
md-object-update,image metadef 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-create,image metadef property create,Create a new metadata definitions property inside a namespace.
|
||||||
md-property-delete,image metadef property delete,Delete a specific metadata definitions property inside a namespace.
|
md-property-delete,image metadef 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-list,image metadef property list,List metadata definitions properties inside a specific namespace.
|
||||||
|
|
@ -187,3 +187,39 @@ class ListMetadefObjects(command.Lister):
|
|||||||
for md_object in md_objects
|
for md_object in md_objects
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class SetMetadefObject(command.Command):
|
||||||
|
_description = _("Update a metadef object")
|
||||||
|
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super().get_parser(prog_name)
|
||||||
|
parser.add_argument(
|
||||||
|
"namespace",
|
||||||
|
metavar="<namespace>",
|
||||||
|
help=_("Metadef namespace name"),
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"object",
|
||||||
|
metavar="<object>",
|
||||||
|
help=_('Metadef object to be updated'),
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--name",
|
||||||
|
help=_("New name of the object"),
|
||||||
|
)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
image_client = self.app.client_manager.image
|
||||||
|
|
||||||
|
object = image_client.get_metadef_object(
|
||||||
|
parsed_args.object, parsed_args.namespace
|
||||||
|
)
|
||||||
|
kwargs = {}
|
||||||
|
if parsed_args.name:
|
||||||
|
kwargs['name'] = parsed_args.name
|
||||||
|
|
||||||
|
image_client.update_metadef_object(
|
||||||
|
object, parsed_args.namespace, **kwargs
|
||||||
|
)
|
||||||
|
@ -160,3 +160,41 @@ class TestMetadefObjectList(fakes.TestImagev2):
|
|||||||
|
|
||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
self.assertEqual(getattr(self.datalist[0], 'name'), next(data)[0])
|
self.assertEqual(getattr(self.datalist[0], 'name'), next(data)[0])
|
||||||
|
|
||||||
|
|
||||||
|
class TestMetadefObjectSet(fakes.TestImagev2):
|
||||||
|
_metadef_namespace = fakes.create_one_metadef_namespace()
|
||||||
|
_metadef_objects = fakes.create_one_metadef_object()
|
||||||
|
new_metadef_object = fakes.create_one_metadef_object(
|
||||||
|
attrs={'name': 'new_object_name'}
|
||||||
|
)
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super().setUp()
|
||||||
|
|
||||||
|
self.image_client.update_metadef_object.return_value = None
|
||||||
|
self.cmd = metadef_objects.SetMetadefObject(self.app, None)
|
||||||
|
|
||||||
|
def test_object_set_no_options(self):
|
||||||
|
arglist = [
|
||||||
|
self._metadef_namespace.namespace,
|
||||||
|
self._metadef_objects.name,
|
||||||
|
]
|
||||||
|
verifylist = []
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
result = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
|
self.assertIsNone(result)
|
||||||
|
|
||||||
|
def test_object_set(self):
|
||||||
|
arglist = [
|
||||||
|
self._metadef_namespace.namespace,
|
||||||
|
self._metadef_objects.name,
|
||||||
|
'--name',
|
||||||
|
'new_object_name',
|
||||||
|
]
|
||||||
|
verifylist = []
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
result = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
|
self.assertIsNone(result)
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Add ``image metadef object update`` command which
|
||||||
|
updates the attributes of an object.
|
@ -403,6 +403,8 @@ openstack.image.v2 =
|
|||||||
image_metadef_object_show = openstackclient.image.v2.metadef_objects:ShowMetadefObjects
|
image_metadef_object_show = openstackclient.image.v2.metadef_objects:ShowMetadefObjects
|
||||||
image_metadef_object_list = openstackclient.image.v2.metadef_objects:ListMetadefObjects
|
image_metadef_object_list = openstackclient.image.v2.metadef_objects:ListMetadefObjects
|
||||||
image_metadef_object_delete = openstackclient.image.v2.metadef_objects:DeleteMetadefObject
|
image_metadef_object_delete = openstackclient.image.v2.metadef_objects:DeleteMetadefObject
|
||||||
|
image_metadef_object_update = openstackclient.image.v2.metadef_objects:SetMetadefObject
|
||||||
|
|
||||||
|
|
||||||
image_metadef_property_create = openstackclient.image.v2.metadef_properties:CreateMetadefProperty
|
image_metadef_property_create = openstackclient.image.v2.metadef_properties:CreateMetadefProperty
|
||||||
image_metadef_property_delete = openstackclient.image.v2.metadef_properties:DeleteMetadefProperty
|
image_metadef_property_delete = openstackclient.image.v2.metadef_properties:DeleteMetadefProperty
|
||||||
|
Loading…
Reference in New Issue
Block a user