def _check_metadata_properties(self, metadata=None): if not metadata: metadata = {} for k, v in metadata.iteritems(): if len(k) == 0: msg = _("Metadata property key blank") LOG.warn(msg) raise exception.InvalidVolumeMetadata(reason=msg) if len(k) > 255: msg = _("Metadata property key greater than 255 characters") LOG.warn(msg) raise exception.InvalidVolumeMetadataSize(reason=msg) if len(v) > 255: msg = _("Metadata property value greater than 255 characters") LOG.warn(msg) raise exception.InvalidVolumeMetadataSize(reason=msg)
def _check_metadata_properties(metadata=None): """Checks that the volume metadata properties are valid.""" if not metadata: metadata = {} for (k, v) in metadata.iteritems(): if len(k) == 0: msg = _("Metadata property key blank") LOG.warn(msg) raise exception.InvalidVolumeMetadata(reason=msg) if len(k) > 255: msg = _("Metadata property key %s greater than 255 " "characters") % k LOG.warn(msg) raise exception.InvalidVolumeMetadataSize(reason=msg) if len(v) > 255: msg = _("Metadata property key %s value greater than" " 255 characters") % k LOG.warn(msg) raise exception.InvalidVolumeMetadataSize(reason=msg)
def check_metadata_properties(metadata=None): """Checks that the volume metadata properties are valid.""" if not metadata: metadata = {} for k, v in metadata.items(): try: check_string_length(k, "Metadata key: %s" % k, min_length=1) check_string_length(v, "Value for metadata key: %s" % k) except exception.InvalidInput as exc: raise exception.InvalidVolumeMetadata(reason=exc) # for backward compatibility if len(k) > 255: msg = _("Metadata property key %s greater than 255 " "characters.") % k raise exception.InvalidVolumeMetadataSize(reason=msg) if len(v) > 255: msg = _("Metadata property key %s value greater than " "255 characters.") % k raise exception.InvalidVolumeMetadataSize(reason=msg)
def check_metadata_properties(metadata=None): """Checks that the volume metadata properties are valid.""" if not metadata: metadata = {} for k, v in metadata.items(): if len(k) == 0: msg = _("Metadata property key blank.") LOG.debug(msg) raise exception.InvalidVolumeMetadata(reason=msg) if len(k) > 255: msg = _("Metadata property key %s greater than 255 " "characters.") % k LOG.debug(msg) raise exception.InvalidVolumeMetadataSize(reason=msg) if v is None: msg = _("Metadata property key '%s' value is None.") % k raise exception.InvalidVolumeMetadata(reason=msg) if len(v) > 255: msg = _("Metadata property key %s value greater than " "255 characters.") % k LOG.debug(msg) raise exception.InvalidVolumeMetadataSize(reason=msg)