Exemplo n.º 1
0
    def _enforce_image_property_quota(self, image):
        if CONF.image_property_quota < 0:
            # If value is negative, allow unlimited number of properties
            return

        attempted = len(image.extra_properties)
        maximum = CONF.image_property_quota
        if attempted > maximum:
            raise exception.ImagePropertyLimitExceeded(attempted=attempted,
                                                       maximum=maximum)
Exemplo n.º 2
0
    def _enforce_image_property_quota(self, attempted):
        if CONF.image_property_quota < 0:
            # If value is negative, allow unlimited number of properties
            return

        maximum = CONF.image_property_quota
        if attempted > maximum:
            kwargs = {'attempted': attempted, 'maximum': maximum}
            exc = exception.ImagePropertyLimitExceeded(**kwargs)
            LOG.debug(six.text_type(exc))
            raise exc
Exemplo n.º 3
0
    def _enforce_image_property_quota(self, properties):
        if CONF.image_property_quota < 0:
            # If value is negative, allow unlimited number of properties
            return

        attempted = len([
            x for x in properties.keys()
            if not x.startswith(glance.api.common.GLANCE_RESERVED_NS)
        ])

        maximum = CONF.image_property_quota
        if attempted > maximum:
            kwargs = {'attempted': attempted, 'maximum': maximum}
            exc = exception.ImagePropertyLimitExceeded(**kwargs)
            LOG.debug(encodeutils.exception_to_unicode(exc))
            raise exc