Module ImportFrom alias Import alias Import alias ImportFrom alias ImportFrom alias identifier ImportFrom alias identifier ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias Import alias ImportFrom alias ImportFrom alias ImportFrom alias alias alias ImportFrom alias alias alias ClassDef bases NameLoad NameLoad NameLoad NameLoad AttributeLoad NameLoad attr body Expr Str ClassDef bases body Assign NameStore TupleLoad TupleLoad Str Str Str decorator_list Assign NameStore Call AttributeLoad NameLoad attr keyword Num Assign NameStore Call AttributeLoad NameLoad attr keyword Num Assign NameStore Call AttributeLoad NameLoad attr keyword Num keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr Str Str Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call NameLoad FunctionDef arguments args NameParam defaults body Return BinOpMod Str TupleLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str If CompareEq AttributeLoad NameLoad attr Num body Return NameLoad Assign NameStore AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr If CompareIsNot NameLoad NameLoad body AugAssignAdd NameStore NameLoad If CompareIsNot NameLoad NameLoad body Assign NameStore BinOpMult NameLoad NameLoad Return CompareGt NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Return TupleLoad Str Str Str Str Str decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr TryExcept body Return Call NameLoad GeneratorExp NameLoad comprehension NameStore NameLoad CompareEq AttributeLoad NameLoad attr AttributeLoad NameLoad attr handlers ExceptHandler type NameLoad body Return decorator_list FunctionDef arguments args NameParam defaults body Return CompareGtE AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list decorator_list NameLoad Call AttributeLoad NameLoad attr keyword ListLoad Str Str FunctionDef arguments args NameParam defaults body FunctionDef arguments args NameParam NameParam defaults vararg kwarg body TryExcept body Return Call NameLoad NameLoad NameLoad NameLoad NameLoad handlers ExceptHandler type AttributeLoad NameLoad attr body If UnaryOpNot Call AttributeLoad NameLoad attr Str NameLoad body Raise Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad NameLoad NameLoad decorator_list Call AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list ClassDef bases AttributeLoad NameLoad attr body Expr Str Assign NameStore ListLoad ClassDef bases Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Assign NameStore NameLoad decorator_list ClassDef bases body Assign NameStore NameLoad decorator_list Assign NameStore Call AttributeLoad NameLoad attr Str keyword Str FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr keyword NameLoad Assign AttributeStore NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr keyword NameLoad Assign AttributeStore NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr keyword NameLoad AugAssignAdd AttributeStore NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr decorator_list NameLoad FunctionDef arguments args NameParam defaults body If Call NameLoad NameLoad NameLoad body Return ListComp NameLoad comprehension NameStore Call AttributeLoad NameLoad attr Call NameLoad NameLoad NameLoad Return ListLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str Assign NameStore ListLoad For TupleStore NameStore NameStore Call AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr keyword NameLoad If Call AttributeLoad NameLoad attr NameLoad body Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr BinOpAdd AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr If UnaryOpNot NameLoad body Return NameLoad orelse If NameLoad body Raise Call AttributeLoad NameLoad attr BinOpMod Str Call AttributeLoad Str attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Return AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad ListLoad Str Str body Expr Str If UnaryOpNot NameLoad body Return Dict If CompareIs NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call NameLoad ListComp AttributeLoad AttributeLoad NameLoad attr attr comprehension NameStore NameLoad If CompareGt Call NameLoad NameLoad Num body Raise Call AttributeLoad NameLoad attr Str Assign NameStore Dict Str Str Str Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr SubscriptLoad NameLoad Index Num ListComp AttributeLoad NameLoad attr comprehension NameStore NameLoad NameLoad Assign NameStore Dict If CompareIn Str NameLoad body Assign NameStore Call AttributeLoad Call AttributeLoad Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad attr Str attr keyword Call NameLoad Str For NameStore NameLoad body Assign SubscriptStore NameLoad Index BinOpAdd SubscriptLoad NameLoad Index Str Str SubscriptLoad NameLoad Index Str If CompareIn Str NameLoad body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr keyword Num NameLoad Assign NameStore Call NameLoad Call AttributeLoad NameLoad attr Str keyword NameLoad For NameStore NameLoad body Assign SubscriptStore NameLoad Index NameLoad Num Assign NameStore Call AttributeLoad Call AttributeLoad Call AttributeLoad Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad attr keyword NameLoad attr Str attr keyword Call NameLoad Str For NameStore NameLoad body Assign SubscriptStore NameLoad Index SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str Return NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Assign NameStore ListComp Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad comprehension NameStore NameLoad Return Call NameLoad AttributeLoad NameLoad attr NameLoad Call NameLoad Lambda arguments args defaults Num decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam defaults body For TupleStore NameStore NameStore Call AttributeLoad NameLoad attr body If CompareNotEq NameLoad Num body AugAssignAdd SubscriptStore NameLoad Index NameLoad NameLoad For NameStore Call AttributeLoad NameLoad attr body If CompareNotIn NameLoad NameLoad body Assign SubscriptStore NameLoad Index NameLoad Num Return NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam defaults NameLoad body If BoolOpOr UnaryOpNot Call NameLoad NameLoad Str UnaryOpNot AttributeLoad AttributeLoad NameLoad attr attr body Assign AttributeStore NameLoad attr Call AttributeLoad Call NameLoad Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Lambda arguments args NameParam defaults Call NameLoad NameLoad AttributeLoad NameLoad attr attr If CompareIsNot NameLoad NameLoad body Return ListComp NameLoad comprehension NameStore AttributeLoad NameLoad attr Call NameLoad NameLoad NameLoad Return AttributeLoad NameLoad attr decorator_list NameLoad FunctionDef arguments args NameParam defaults body Return BinOpAdd AttributeLoad NameLoad attr ListComp AttributeLoad NameLoad attr comprehension NameStore Call AttributeLoad NameLoad attr decorator_list NameLoad decorator_list ClassDef bases NameLoad body Expr Str ClassDef bases AttributeLoad NameLoad attr body Assign NameStore NameLoad decorator_list ClassDef bases body Assign NameStore NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Assign AttributeStore NameLoad attr NameLoad Expr Call NameLoad AttributeLoad NameLoad attr NameLoad NameLoad ImportFrom alias If Call NameLoad NameLoad AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr keyword NameLoad keyword NameLoad decorator_list NameLoad decorator_list
N/A __future__ unicode_literals N/A functools N/A inspect collections defaultdict django.contrib.contenttypes fields ct_fields django.contrib.contenttypes models ct_models django.db models django.db.models Sum django.utils six django.utils.encoding python_2_unicode_compatible model_utils FieldTracker N/A reversion nodeconductor.logging.loggers LoggableMixin nodeconductor.logging.models AlertThresholdMixin nodeconductor.quotas exceptions managers fields nodeconductor.core.models UuidMixin ReversionMixin DescendantMixin Quota N/A UuidMixin AlertThresholdMixin LoggableMixin ReversionMixin N/A models Model N/A N/A 
    Abstract quota for any resource.

    Quota can exist without scope: for example, a quota for all projects or all
    customers on site.
    If quota limit is set to -1 quota will never be exceeded.
     Meta N/A N/A N/A unique_together N/A N/A name content_type object_id N/A N/A limit N/A N/A models FloatField default -1 N/A usage N/A N/A models FloatField default 0 N/A name N/A N/A models CharField max_length 150 db_index True N/A content_type N/A N/A models ForeignKey N/A ct_models ContentType null True N/A object_id N/A N/A models PositiveIntegerField null True N/A scope N/A N/A ct_fields GenericForeignKey content_type object_id N/A objects N/A N/A managers QuotaManager scope N/A tracker N/A FieldTracker __str__ N/A N/A self N/A N/A N/A N/A %s quota for %s N/A N/A self name N/A self scope N/A is_exceeded N/A N/A self delta threshold N/A None None N/A N/A 
        Check is quota exceeded

        If delta is not None then checks if quota exceeds with additional delta usage
        If threshold is not None then checks if quota usage over threshold * limit
         N/A N/A N/A self limit -1 N/A N/A False N/A usage N/A self usage N/A limit N/A self limit N/A N/A delta None N/A N/A usage delta N/A N/A threshold None N/A N/A limit N/A threshold limit N/A N/A usage limit N/A get_log_fields N/A N/A self N/A N/A N/A N/A uuid name limit usage scope N/A get_field N/A N/A self N/A N/A N/A fields N/A N/A N/A self scope get_quotas_fields N/A N/A N/A N/A next N/A f N/A f fields N/A N/A f name N/A self name N/A N/A N/A StopIteration N/A N/A N/A is_over_threshold N/A N/A self N/A N/A N/A N/A N/A self usage N/A self threshold N/A N/A python_2_unicode_compatible N/A N/A reversion register fields N/A usage limit _fail_silently N/A N/A method N/A N/A wrapped N/A N/A self quota_name N/A args kwargs N/A N/A N/A N/A N/A method self quota_name args kwargs N/A N/A N/A N/A Quota DoesNotExist N/A N/A N/A N/A N/A kwargs get fail_silently False N/A N/A N/A N/A Quota DoesNotExist N/A Object %s does not have quota with name %s N/A self quota_name N/A N/A N/A functools wraps method N/A wrapped N/A QuotaModelMixin N/A N/A models Model N/A N/A 
    Add general fields and methods to model for quotas usage.

    Model with quotas have inherit this mixin.
    For quotas implementation such methods and fields have to be defined:
      - class Quota(QuotaModelMixin) - class with quotas fields as attributes.
      - can_user_update_quotas(self, user) - Return True if user has permission to update quotas of this object.
      - QUOTAS_NAMES - List of names for object quotas. Deprecated, define quotas as fields in Quotas class instead.
      - GLOBAL_COUNT_QUOTA_NAME - Name of global count quota. It presents - global quota will be automatically created
                                  for model. Optional attribute.

    Example:
        Customer(models.Model):
            ...
            Quotas(quotas_models.QuotaModelMixin.Quotas):
                nc_user_count = quotas_fields.QuotaField()  # define user count quota for customers

            # optional descriptor to direct access to quota
            nc_user_count = quotas_fields.QuotaLimitField(quota_field=Quotas.nc_user_count)

            def can_user_update_quotas(self, user):
                # only staff user can edit Customer quotas
                return user.is_staff

    Use such methods to change objects quotas:
      set_quota_limit, set_quota_usage, add_quota_usage.

    Helper methods validate_quota_change and get_sum_of_quotas_as_dict provide common operations with objects quotas.
    Check methods docstrings for more details.
     N/A QUOTAS_NAMES N/A Quotas N/A N/A N/A six with_metaclass N/A fields FieldsContainerMeta N/A N/A enable_fields_caching True N/A Meta N/A N/A N/A abstract True N/A N/A quotas N/A N/A ct_fields GenericRelation quotas.Quota related_query_name quotas set_quota_limit N/A N/A self quota_name limit fail_silently N/A False N/A N/A quota N/A N/A N/A self quotas get name quota_name N/A N/A quota limit limit N/A N/A N/A quota save N/A _fail_silently set_quota_usage N/A N/A self quota_name usage fail_silently N/A False N/A N/A quota N/A N/A N/A self quotas get name quota_name N/A N/A quota usage usage N/A N/A N/A quota save N/A _fail_silently add_quota_usage N/A N/A self quota_name usage_delta fail_silently N/A False N/A N/A quota N/A N/A N/A self quotas get name quota_name N/A N/A quota usage usage_delta N/A N/A N/A quota save N/A _fail_silently get_quota_ancestors N/A N/A self N/A N/A N/A N/A isinstance self DescendantMixin N/A N/A N/A a N/A a N/A N/A self get_ancestors N/A isinstance a QuotaModelMixin N/A N/A N/A validate_quota_change N/A N/A self quota_deltas raise_exception N/A False N/A N/A 
        Get error messages about object and his ancestor quotas that will be exceeded if quota_delta will be added.

        raise_exception - if True QuotaExceededException will be raised if validation fails
        quota_deltas - dictionary of quotas deltas, example:
        {
            'ram': 1024,
            'storage': 2048,
            ...
        }
        Example of output:
            ['ram quota limit: 1024, requires: 2048(instance#1)', ...]

         N/A errors N/A N/A N/A name delta N/A N/A quota_deltas iteritems N/A N/A quota N/A N/A N/A self quotas get name name N/A N/A N/A quota is_exceeded delta N/A N/A N/A N/A errors append N/A %s quota limit: %s, requires %s (%s)
 N/A N/A quota name N/A quota limit N/A N/A quota usage delta N/A quota scope N/A N/A raise_exception N/A N/A errors N/A N/A errors N/A N/A N/A N/A exceptions QuotaExceededException N/A One or more quotas were exceeded: %s N/A N/A ; join errors N/A can_user_update_quotas N/A N/A self user N/A N/A N/A 
        Return True if user has permission to update quota
         N/A N/A user is_staff N/A get_sum_of_quotas_as_dict N/A N/A cls scopes quota_names fields N/A None N/A usage limit N/A N/A 
        Return dictionary with sum of all scopes' quotas.

        Dictionary format:
        {
            'quota_name1': 'sum of limits for quotas with such quota_name1',
            'quota_name1_usage': 'sum of usages for quotas with such quota_name1',
            ...
        }
        All `scopes` have to be instances of the same model.
        `fields` keyword argument defines sum of which fields of quotas will present in result.
         N/A N/A scopes N/A N/A N/A N/A N/A quota_names None N/A N/A quota_names N/A N/A cls get_quotas_names N/A scope_models N/A set N/A N/A N/A scope _meta model N/A scope scopes N/A N/A N/A len scope_models 1 N/A N/A N/A N/A exceptions QuotaError All scopes have to be instances of the same model N/A filter_kwargs N/A content_type object_id__in name__in N/A N/A N/A N/A ct_models ContentType objects get_for_model N/A scopes N/A 0 N/A N/A scope id N/A scope scopes quota_names N/A result N/A N/A N/A usage fields N/A N/A items N/A N/A N/A N/A N/A N/A N/A Quota objects filter filter_kwargs values name annotate usage N/A Sum usage N/A item items N/A N/A N/A result N/A N/A N/A item N/A name _usage N/A item N/A usage N/A N/A limit fields N/A N/A unlimited_quotas N/A N/A N/A Quota objects filter limit -1 filter_kwargs N/A unlimited_quotas N/A list N/A N/A unlimited_quotas values_list name flat True N/A quota_name unlimited_quotas N/A N/A N/A result N/A quota_name -1 N/A items N/A N/A N/A N/A N/A N/A N/A N/A N/A Quota objects filter filter_kwargs exclude name__in unlimited_quotas values name annotate limit N/A Sum limit N/A item items N/A N/A N/A result N/A N/A item N/A name N/A item N/A limit N/A result N/A classmethod get_sum_of_quotas_for_querysets N/A N/A cls querysets quota_names N/A None N/A N/A partial_sums N/A N/A N/A N/A qs model get_sum_of_quotas_as_dict qs quota_names N/A qs querysets N/A N/A reduce N/A cls _sum_dicts partial_sums N/A defaultdict N/A N/A N/A N/A 0 N/A classmethod _sum_dicts N/A N/A cls total partial N/A N/A N/A N/A key val N/A N/A partial items N/A N/A N/A val -1 N/A N/A N/A total N/A key val N/A key N/A N/A partial keys N/A N/A N/A key total N/A N/A N/A total N/A key -1 N/A total N/A classmethod get_quotas_fields N/A N/A cls field_class N/A None N/A N/A N/A N/A N/A hasattr cls _quota_fields N/A N/A N/A cls Quotas enable_fields_caching N/A N/A N/A cls _quota_fields N/A N/A N/A dict N/A N/A inspect getmembers N/A cls Quotas N/A N/A N/A m N/A N/A isinstance m N/A fields QuotaField values N/A N/A field_class None N/A N/A N/A v N/A v N/A cls _quota_fields N/A isinstance v field_class N/A N/A cls _quota_fields N/A classmethod get_quotas_names N/A N/A cls N/A N/A N/A N/A N/A cls QUOTAS_NAMES N/A N/A f name N/A f N/A N/A cls get_quotas_fields N/A classmethod N/A ExtendableQuotaModelMixin N/A QuotaModelMixin N/A N/A  Allows to add quotas to model in runtime.

    Example:
        from nodeconductor.quotas.fields import QuotaField

        QuotaScopeModel.add_quota_field(
            name='quota_name',
            quota_field=QuotaField(...),
        )
     Quotas N/A N/A QuotaModelMixin Quotas N/A N/A enable_fields_caching False N/A Meta N/A N/A N/A abstract True N/A add_quota_field N/A N/A cls name quota_field N/A N/A N/A N/A quota_field name name N/A N/A setattr N/A cls Quotas name quota_field nodeconductor.quotas.apps QuotasConfig N/A N/A isinstance quota_field N/A fields CounterQuotaField N/A N/A N/A N/A QuotasConfig register_counter_field_signals model cls counter_field quota_field N/A classmethod N/A