From 56dfbb59f9ad61d7f45d97f233db5d1cf0a46879 Mon Sep 17 00:00:00 2001 From: Unmesh Gurjar Date: Mon, 2 Apr 2012 11:52:37 +0530 Subject: Fixed metadata validation err. Fixes bug 965102. 1. Fixed the error message on specifying invalid server metadata key/value. 2. Added check to disallow specifying blank metadata key. 3. Added unit test coverage. Addressed review comments. Change-Id: I1f0002971dc236045d6e622641f46a4a30249d54 --- nova/compute/api.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'nova/compute') diff --git a/nova/compute/api.py b/nova/compute/api.py index aa584dba5..60c4a7a70 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -204,12 +204,16 @@ class API(BaseAPI): # In future, we may support more variable length strings, so we act # as if this is quota-controlled for forwards compatibility for k, v in metadata.iteritems(): + if len(k) == 0: + msg = _("Metadata property key blank") + LOG.warn(msg) + raise exception.QuotaError(code="MetadataKeyUnspecified") if len(k) > 255 or len(v) > 255: - pid = context.project_id - msg = _("Quota exceeded for %(pid)s, metadata property " - "key or value too long") % locals() + msg = _("Metadata property key or value greater than 255 " + "characters") LOG.warn(msg) - raise exception.QuotaError(code="MetadataLimitExceeded") + raise exception.QuotaError( + code="MetadataKeyValueLimitExceeded") def _check_requested_networks(self, context, requested_networks): """ Check if the networks requested belongs to the project -- cgit