manila.quota
Module¶Quotas for shares.
AbsoluteResource
(name, flag=None)Bases: manila.quota.BaseResource
Describe a non-reservable resource.
BaseResource
(name, flag=None)Bases: object
Describe a single resource for quota checking.
default
Return the default value of the quota.
CountableResource
(name, count, flag=None)Bases: manila.quota.AbsoluteResource
Describe a countable resource.
Describe a resource where the counts aren’t based solely on the project ID.
DbQuotaDriver
Bases: object
Database Quota driver.
Driver to perform necessary checks to enforce quotas and obtain quota information. The default driver utilizes the local database.
commit
(context, reservations, project_id=None, user_id=None, share_type_id=None)Commit reservations.
Parameters: |
|
---|
destroy_all_by_project
(context, project_id)Destroy metadata associated with a project.
Destroy all quotas, usages, and reservations associated with a project.
Parameters: |
|
---|
destroy_all_by_project_and_share_type
(context, project_id, share_type_id)Destroy metadata associated with a project and share_type.
Destroy all quotas, usages, and reservations associated with a project and share_type.
Parameters: |
|
---|
destroy_all_by_project_and_user
(context, project_id, user_id)Destroy metadata associated with a project and user.
Destroy all quotas, usages, and reservations associated with a project and user.
Parameters: |
|
---|
expire
(context)Expire reservations.
Explores all currently existing reservations and rolls back any that have expired.
Parameters: | context – The request context, for access checks. |
---|
get_by_class
(context, quota_class, resource)Get a specific quota by quota class.
get_class_quotas
(context, resources, quota_class, defaults=True)Retrieve quotas for a quota class.
Given a list of resources, retrieve the quotas for the given quota class.
Parameters: |
|
---|
get_defaults
(context, resources)Given a list of resources, retrieve the default quotas.
Parameters: |
|
---|
get_project_quotas
(context, resources, project_id, quota_class=None, defaults=True, usages=True, remains=False)Retrieve quotas for project.
Given a list of resources, retrieve the quotas for the given project.
Parameters: |
|
---|
get_settable_quotas
(context, resources, project_id, user_id=None, share_type_id=None)Retrieve range of settable quotas.
Given a list of resources, retrieve the range of settable quotas for the given user or project.
Parameters: |
|
---|
get_share_type_quotas
(context, resources, project_id, share_type_id, quota_class=None, defaults=True, usages=True)Retrieve quotas for share_type and project.
Given a list of resources, retrieve the quotas for the given share_type and project.
Parameters: |
|
---|
get_user_quotas
(context, resources, project_id, user_id, quota_class=None, defaults=True, usages=True)Retrieve quotas for user and project.
Given a list of resources, retrieve the quotas for the given user and project.
Parameters: |
|
---|
reserve
(context, resources, deltas, expire=None, project_id=None, user_id=None, share_type_id=None)Check quotas and reserve resources.
For counting quotas–those quotas for which there is a usage synchronization function–this method checks quotas against current usage and the desired deltas.
This method will raise a QuotaResourceUnknown exception if a given resource is unknown or if it does not have a usage synchronization function.
If any of the proposed values is over the defined quota, an OverQuota exception will be raised with the sorted list of the resources which are too high. Otherwise, the method returns a list of reservation UUIDs which were created.
Parameters: |
|
---|
rollback
(context, reservations, project_id=None, user_id=None, share_type_id=None)Roll back reservations.
Parameters: |
|
---|
usage_reset
(context, resources)Reset usage records.
Reset the usage records for a particular user on a list of resources. This will force that user’s usage records to be refreshed the next time a reservation is made.
Note: this does not affect the currently outstanding reservations the user has; those reservations must be committed or rolled back (or expired).
Parameters: |
|
---|
QuotaEngine
(quota_driver_class=None)Bases: object
Represent the set of recognized quotas.
commit
(context, reservations, project_id=None, user_id=None, share_type_id=None)Commit reservations.
Parameters: |
|
---|
count
(context, resource, *args, **kwargs)Count a resource.
For countable resources, invokes the count() function and returns its result. Arguments following the context and resource are passed directly to the count function declared by the resource.
Parameters: |
|
---|
destroy_all_by_project
(context, project_id)Destroy metadata associated with a project.
Destroy all quotas, usages, and reservations associated with a project.
Parameters: |
|
---|
destroy_all_by_project_and_share_type
(context, project_id, share_type_id)Destroy metadata associated with a project and share_type.
Destroy all quotas, usages, and reservations associated with a project and share_type.
Parameters: |
|
---|
destroy_all_by_project_and_user
(context, project_id, user_id)Destroy metadata associated with a project and user.
Destroy all quotas, usages, and reservations associated with a project and user.
Parameters: |
|
---|
expire
(context)Expire reservations.
Explores all currently existing reservations and rolls back any that have expired.
Parameters: | context – The request context, for access checks. |
---|
get_by_class
(context, quota_class, resource)Get a specific quota by quota class.
get_class_quotas
(context, quota_class, defaults=True)Retrieve the quotas for the given quota class.
Parameters: |
|
---|
get_defaults
(context)Retrieve the default quotas.
Parameters: | context – The request context, for access checks. |
---|
get_project_quotas
(context, project_id, quota_class=None, defaults=True, usages=True, remains=False)Retrieve the quotas for the given project.
Parameters: |
|
---|
get_settable_quotas
(context, project_id, user_id=None, share_type_id=None)Get settable quotas.
Given a list of resources, retrieve the range of settable quotas for the given user or project.
Parameters: |
|
---|
get_share_type_quotas
(context, project_id, share_type_id, quota_class=None, defaults=True, usages=True)Retrieve the quotas for the given user and project.
Parameters: |
|
---|
get_user_quotas
(context, project_id, user_id, quota_class=None, defaults=True, usages=True)Retrieve the quotas for the given user and project.
Parameters: |
|
---|
register_resource
(resource)Register a resource.
register_resources
(resources)Register a list of resources.
reserve
(context, expire=None, project_id=None, user_id=None, share_type_id=None, **deltas)Check quotas and reserve resources.
For counting quotas–those quotas for which there is a usage synchronization function–this method checks quotas against current usage and the desired deltas. The deltas are given as keyword arguments, and current usage and other reservations are factored into the quota check.
This method will raise a QuotaResourceUnknown exception if a given resource is unknown or if it does not have a usage synchronization function.
If any of the proposed values is over the defined quota, an OverQuota exception will be raised with the sorted list of the resources which are too high. Otherwise, the method returns a list of reservation UUIDs which were created.
Parameters: |
|
---|
resources
rollback
(context, reservations, project_id=None, user_id=None, share_type_id=None)Roll back reservations.
Parameters: |
|
---|
usage_reset
(context, resources)Reset usage records.
Reset the usage records for a particular user on a list of resources. This will force that user’s usage records to be refreshed the next time a reservation is made.
Note: this does not affect the currently outstanding reservations the user has; those reservations must be committed or rolled back (or expired).
Parameters: |
|
---|
ReservableResource
(name, sync, flag=None)Bases: manila.quota.BaseResource
Describe a reservable resource.
manila.policy
Module¶Policy Engine For Manila
authorize
(context, action, target, do_raise=True, exc=None)Verifies that the action is valid on the target in this context.
Parameters: |
|
---|---|
Raises: | manila.exception.PolicyNotAuthorized – if verification fails and do_raise is True. Or if ‘exc’ is specified it will raise an exception of that type. |
Returns: | returns a non-False value (not necessarily “True”) if authorized, and the exact value False if not authorized and do_raise is False. |
check_is_admin
(context)Whether or not user is admin according to policy setting.
check_policy
(context, resource, action, target_obj=None)enforce
(context, action, target, do_raise=True)Verifies that the action is valid on the target in this context.
Parameters: |
|
---|---|
Returns: | When |
Raises: | manila.exception.PolicyNotAuthorized if verification fails
and |
get_enforcer
()get_rules
()init
(rules=None, use_conf=True)Init an Enforcer class.
Parameters: |
|
---|
register_rules
(enforcer)reset
()set_rules
(rules, overwrite=True, use_conf=False)Set rules based on the provided dict of rules.
Parameters: |
|
---|
wrap_check_policy
(resource)Check policy corresponding to the wrapped methods prior to execution.
test_quota
Module¶DbQuotaDriverTestCase
(*args, **kwds)Bases: manila.test.TestCase
setUp
()test__get_quotas_1__None__None_
()test__get_quotas_2__None___fake_st_id__
()test__get_quotas_3___fake_user_id___None_
()test__get_quotas_unknown
()test__process_quotas_1
()test__process_quotas_2
()test__process_quotas_3
()test_commit
()test_destroy_all_by_project
()test_destroy_all_by_project_and_share_type
()test_destroy_all_by_project_and_user
()test_expire
()test_get_by_class
()test_get_class_quotas_1_True
()test_get_class_quotas_2_False
()test_get_defaults
()test_get_project_quotas_1___fake_quota_class___True__None___fake_remains__
()test_get_project_quotas_2__None__False___fake_usages___False_
()test_get_settable_quotas_1__None__None_
()test_get_settable_quotas_2__None___foo_st_id__
()test_get_settable_quotas_3___foo_user_id___None_
()test_get_share_type_quotas_1__None__True__True_
()test_get_share_type_quotas_2___fake_quota_class___False__True_
()test_get_share_type_quotas_3___fake_quota_class___True__False_
()test_get_user_quotas_1__None__True__True_
()test_get_user_quotas_2___fake_quota_class___False__True_
()test_get_user_quotas_3___fake_quota_class___True__False_
()test_reserve_1
()test_reserve_2
()test_reserve_3
()test_reserve_4
()test_reserve_wrong_expire
()test_rollback_1__None__None_
()test_rollback_2___fake_project_id____fake_user_id__
()test_usage_reset
()QuotaEngineTestCase
(*args, **kwds)Bases: manila.test.TestCase
setUp
()test_commit_1
()test_commit_2__None_
()test_count
()test_count_unknown_resource
()test_current_common_resources
()test_destroy_all_by_project
()test_destroy_all_by_project_and_share_type
()test_destroy_all_by_project_and_user
()test_expire
()test_get_by_class
()test_get_class_quotas_1_None
()test_get_class_quotas_2_True
()test_get_class_quotas_3_False
()test_get_defaults
()test_get_project_quotas_1
()test_get_project_quotas_2
()test_get_project_quotas_3
()test_get_project_quotas_4
()test_get_project_quotas_5
()test_get_settable_quotas_1
()test_get_settable_quotas_2
()test_get_settable_quotas_3
()test_get_share_type_quotas_1
()test_get_share_type_quotas_2
()test_get_share_type_quotas_3
()test_get_share_type_quotas_4
()test_get_user_quotas_1
()test_get_user_quotas_2
()test_get_user_quotas_3
()test_get_user_quotas_4
()test_register_resource
()test_register_resources
()test_reserve
()test_resources
()test_rollback_1
()test_rollback_2__None_
()test_usage_reset
()test_policy
Module¶Test of Policy Engine For Manila.
ContextIsAdminPolicyTestCase
(*args, **kwds)Bases: manila.test.TestCase
setUp
()test_context_is_admin_undefined
()test_custom_admin_role_is_admin
()test_default_admin_role_is_admin
()DefaultPolicyTestCase
(*args, **kwds)Bases: manila.test.TestCase
setUp
()tearDown
()test_default_not_found
()test_not_found_policy_calls_default
()test_policy_called
()PolicyTestCase
(*args, **kwds)Bases: manila.test.TestCase
setUp
()test_authorize_bad_action_noraise
()test_authorize_bad_action_throws
()test_authorize_good_action
()test_authorize_nonexistent_action_throws
()test_early_AND_authorization
()test_early_OR_authorization
()test_ignore_case_role_check
()test_templatized_authorization
()The following limits need to be defined and enforced:
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.