From 2081befb9212a44442f0a3d4e7ec5d72aa152bb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Unbekandt?= Date: Thu, 11 Jul 2019 14:20:08 +0200 Subject: [PATCH] Can't create a metadata named key, clear, delete We now pass metadata as a dictionnary and not as keyword arguments since _metadata method already have 3 keywords arguments (key, clear and delete) which couldn't be used as metadata keys. Change-Id: Iee3773e4e9a4187bd1557f400aa966f80e3acb3c Story: 2005085 Task: 35787 --- openstack/compute/v2/metadata.py | 5 +++-- .../notes/metadata-key-name-bugfix-77612a825c5145d7.yaml | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/metadata-key-name-bugfix-77612a825c5145d7.yaml diff --git a/openstack/compute/v2/metadata.py b/openstack/compute/v2/metadata.py index e585871f7..b1f554d1e 100644 --- a/openstack/compute/v2/metadata.py +++ b/openstack/compute/v2/metadata.py @@ -19,7 +19,8 @@ from openstack import utils class MetadataMixin(object): def _metadata(self, method, key=None, clear=False, delete=False, - **metadata): + metadata=None): + metadata = metadata or {} for k, v in metadata.items(): if not isinstance(v, six.string_types): raise ValueError("The value for %s (%s) must be " @@ -84,7 +85,7 @@ class MetadataMixin(object): if not metadata: return dict() - result = self._metadata(session.post, **metadata) + result = self._metadata(session.post, metadata=metadata) return result["metadata"] def delete_metadata(self, session, keys): diff --git a/releasenotes/notes/metadata-key-name-bugfix-77612a825c5145d7.yaml b/releasenotes/notes/metadata-key-name-bugfix-77612a825c5145d7.yaml new file mode 100644 index 000000000..892fb85f2 --- /dev/null +++ b/releasenotes/notes/metadata-key-name-bugfix-77612a825c5145d7.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - Fixed a bug related to metadata's key name. An exception was + raised when setting it to "delete"," clear" or "key"