karbor package¶
Subpackages¶
- karbor.api package
- Subpackages
- karbor.api.middleware package
- karbor.api.openstack package
- karbor.api.schemas package
- Submodules
- karbor.api.schemas.checkpoints module
- karbor.api.schemas.copies module
- karbor.api.schemas.plans module
- karbor.api.schemas.quota_classes module
- karbor.api.schemas.quotas module
- karbor.api.schemas.restores module
- karbor.api.schemas.scheduled_operations module
- karbor.api.schemas.triggers module
- karbor.api.schemas.verifications module
- Module contents
- karbor.api.v1 package
- Submodules
- karbor.api.v1.copies module
- karbor.api.v1.operation_logs module
- karbor.api.v1.plans module
- karbor.api.v1.protectables module
- karbor.api.v1.providers module
- karbor.api.v1.quota_classes module
- karbor.api.v1.quotas module
- karbor.api.v1.restores module
- karbor.api.v1.router module
- karbor.api.v1.scheduled_operations module
- karbor.api.v1.services module
- karbor.api.v1.triggers module
- karbor.api.v1.verifications module
- Module contents
- karbor.api.validation package
- Submodules
- karbor.api.common module
- karbor.api.versions module
- Module contents
- Subpackages
- karbor.cmd package
- karbor.common package
- karbor.db package
- karbor.objects package
- Submodules
- karbor.objects.base module
- karbor.objects.checkpoint_record module
- karbor.objects.operation_log module
- karbor.objects.plan module
- karbor.objects.restore module
- karbor.objects.scheduled_operation module
- karbor.objects.scheduled_operation_log module
- karbor.objects.scheduled_operation_state module
- karbor.objects.service module
- karbor.objects.trigger module
- karbor.objects.verification module
- Module contents
- karbor.policies package
- Submodules
- karbor.policies.base module
- karbor.policies.copies module
- karbor.policies.operation_logs module
- karbor.policies.plans module
- karbor.policies.protectables module
- karbor.policies.providers module
- karbor.policies.quota_classes module
- karbor.policies.quotas module
- karbor.policies.restores module
- karbor.policies.scheduled_operations module
- karbor.policies.services module
- karbor.policies.triggers module
- karbor.policies.verifications module
- Module contents
- karbor.services package
- Subpackages
- karbor.services.operationengine package
- Subpackages
- Submodules
- karbor.services.operationengine.api module
- karbor.services.operationengine.karbor_client module
- karbor.services.operationengine.manager module
- karbor.services.operationengine.operation_manager module
- karbor.services.operationengine.rpcapi module
- karbor.services.operationengine.user_trust_manager module
- Module contents
- karbor.services.protection package
- Subpackages
- Submodules
- karbor.services.protection.api module
- karbor.services.protection.bank_plugin module
- karbor.services.protection.checkpoint module
- karbor.services.protection.client_factory module
- karbor.services.protection.graph module
- karbor.services.protection.manager module
- karbor.services.protection.protectable_plugin module
- karbor.services.protection.protectable_registry module
- karbor.services.protection.protection_plugin module
- karbor.services.protection.provider module
- karbor.services.protection.resource_flow module
- karbor.services.protection.rpcapi module
- Module contents
- karbor.services.operationengine package
- Module contents
- Subpackages
Submodules¶
karbor.context module¶
RequestContext: context for requests that persist through all of karbor.
-
class
karbor.context.
RequestContext
(user_id, project_id, is_admin=None, read_deleted='no', roles=None, project_name=None, remote_address=None, timestamp=None, request_id=None, auth_token=None, overwrite=True, quota_class=None, service_catalog=None, domain=None, user_domain=None, project_domain=None, auth_token_info=None)¶ Bases:
oslo_context.context.RequestContext
Security context and request information.
Represents the user taking a given action within the system.
-
property
auth_token_info
¶
-
can
(action, target_obj=None, fatal=True)¶ Verifies that the given action is valid on the target in this context.
- Parameters
action – string representing the action to be checked.
target – dictionary representing the object of the action for object creation this should be a dictionary representing the location of the object e.g.
{'project_id': context.project_id}
. If None, then this default target will be considered: {‘project_id’: self.project_id, ‘user_id’: self.user_id}fatal – if False, will return False when an exception.NotAuthorized occurs.
- Param
target_obj: dictionary representing the object which will be used to update target.
- Raises
nova.exception.Forbidden – if verification fails and fatal is True.
- Returns
returns a non-False value (not necessarily “True”) if authorized and False if not authorized and fatal is False.
-
deepcopy
()¶
-
elevated
(read_deleted=None, overwrite=False)¶ Return a version of this context with admin flag set.
-
classmethod
from_dict
(values)¶ Construct a context object from a provided dictionary.
-
property
project_id
¶
-
property
read_deleted
¶
-
to_dict
()¶ Return a dictionary of context attributes.
-
to_policy_values
()¶ A dictionary of context attributes to enforce policy with.
oslo.policy enforcement requires a dictionary of attributes representing the current logged in user on which it applies policy enforcement. This dictionary defines a standard list of attributes that should be available for enforcement across services.
It is expected that services will often have to override this method with either deprecated values or additional attributes used by that service specific policy.
-
property
user_id
¶
-
property
-
karbor.context.
get_admin_context
(read_deleted='no')¶
karbor.exception module¶
karbor base exception handling.
Includes decorator for re-raising karbor-type exceptions.
SHOULD include dedicated exception logging.
-
exception
karbor.exception.
AccessCheckpointNotAllowed
(message=None, **kwargs)¶ Bases:
karbor.exception.NotAuthorized
-
message
= 'Access checkpoint %(checkpoint_id)s is not allowed'¶
-
-
exception
karbor.exception.
AcquireLeaseFailed
(message=None, **kwargs)¶ Bases:
karbor.exception.KarborException
-
message
= 'Acquire Lease in Failed: %(reason)s'¶
-
-
exception
karbor.exception.
AdminRequired
(message=None, **kwargs)¶ Bases:
karbor.exception.NotAuthorized
-
message
= 'User does not have admin privileges'¶
-
-
exception
karbor.exception.
AuthorizationFailure
(message=None, **kwargs)¶ Bases:
karbor.exception.NotAuthorized
-
message
= 'Authorization for %(obj)s is failed '¶
-
-
exception
karbor.exception.
BankCreateObjectFailed
(message=None, **kwargs)¶ Bases:
karbor.exception.KarborException
-
message
= 'Create Object in Bank Failed: %(reason)s'¶
-
-
exception
karbor.exception.
BankDeleteObjectFailed
(message=None, **kwargs)¶ Bases:
karbor.exception.KarborException
-
message
= 'Delete Object %(key)s in Bank Failed: %(reason)s'¶
-
-
exception
karbor.exception.
BankGetObjectFailed
(message=None, **kwargs)¶ Bases:
karbor.exception.KarborException
-
message
= 'Get Object %(key)s in Bank Failed: %(reason)s'¶
-
-
exception
karbor.exception.
BankListObjectsFailed
(message=None, **kwargs)¶ Bases:
karbor.exception.KarborException
-
message
= 'Get Object in Bank Failed: %(reason)s'¶
-
-
exception
karbor.exception.
BankReadonlyViolation
(message=None, **kwargs)¶ Bases:
karbor.exception.KarborException
-
message
= 'Bank read-only violation'¶
-
-
exception
karbor.exception.
BankUpdateObjectFailed
(message=None, **kwargs)¶ Bases:
karbor.exception.KarborException
-
message
= 'Update Object %(key)s in Bank Failed: %(reason)s'¶
-
-
exception
karbor.exception.
CheckpointLimitExceeded
(message=None, **kwargs)¶ Bases:
karbor.exception.QuotaError
-
message
= 'Maximum number of checkpoints allowed (%(allowed)d) exceeded'¶
-
-
exception
karbor.exception.
CheckpointNotAvailable
(message=None, **kwargs)¶ Bases:
karbor.exception.KarborException
-
message
= 'The checkpoint %(checkpoint_id)s is not available'¶
-
-
exception
karbor.exception.
CheckpointNotBeDeleted
(message=None, **kwargs)¶ Bases:
karbor.exception.KarborException
-
message
= 'The checkpoint %(checkpoint_id)s can not be deleted.'¶
-
-
exception
karbor.exception.
CheckpointNotBeReset
(message=None, **kwargs)¶ Bases:
karbor.exception.KarborException
-
message
= 'The checkpoint %(checkpoint_id)s can not be reset.'¶
-
-
exception
karbor.exception.
CheckpointNotFound
(message=None, **kwargs)¶ Bases:
karbor.exception.NotFound
-
message
= 'Checkpoint %(checkpoint_id)s could not be found.'¶
-
-
exception
karbor.exception.
CheckpointRecordNotFound
(message=None, **kwargs)¶ Bases:
karbor.exception.NotFound
-
message
= 'CheckpointRecord %(id)s could not be found.'¶
-
-
exception
karbor.exception.
ClassNotFound
(message=None, **kwargs)¶ Bases:
karbor.exception.NotFound
-
message
= 'Class %(class_name)s could not be found: %(exception)s'¶
-
-
exception
karbor.exception.
ConfigNotFound
(message=None, **kwargs)¶ Bases:
karbor.exception.NotFound
-
message
= 'Could not find config at %(path)s'¶
-
-
exception
karbor.exception.
ConvertedException
(code=500, title='', explanation='')¶ Bases:
webob.exc.WSGIHTTPException
-
exception
karbor.exception.
CreateBucketFailed
(message=None, **kwargs)¶ Bases:
karbor.exception.KarborException
-
message
= 'Create Bucket in Bank Failed: %(reason)s'¶
-
-
exception
karbor.exception.
CreateContainerFailed
(message=None, **kwargs)¶ Bases:
karbor.exception.KarborException
-
message
= 'Create Container in Bank Failed: %(reason)s'¶
-
-
exception
karbor.exception.
CreateResourceFailed
(message=None, **kwargs)¶ Bases:
karbor.exception.KarborException
-
message
= 'Create %(name)s failed: %(reason)s, id=%(resource_id)s, type=%(resource_type)s'¶
-
-
exception
karbor.exception.
DeleteCheckpointNotAllowed
(message=None, **kwargs)¶ Bases:
karbor.exception.NotAuthorized
-
message
= 'Delete checkpoint %(checkpoint_id)s is not allowed'¶
-
-
exception
karbor.exception.
DeleteResourceFailed
(message=None, **kwargs)¶ Bases:
karbor.exception.KarborException
-
message
= 'Delete %(name)s failed: %(reason)s, id=%(resource_id)s, type=%(resource_type)s'¶
-
-
exception
karbor.exception.
DeleteTriggerNotAllowed
(message=None, **kwargs)¶ Bases:
karbor.exception.NotAuthorized
-
message
= 'Can not delete trigger %(trigger_id)s'¶
-
-
exception
karbor.exception.
Error
¶ Bases:
Exception
-
exception
karbor.exception.
FlowError
(message=None, **kwargs)¶ Bases:
karbor.exception.KarborException
-
message
= 'Flow: %(flow)s, Error: %(error)s'¶
-
-
exception
karbor.exception.
GetProtectionNetworkSubResourceFailed
(message=None, **kwargs)¶ Bases:
karbor.exception.KarborException
-
message
= 'Get protection network sub-resources of type %(type)s failed: %(reason)s'¶
-
-
exception
karbor.exception.
HostBinaryNotFound
(message=None, **kwargs)¶ Bases:
karbor.exception.NotFound
-
message
= 'Could not find binary %(binary)s on host %(host)s.'¶
-
-
exception
karbor.exception.
Invalid
(message=None, **kwargs)¶ Bases:
karbor.exception.KarborException
-
code
= 400¶
-
message
= 'Unacceptable parameters.'¶
-
-
exception
karbor.exception.
InvalidContentType
(message=None, **kwargs)¶ Bases:
karbor.exception.Invalid
-
message
= 'Invalid content type %(content_type)s.'¶
-
-
exception
karbor.exception.
InvalidInput
(message=None, **kwargs)¶ Bases:
karbor.exception.Invalid
-
message
= 'Invalid input received: %(reason)s'¶
-
-
exception
karbor.exception.
InvalidName
(message=None, **kwargs)¶ Bases:
karbor.exception.Invalid
-
message
= "An invalid 'name' value was provided. %(reason)s"¶
-
-
exception
karbor.exception.
InvalidOperationDefinition
(message=None, **kwargs)¶ Bases:
karbor.exception.Invalid
-
message
= 'Invalid operation definition, reason:%(reason)s'¶
-
-
exception
karbor.exception.
InvalidOperationObject
(message=None, **kwargs)¶ Bases:
karbor.exception.Invalid
-
message
= 'The operation %(operation_id)s is invalid'¶
-
-
exception
karbor.exception.
InvalidOriginalId
(message=None, **kwargs)¶ Bases:
karbor.exception.Invalid
-
message
= 'The original_id: %(original_id)s is invalid.'¶
-
-
exception
karbor.exception.
InvalidParameterValue
(message=None, **kwargs)¶ Bases:
karbor.exception.Invalid
-
message
= '%(err)s'¶
-
-
exception
karbor.exception.
InvalidPlan
(message=None, **kwargs)¶ Bases:
karbor.exception.Invalid
-
message
= 'Invalid plan: %(reason)s'¶
-
-
exception
karbor.exception.
InvalidProtectableInstance
(message=None, **kwargs)¶ Bases:
karbor.exception.Invalid
-
message
= 'Invalid protectable instance.'¶
-
-
exception
karbor.exception.
InvalidQuotaValue
(message=None, **kwargs)¶ Bases:
karbor.exception.Invalid
-
message
= 'Change would make usage less than 0 for the following resources: %(unders)s.'¶
-
-
exception
karbor.exception.
InvalidReservationExpiration
(message=None, **kwargs)¶ Bases:
karbor.exception.Invalid
-
message
= 'Invalid reservation expiration %(expire)s.'¶
-
-
exception
karbor.exception.
InvalidTaskFlowObject
(message=None, **kwargs)¶ Bases:
karbor.exception.Invalid
-
message
= 'The task flow is invalid: %(reason)s'¶
-
-
exception
karbor.exception.
KarborException
(message=None, **kwargs)¶ Bases:
Exception
Base karbor Exception
To correctly use this class, inherit from it and define a ‘message’ property. That message will get printf’d with the keyword arguments provided to the constructor.
-
code
= 500¶
-
headers
= {}¶
-
message
= 'An unknown exception occurred.'¶
-
safe
= True¶
-
-
exception
karbor.exception.
ListProtectableResourceFailed
(message=None, **kwargs)¶ Bases:
karbor.exception.KarborException
-
message
= 'List protectable resources of type %(type)s failed: %(reason)s'¶
-
-
exception
karbor.exception.
MalformedRequestBody
(message=None, **kwargs)¶ Bases:
karbor.exception.KarborException
-
message
= 'Malformed message body: %(reason)s'¶
-
-
exception
karbor.exception.
NotAuthorized
(message=None, **kwargs)¶ Bases:
karbor.exception.KarborException
-
code
= 403¶
-
message
= 'Not authorized.'¶
-
-
exception
karbor.exception.
NotFound
(message=None, **kwargs)¶ Bases:
karbor.exception.KarborException
-
code
= 404¶
-
message
= 'Resource could not be found.'¶
-
safe
= True¶
-
-
exception
karbor.exception.
OperationLogFound
(message=None, **kwargs)¶ Bases:
karbor.exception.NotFound
-
message
= 'Operation log %(operation_log_id)s could not be found.'¶
-
-
exception
karbor.exception.
OperationLogNotFound
(message=None, **kwargs)¶ Bases:
karbor.exception.NotFound
-
message
= 'OperationLog %(restore_id)s could not be found.'¶
-
-
exception
karbor.exception.
OverQuota
(message=None, **kwargs)¶ Bases:
karbor.exception.KarborException
-
message
= 'Quota exceeded for resources: %(overs)s'¶
-
-
exception
karbor.exception.
PasteAppNotFound
(message=None, **kwargs)¶ Bases:
karbor.exception.NotFound
-
message
= "Could not load paste app '%(name)s' from %(path)s"¶
-
-
exception
karbor.exception.
PlanLimitExceeded
(message=None, **kwargs)¶ Bases:
karbor.exception.QuotaError
-
message
= 'Maximum number of plans allowed (%(allowed)d) exceeded'¶
-
-
exception
karbor.exception.
PlanNotFound
(message=None, **kwargs)¶ Bases:
karbor.exception.NotFound
-
message
= 'Plan %(plan_id)s could not be found.'¶
-
-
exception
karbor.exception.
PolicyNotAuthorized
(message=None, **kwargs)¶ Bases:
karbor.exception.NotAuthorized
-
message
= "Policy doesn't allow %(action)s to be performed."¶
-
-
exception
karbor.exception.
ProjectQuotaNotFound
(message=None, **kwargs)¶ Bases:
karbor.exception.QuotaNotFound
-
message
= 'Quota for project %(project_id)s could not be found.'¶
-
-
exception
karbor.exception.
ProtectableResourceInvalidStatus
(message=None, **kwargs)¶ Bases:
karbor.exception.KarborException
-
message
= 'The resource %(id)s of type %(type)s has a invalid status: %(status)s'¶
-
-
exception
karbor.exception.
ProtectableResourceNotFound
(message=None, **kwargs)¶ Bases:
karbor.exception.NotFound
-
message
= 'The resource %(id)s of type %(type)s could not be found: %(reason)s'¶
-
-
exception
karbor.exception.
ProtectableTypeNotFound
(message=None, **kwargs)¶ Bases:
karbor.exception.NotFound
-
message
= 'ProtectableType %(protectable_type)s could not be found.'¶
-
-
exception
karbor.exception.
ProtectionPluginNotFound
(message=None, **kwargs)¶ Bases:
karbor.exception.NotFound
-
message
= 'Protection Plugin for %(type)s could not be found.'¶
-
-
exception
karbor.exception.
ProviderNotFound
(message=None, **kwargs)¶ Bases:
karbor.exception.NotFound
-
message
= 'Provider %(provider_id)s could not be found.'¶
-
-
exception
karbor.exception.
QuotaClassNotFound
(message=None, **kwargs)¶ Bases:
karbor.exception.QuotaNotFound
-
message
= 'Quota class %(class_name)s could not be found.'¶
-
-
exception
karbor.exception.
QuotaError
(message=None, **kwargs)¶ Bases:
karbor.exception.KarborException
-
code
= 413¶
-
headers
= {'Retry-After': '0'}¶
-
message
= 'Quota exceeded: code=%(code)s'¶
-
safe
= True¶
-
-
exception
karbor.exception.
QuotaNotFound
(message=None, **kwargs)¶ Bases:
karbor.exception.NotFound
-
message
= 'Quota could not be found'¶
-
-
exception
karbor.exception.
QuotaResourceUnknown
(message=None, **kwargs)¶ Bases:
karbor.exception.QuotaNotFound
-
message
= 'Unknown quota resources %(unknown)s.'¶
-
-
exception
karbor.exception.
QuotaUsageNotFound
(message=None, **kwargs)¶ Bases:
karbor.exception.QuotaNotFound
-
message
= 'Quota usage for project %(project_id)s could not be found.'¶
-
-
exception
karbor.exception.
ReservationNotFound
(message=None, **kwargs)¶ Bases:
karbor.exception.QuotaNotFound
-
message
= 'Quota reservation %(uuid)s could not be found.'¶
-
-
exception
karbor.exception.
RestoreNotFound
(message=None, **kwargs)¶ Bases:
karbor.exception.NotFound
-
message
= 'Restore %(restore_id)s could not be found.'¶
-
-
exception
karbor.exception.
RestoreResourceFailed
(message=None, **kwargs)¶ Bases:
karbor.exception.KarborException
-
message
= 'Restore %(name)s failed: %(reason)s, id=%(resource_id)s, type=%(resource_type)s'¶
-
-
exception
karbor.exception.
ScheduledOperationExist
(message=None, **kwargs)¶ Bases:
karbor.exception.Invalid
-
message
= 'Scheduled Operation%(op_id)s exists'¶
-
-
exception
karbor.exception.
ScheduledOperationLogNotFound
(message=None, **kwargs)¶ Bases:
karbor.exception.NotFound
-
message
= 'Scheduled Operation Log %(log_id)s could not be found.'¶
-
-
exception
karbor.exception.
ScheduledOperationNotFound
(message=None, **kwargs)¶ Bases:
karbor.exception.NotFound
-
message
= 'Scheduled Operation %(id)s could not be found.'¶
-
-
exception
karbor.exception.
ScheduledOperationStateNotFound
(message=None, **kwargs)¶ Bases:
karbor.exception.NotFound
-
message
= 'Scheduled Operation State %(op_id)s could not be found.'¶
-
-
exception
karbor.exception.
ServiceNotFound
(message=None, **kwargs)¶ Bases:
karbor.exception.NotFound
-
message
= 'Service %(service_id)s could not be found.'¶
-
-
exception
karbor.exception.
TriggerIsInvalid
(message=None, **kwargs)¶ Bases:
karbor.exception.Invalid
-
message
= 'Trigger%(trigger_id)s is invalid.'¶
-
-
exception
karbor.exception.
TriggerNotFound
(message=None, **kwargs)¶ Bases:
karbor.exception.NotFound
-
message
= 'Trigger %(id)s could not be found.'¶
-
-
exception
karbor.exception.
UnexpectedOverQuota
(message=None, **kwargs)¶ Bases:
karbor.exception.QuotaError
-
message
= 'Unexpected over quota on %(name)s.'¶
-
-
exception
karbor.exception.
ValidationError
(message=None, **kwargs)¶ Bases:
karbor.exception.Invalid
-
message
= '%(detail)s'¶
-
-
exception
karbor.exception.
VerificationNotFound
(message=None, **kwargs)¶ Bases:
karbor.exception.NotFound
-
message
= 'Verification %(verification_id)s could not be found.'¶
-
-
exception
karbor.exception.
VerifyResourceFailed
(message=None, **kwargs)¶ Bases:
karbor.exception.KarborException
-
message
= 'Verify %(name)s failed: %(reason)s, id=%(resource_id)s, type=%(resource_type)s'¶
-
karbor.i18n module¶
oslo.i18n integration module.
See https://docs.openstack.org/oslo.i18n/latest/user/usage.html .
-
karbor.i18n.
enable_lazy
(enable=True)¶
-
karbor.i18n.
get_available_languages
()¶
-
karbor.i18n.
translate
(value, user_locale=None)¶
karbor.loadables module¶
Generic Loadable class support.
Meant to be used by such things as scheduler filters and weights where we want to load modules from certain directories and find certain types of classes within those modules. Note that this is quite different than generic plugins and the pluginmanager code that exists elsewhere.
Usage:
Create a directory with an __init__.py with code such as:
- class SomeLoadableClass(object):
pass
- class MyLoader(nova.loadables.BaseLoader)
- def __init__(self):
super(MyLoader, self).__init__(SomeLoadableClass)
If you create modules in the same directory and subclass SomeLoadableClass within them, MyLoader().get_all_classes() will return a list of such classes.
-
class
karbor.loadables.
BaseLoader
(loadable_cls_type)¶ Bases:
object
-
get_all_classes
()¶ Get all classes.
Get the classes of the type we want from all modules found in the directory that defines this class.
-
get_matching_classes
(loadable_class_names)¶ Get loadable classes from a list of names.
Each name can be a full module path or the full path to a method that returns classes to use. The latter behavior is useful to specify a method that returns a list of classes to use in a default case.
-
karbor.manager module¶
Base Manager class.
Managers are responsible for a certain aspect of the system. It is a logical grouping of code relating to a portion of the system. In general other components should be using the manager to make changes to the components that it is responsible for.
We have adopted a basic strategy of Smart managers and dumb data, which means rather than attaching methods to data objects, components should call manager methods that act on the data.
Methods on managers that can be executed locally should be called directly. If a particular method must execute on a remote host, this should be done via rpc to the service that wraps the manager
Managers should be responsible for most of the db access, and non-implementation specific data. Anything implementation specific that can’t be generalized should be done by the Driver.
Managers will often provide methods for initial setup of a host or periodic tasks to a wrapping service.
This module provides Manager, a base class for managers.
-
class
karbor.manager.
Manager
(host=None, db_driver=None)¶ Bases:
karbor.db.base.Base
,karbor.manager.PeriodicTasks
-
RPC_API_VERSION
= '1.0'¶
-
cleanup_host
()¶ Hook to do cleanup work when the service shuts down.
Child classes should override this method.
-
init_host
(**kwargs)¶ Handle initialization if this is a standalone service.
A hook point for services to execute tasks before the services are made available (i.e. showing up on RPC and starting to accept RPC calls) to other components. Child classes should override this method.
-
init_host_with_rpc
()¶ A hook for service to do jobs after RPC is ready.
Like init_host(), this method is a hook where services get a chance to execute tasks that need RPC. Child classes should override this method.
-
is_working
()¶ Method indicating if service is working correctly.
This method is supposed to be overridden by subclasses and return if manager is working correctly.
-
periodic_tasks
(context, raise_on_error=False)¶ Tasks to be run at a periodic interval.
-
service_config
()¶
-
service_version
()¶
-
target
= <Target version=1.0>¶
-
-
class
karbor.manager.
PeriodicTasks
¶ Bases:
oslo_service.periodic_task.PeriodicTasks
karbor.policy module¶
Policy Engine For Karbor
Verifies that the action is valid on the target in this context.
- Parameters
context – karbor context
action – string representing the action to be checked this should be colon separated for clarity. i.e.
compute:create_instance
,plan:create
,plan:get
target – dictionary representing the object of the action for object creation this should be a dictionary representing the location of the object e.g.
{'project_id': context.project_id}
do_raise – if True (the default), raises PolicyNotAuthorized; if False, returns False
exc – Class of the exception to raise if the check fails. Any remaining arguments passed to
authorize()
(both positional and keyword arguments) will be passed to the exception class. If not specified,PolicyNotAuthorized
will be used.
- Raises
karbor.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.
-
karbor.policy.
check_is_admin
(context)¶ Whether or not user is admin according to policy setting.
-
karbor.policy.
enforce
(context, action, target)¶ Verifies that the action is valid on the target in this context.
- Parameters
context – karbor context
action – string representing the action to be checked this should be colon separated for clarity. i.e.
compute:create_instance
,compute:attach_volume
,volume:attach_volume
target – dictionary representing the object of the action for object creation this should be a dictionary representing the location of the object e.g.
{'project_id': context.project_id}
- Raises
PolicyNotAuthorized – if verification fails.
-
karbor.policy.
enforce_action
(context, action)¶ Checks that the action can be done by the given context.
Applies a check to ensure the context’s project_id and user_id can be applied to the given action using the policy enforcement api.
-
karbor.policy.
get_enforcer
()¶
-
karbor.policy.
get_rules
()¶
-
karbor.policy.
init
(policy_file=None, rules=None, default_rule=None, use_conf=True)¶ Init an Enforcer class.
- Parameters
policy_file – Custom policy file to use, if none is specified, CONF.policy_file will be used.
rules – Default dictionary / Rules to use. It will be considered just in the first instantiation.
default_rule – Default rule to use, CONF.default_rule will be used if none is specified.
use_conf – Whether to load rules from config file.
-
karbor.policy.
register_rules
(enforcer)¶
-
karbor.policy.
reset
()¶
-
karbor.policy.
set_rules
(rules, overwrite=True, use_conf=False)¶ Set rules based on the provided dict of rules.
- Parameters
rules – New rules to use. It should be an instance of dict.
overwrite – Whether to overwrite current rules or update them with the new rules.
use_conf – Whether to reload rules from config file.
karbor.quota module¶
Quotas for shares.
-
class
karbor.quota.
AbsoluteResource
(name, flag=None)¶ Bases:
karbor.quota.BaseResource
Describe a non-reservable resource.
-
class
karbor.quota.
BaseResource
(name, flag=None)¶ Bases:
object
Describe a single resource for quota checking.
-
property
default
¶ Return the default value of the quota.
-
quota
(driver, context, **kwargs)¶ Given a driver and context, obtain the quota for this resource.
- Parameters
driver – A quota driver.
context – The request context.
project_id – The project to obtain the quota value for. If not provided, it is taken from the context. If it is given as None, no project-specific quota will be searched for.
quota_class – The quota class corresponding to the project, or for which the quota is to be looked up. If not provided, it is taken from the context. If it is given as None, no quota class-specific quota will be searched for. Note that the quota class defaults to the value in the context, which may not correspond to the project if project_id is not the same as the one in the context.
-
property
-
class
karbor.quota.
CountableResource
(name, count, flag=None)¶ Bases:
karbor.quota.AbsoluteResource
Describe a resource where the counts aren’t based solely on the
project ID.
-
class
karbor.quota.
DbQuotaDriver
¶ Bases:
object
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)¶ Commit reservations.
- Parameters
context – The request context, for access checks.
reservations – A list of the reservation UUIDs, as returned by the reserve() method.
project_id – Specify the project_id if current context is admin and admin wants to impact on common user’s tenant.
-
destroy_all_by_project
(context, project_id)¶ Destroy all quotas, usages, and reservations associated with a project.
- Parameters
context – The request context, for access checks.
project_id – The ID of the project being deleted.
-
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_by_project
(context, project_id, resource)¶ Get a specific quota by project.
-
get_class_quotas
(context, resources, quota_class, defaults=True)¶ Given a list of resources, retrieve the quotas for the given quota class.
- Parameters
context – The request context, for access checks.
resources – A dictionary of the registered resources.
quota_class – The name of the quota class to return quotas for.
defaults – If True, the default value will be reported if there is no specific value for the resource.
-
get_defaults
(context, resources)¶ Given a list of resources, retrieve the default quotas.
- Parameters
context – The request context, for access checks.
resources – A dictionary of the registered resources.
-
get_project_quotas
(context, resources, project_id, quota_class=None, defaults=True, usages=True)¶ Given a list of resources, retrieve the quotas for the given project.
- Parameters
context – The request context, for access checks.
resources – A dictionary of the registered resources.
project_id – The ID of the project to return quotas for.
quota_class – If project_id != context.project_id, the quota class cannot be determined. This parameter allows it to be specified. It will be ignored if project_id == context.project_id.
defaults – If True, the quota class value (or the default value, if there is no value from the quota class) will be reported if there is no specific value for the resource.
usages – If True, the current in_use and reserved counts will also be returned.
-
limit_check
(context, resources, values, project_id=None)¶ Check simple quota limits.
For limits–those quotas for which there is no usage synchronization function–this method checks that a set of proposed values are permitted by the limit restriction.
This method will raise a QuotaResourceUnknown exception if a given resource is unknown or if it is not a simple limit resource.
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 nothing.
- Parameters
context – The request context, for access checks.
resources – A dictionary of the registered resources.
values – A dictionary of the values to check against the quota.
project_id – Specify the project_id if current context is admin and admin wants to impact on common user’s tenant.
-
reserve
(context, resources, deltas, expire=None, project_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
context – The request context, for access checks.
resources – A dictionary of the registered resources.
deltas – A dictionary of the proposed delta changes.
expire – An optional parameter specifying an expiration time for the reservations. If it is a simple number, it is interpreted as a number of seconds and added to the current time; if it is a datetime.timedelta object, it will also be added to the current time. A datetime.datetime object will be interpreted as the absolute expiration time. If None is specified, the default expiration time set by –default-reservation-expire will be used (this value will be treated as a number of seconds).
project_id – Specify the project_id if current context is admin and admin wants to impact on common user’s tenant.
-
rollback
(context, reservations, project_id=None)¶ Roll back reservations.
- Parameters
context – The request context, for access checks.
reservations – A list of the reservation UUIDs, as returned by the reserve() method.
project_id – Specify the project_id if current context is admin and admin wants to impact on common user’s tenant.
-
-
class
karbor.quota.
QuotaEngine
(quota_driver_class=None)¶ Bases:
object
Represent the set of recognized quotas.
-
commit
(context, reservations, project_id=None)¶ Commit reservations.
- Parameters
context – The request context, for access checks.
reservations – A list of the reservation UUIDs, as returned by the reserve() method.
project_id – Specify the project_id if current context is admin and admin wants to impact on common user’s tenant.
-
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
context – The request context, for access checks.
resource – The name of the resource, as a string.
-
destroy_all_by_project
(context, project_id)¶ Destroy all quotas, usages, and reservations associated with a
project.
- Parameters
context – The request context, for access checks.
project_id – The ID of the project being deleted.
-
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_by_project
(context, project_id, resource)¶ Get a specific quota by project.
-
get_class_quotas
(context, quota_class, defaults=True)¶ Retrieve the quotas for the given quota class.
- Parameters
context – The request context, for access checks.
quota_class – The name of the quota class to return quotas for.
defaults – If True, the default value will be reported if there is no specific value for the resource.
-
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)¶ Retrieve the quotas for the given project.
- Parameters
context – The request context, for access checks.
project_id – The ID of the project to return quotas for.
quota_class – If project_id != context.project_id, the quota class cannot be determined. This parameter allows it to be specified.
defaults – If True, the quota class value (or the default value, if there is no value from the quota class) will be reported if there is no specific value for the resource.
usages – If True, the current in_use and reserved counts will also be returned.
-
limit_check
(context, project_id=None, **values)¶ Check simple quota limits.
For limits–those quotas for which there is no usage synchronization function–this method checks that a set of proposed values are permitted by the limit restriction. The values to check are given as keyword arguments, where the key identifies the specific quota limit to check, and the value is the proposed value.
This method will raise a QuotaResourceUnknown exception if a given resource is unknown or if it is not a simple limit resource.
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 nothing.
- Parameters
context – The request context, for access checks.
project_id – Specify the project_id if current context is admin and admin wants to impact on common user’s tenant.
-
register_resource
(resource)¶ Register a resource.
-
register_resources
(resources)¶ Register a list of resources.
-
reserve
(context, expire=None, project_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
context – The request context, for access checks.
expire – An optional parameter specifying an expiration time for the reservations. If it is a simple number, it is interpreted as a number of seconds and added to the current time; if it is a datetime.timedelta object, it will also be added to the current time. A datetime.datetime object will be interpreted as the absolute expiration time. If None is specified, the default expiration time set by –default-reservation-expire will be used (this value will be treated as a number of seconds).
project_id – Specify the project_id if current context is admin and admin wants to impact on common user’s tenant.
-
property
resources
¶
-
rollback
(context, reservations, project_id=None)¶ Roll back reservations.
- Parameters
context – The request context, for access checks.
reservations – A list of the reservation UUIDs, as returned by the reserve() method.
project_id – Specify the project_id if current context is admin and admin wants to impact on common user’s tenant.
-
-
class
karbor.quota.
ReservableResource
(name, sync, flag=None)¶ Bases:
karbor.quota.BaseResource
Describe a reservable resource.
-
karbor.quota.
process_reserve_over_quota
(context, over_quota_exception, resource, size=None)¶ Handle OverQuota exception.
Analyze OverQuota exception, and raise new exception related to resource type. If there are unexpected items in overs, UnexpectedOverQuota is raised.
- Parameters
context – security context
over_quota_exception – OverQuota exception
resource – can be backups, snapshots, and volumes
size – requested size in reservation
karbor.resource module¶
karbor.rpc module¶
-
class
karbor.rpc.
RequestContextSerializer
(base)¶ Bases:
oslo_messaging.serializer.Serializer
-
deserialize_context
(context)¶ Deserialize a dictionary into a request context.
- Parameters
ctxt – Request context dictionary
- Returns
Deserialized form of entity
-
deserialize_entity
(context, entity)¶ Deserialize something from primitive form.
- Parameters
ctxt – Request context, in deserialized form
entity – Primitive to be deserialized
- Returns
Deserialized form of entity
-
serialize_context
(context)¶ Serialize a request context into a dictionary.
- Parameters
ctxt – Request context
- Returns
Serialized form of context
-
serialize_entity
(context, entity)¶ Serialize something to primitive form.
- Parameters
ctxt – Request context, in deserialized form
entity – Entity to be serialized
- Returns
Serialized form of entity
-
-
karbor.rpc.
add_extra_exmods
(*args)¶
-
karbor.rpc.
cleanup
()¶
-
karbor.rpc.
clear_extra_exmods
()¶
-
karbor.rpc.
get_allowed_exmods
()¶
-
karbor.rpc.
get_client
(target, version_cap=None, serializer=None)¶
-
karbor.rpc.
get_notifier
(service=None, host=None, publisher_id=None)¶
-
karbor.rpc.
get_server
(target, endpoints, serializer=None)¶
-
karbor.rpc.
init
(conf)¶
-
karbor.rpc.
set_defaults
(control_exchange)¶
karbor.service module¶
Generic Node base class for all workers that run on hosts.
-
class
karbor.service.
Launcher
¶ Bases:
object
-
class
karbor.service.
Service
(host, binary, topic, manager, report_interval=None, periodic_interval=None, periodic_fuzzy_delay=None, service_name=None, *args, **kwargs)¶ Bases:
oslo_service.service.Service
Service object for binaries running on hosts.
A service takes a manager and enables rpc by listening to queues based on topic. It also periodically runs tasks on the manager and reports it state to the database services table.
-
basic_config_check
()¶ Perform basic config checks before starting service.
-
classmethod
create
(host=None, binary=None, topic=None, manager=None, report_interval=None, periodic_interval=None, periodic_fuzzy_delay=None, service_name=None)¶ Instantiates class and passes back application object.
- Parameters
host – defaults to CONF.host
binary – defaults to basename of executable
topic – defaults to bin_name - ‘karbor-‘ part
manager – defaults to CONF.<topic>_manager
report_interval – defaults to CONF.report_interval
periodic_interval – defaults to CONF.periodic_interval
periodic_fuzzy_delay – defaults to CONF.periodic_fuzzy_delay
-
kill
()¶ Destroy the service object in the datastore.
-
periodic_tasks
(raise_on_error=False)¶ Tasks to be run at a periodic interval.
-
report_state
()¶ Update the state of this service in the datastore.
-
start
()¶ Start a service.
-
stop
()¶ Stop a service.
- Parameters
graceful – indicates whether to wait for all threads to finish or terminate them instantly
-
wait
()¶ Wait for a service to shut down.
-
-
class
karbor.service.
WSGIService
(name, loader=None)¶ Bases:
oslo_service.service.ServiceBase
Provides ability to launch API from a ‘paste’ configuration.
-
reset
()¶ Reset server greenpool size to default.
- Returns
None
-
start
()¶ Start serving this service using loaded configuration.
Also, retrieve updated port number in case ‘0’ was passed in, which indicates a random port should be used.
- Returns
None
-
stop
()¶ Stop serving this API.
- Returns
None
-
wait
()¶ Wait for the service to stop serving this API.
- Returns
None
-
-
karbor.service.
get_launcher
()¶
-
karbor.service.
process_launcher
()¶
-
karbor.service.
serve
(server, workers=None)¶
-
karbor.service.
wait
()¶
karbor.utils module¶
Utilities and helper functions.
-
karbor.utils.
DO_NOTHING
¶ Class that literally does nothing.
We inherit from str in case it’s called with json.dumps.
-
class
karbor.utils.
DoNothing
¶ Bases:
str
Class that literally does nothing.
We inherit from str in case it’s called with json.dumps.
-
karbor.utils.
check_filters
(filters)¶
-
karbor.utils.
find_config
(config_path)¶ Find a configuration file using the given hint.
- Parameters
config_path – Full or relative path to the config.
- Returns
Full path of the config, if it exists.
- Raises
-
karbor.utils.
get_auth_uri
(v3=True)¶
-
karbor.utils.
get_bool_param
(param_string, params)¶
-
karbor.utils.
is_valid_boolstr
(val)¶ Check if the provided string is a valid bool string or not.
-
karbor.utils.
load_class
(namespace, plugin_name)¶
-
karbor.utils.
load_plugin
(namespace, plugin_name, *args, **kwargs)¶
-
karbor.utils.
notifications_enabled
(conf)¶ Check if oslo notifications are enabled.
-
karbor.utils.
remove_invalid_filter_options
(context, filters, allowed_search_options)¶ Remove search options that are not valid for non-admin API/context.
-
karbor.utils.
service_is_up
(service)¶ Check whether a service is up based on last heartbeat.
-
karbor.utils.
tempdir
(**kwargs)¶
-
karbor.utils.
validate_integer
(value, name, min_value=None, max_value=None)¶ Make sure that value is a valid integer, potentially within range.
- Parameters
value – the value of the integer
name – the name of the integer
min_length – the min_length of the integer
max_length – the max_length of the integer
- Returns
integer
-
karbor.utils.
walk_class_hierarchy
(clazz, encountered=None)¶ Walk class hierarchy, yielding most derived classes first.