diff options
| author | Unmesh Gurjar <unmesh.gurjar@vertex.co.in> | 2012-04-02 11:52:37 +0530 |
|---|---|---|
| committer | Unmesh Gurjar <unmesh.gurjar@vertex.co.in> | 2012-04-12 10:59:32 +0530 |
| commit | 56dfbb59f9ad61d7f45d97f233db5d1cf0a46879 (patch) | |
| tree | 6b5f309d2649ceaabf5d8ed63a59548915f5fc56 /nova/compute | |
| parent | 42f3bec10c7f7374ad4e9752b275b02ca2b2fdb9 (diff) | |
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
Diffstat (limited to 'nova/compute')
| -rw-r--r-- | nova/compute/api.py | 12 |
1 files changed, 8 insertions, 4 deletions
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 |
