The karbor.db.api
Module¶
Defines interface for DB access.
Functions in this module are imported into the karbor.db namespace. Call these functions from karbor.db namespace, not the karbor.db.api namespace.
All functions in this module return objects that implement a dictionary-like interface. Currently, many of these objects are sqlalchemy objects that implement a dictionary interface. However, a future goal is to have all of these objects be simple dictionaries.
Related Flags
connection: | string specifying the sqlalchemy connection to use, like: sqlite:///var/lib/karbor/karbor.sqlite. |
---|---|
enable_new_services: | |
when adding a new service to the database, is it in the pool of available hardware (Default: True) |
-
karbor.db.api.
checkpoint_record_create
(context, values)¶ Create a checkpoint record from the values dictionary.
-
karbor.db.api.
checkpoint_record_destroy
(context, checkpoint_record_id)¶ Destroy the checkpoint record or raise if it does not exist.
-
karbor.db.api.
checkpoint_record_get
(context, checkpoint_record_id)¶ Get a checkpoint record or raise if it does not exist.
-
karbor.db.api.
checkpoint_record_get_all_by_filters_sort
(context, filters, limit=None, marker=None, sort_keys=None, sort_dirs=None)¶ Get all checkpoint records that match all filters sorted
by multiple keys. sort_keys and sort_dirs must be a list of strings.
-
karbor.db.api.
checkpoint_record_update
(context, checkpoint_record_id, values)¶ Set the given properties on a checkpoint record and update it.
Raises NotFound if checkpoint record does not exist.
-
karbor.db.api.
dispose_engine
()¶ Force the engine to establish new connections.
-
karbor.db.api.
get_by_id
(context, model, id, *args, **kwargs)¶
-
karbor.db.api.
operation_log_create
(context, values)¶ Create a operation log from the values dictionary.
-
karbor.db.api.
operation_log_destroy
(context, operation_log_id)¶ Destroy the operation log or raise if it does not exist.
-
karbor.db.api.
operation_log_get
(context, operation_log_id)¶ Get a operation log or raise if it does not exist.
-
karbor.db.api.
operation_log_get_all
(context, marker, limit, sort_keys=None, sort_dirs=None, filters=None, offset=None)¶ Get all operation logs.
-
karbor.db.api.
operation_log_get_all_by_project
(context, project_id, marker, limit, sort_keys=None, sort_dirs=None, filters=None, offset=None)¶ Get all operation logs belonging to a project.
-
karbor.db.api.
operation_log_update
(context, operation_log_id, values)¶ Set the given properties on a operation log and update it.
Raises NotFound if plan does not exist.
-
karbor.db.api.
plan_create
(context, values)¶ Create a plan from the values dictionary.
-
karbor.db.api.
plan_destroy
(context, plan_id)¶ Destroy the plan or raise if it does not exist.
-
karbor.db.api.
plan_get
(context, plan_id)¶ Get a plan or raise if it does not exist.
-
karbor.db.api.
plan_get_all
(context, marker, limit, sort_keys=None, sort_dirs=None, filters=None, offset=None)¶ Get all plans.
-
karbor.db.api.
plan_get_all_by_project
(context, project_id, marker, limit, sort_keys=None, sort_dirs=None, filters=None, offset=None)¶ Get all plans belonging to a project.
-
karbor.db.api.
plan_resources_update
(context, plan_id, resources)¶ Update resources if it exists, otherwise create it.
-
karbor.db.api.
plan_update
(context, plan_id, values)¶ Set the given properties on a plan and update it.
Raises NotFound if plan does not exist.
-
karbor.db.api.
purge_deleted_rows
(context, age_in_days)¶ Purge deleted rows older than given age from karbor tables
Raises InvalidParameterValue if age_in_days is incorrect. :returns: number of deleted rows
-
karbor.db.api.
restore_create
(context, values)¶ Create a restore from the values dictionary.
-
karbor.db.api.
restore_destroy
(context, restore_id)¶ Destroy the restore or raise if it does not exist.
-
karbor.db.api.
restore_get
(context, restore_id)¶ Get a restore or raise if it does not exist.
-
karbor.db.api.
restore_get_all
(context, marker, limit, sort_keys=None, sort_dirs=None, filters=None, offset=None)¶ Get all restores.
-
karbor.db.api.
restore_get_all_by_project
(context, project_id, marker, limit, sort_keys=None, sort_dirs=None, filters=None, offset=None)¶ Get all restores belonging to a project.
-
karbor.db.api.
restore_update
(context, restore_id, values)¶ Set the given properties on a restore and update it.
Raises NotFound if plan does not exist.
-
karbor.db.api.
scheduled_operation_create
(context, values)¶ Create a scheduled operation from the values dictionary.
Parameters: - context – The security context
- values – Dictionary containing scheduled operation properties
Returns: Dictionary-like object containing the properties of the created scheduled operation
-
karbor.db.api.
scheduled_operation_delete
(context, id)¶ Delete a scheduled operation from the database.
Parameters: - context – The security context
- id – ID of the scheduled operation
Raises ScheduledOperationNotFound if scheduled operation with the given ID doesn’t exist.
-
karbor.db.api.
scheduled_operation_get
(context, id, columns_to_join=[])¶ Get a scheduled operation by its id.
Parameters: - context – The security context
- id – ID of the scheduled operation
- columns_to_join – columns which will be joined
Returns: Dictionary-like object containing properties of the scheduled operation
- Raises ScheduledOperationNotFound if scheduled operation with
- the given ID doesn’t exist.
-
karbor.db.api.
scheduled_operation_get_all_by_filters_sort
(context, filters, limit=None, marker=None, sort_keys=None, sort_dirs=None)¶ Get all operations that match all filters sorted by multiple keys.
sort_keys and sort_dirs must be a list of strings.
-
karbor.db.api.
scheduled_operation_log_create
(context, values)¶ Create a scheduled operation log from the values dictionary.
Parameters: - context – The security context
- values – Dictionary containing scheduled operation log properties
Returns: Dictionary-like object containing the properties of the created scheduled operation log
-
karbor.db.api.
scheduled_operation_log_delete
(context, log_id)¶ Delete a scheduled operation log from the database.
Parameters: - context – The security context
- log_id – Log_id of the scheduled operation log
Raises ScheduledOperationLogNotFound if scheduled operation log with the given ID doesn’t exist.
-
karbor.db.api.
scheduled_operation_log_delete_oldest
(context, operation_id, retained_num, excepted_states=[])¶ Delete the oldest scheduled operation logs from the database.
Parameters: - context – The security context
- operation_id – ID of the scheduled operation
- retained_num – The number of retained logs
- excepted_states – If the state of log is in excepted_states, it will not be deleted.
-
karbor.db.api.
scheduled_operation_log_get
(context, log_id)¶ Get a scheduled operation log by its id.
Parameters: - context – The security context
- log_id – Log_id of the scheduled operation log
Returns: Dictionary-like object containing properties of the scheduled operation log
- Raises ScheduledOperationLogNotFound if scheduled operation log with
- the given ID doesn’t exist.
-
karbor.db.api.
scheduled_operation_log_get_all_by_filters_sort
(context, filters, limit=None, marker=None, sort_keys=None, sort_dirs=None)¶ Get all operation logs that match all filters sorted by multiple keys.
sort_keys and sort_dirs must be a list of strings.
-
karbor.db.api.
scheduled_operation_log_update
(context, log_id, values)¶ Set the given properties on a scheduled operation log and update it.
Parameters: - context – The security context
- log_id – Log_id of the scheduled operation log
- values – Dictionary containing scheduled operation log properties to be updated
Returns: Dictionary-like object containing the properties of the updated scheduled operation log
Raises ScheduledOperationLogNotFound if scheduled operation log with the given ID doesn’t exist.
-
karbor.db.api.
scheduled_operation_state_create
(context, values)¶ Create a scheduled operation state from the values dictionary.
Parameters: - context – The security context
- values – Dictionary containing scheduled operation state properties
Returns: Dictionary-like object containing the properties of the created scheduled operation state
-
karbor.db.api.
scheduled_operation_state_delete
(context, operation_id)¶ Delete a scheduled operation state from the database.
Parameters: - context – The security context
- operation_id – Operation_id of the scheduled operation state
Raises ScheduledOperationStateNotFound if scheduled operation state with the given ID doesn’t exist.
-
karbor.db.api.
scheduled_operation_state_get
(context, operation_id, columns_to_join=[])¶ Get a scheduled operation state by its id.
Parameters: - context – The security context
- operation_id – Operation_id of the scheduled operation state
Columns_to_join: columns which will be joined
Returns: Dictionary-like object containing properties of the scheduled operation state
- Raises ScheduledOperationStateNotFound if scheduled operation state with
- the given ID doesn’t exist.
-
karbor.db.api.
scheduled_operation_state_get_all_by_filters_sort
(context, filters, limit=None, marker=None, sort_keys=None, sort_dirs=None, columns_to_join=[])¶ Get all operation states that match all filters sorted by multiple keys.
sort_keys and sort_dirs must be a list of strings.
-
karbor.db.api.
scheduled_operation_state_update
(context, operation_id, values)¶ Set the given properties on a scheduled operation state and update it.
Parameters: - context – The security context
- operation_id – Operation_id of the scheduled operation state
- values – Dictionary containing scheduled operation state properties to be updated
Returns: Dictionary-like object containing the properties of the updated scheduled operation state
Raises ScheduledOperationStateNotFound if scheduled operation state with the given ID doesn’t exist.
-
karbor.db.api.
scheduled_operation_update
(context, id, values)¶ Set the given properties on a scheduled operation and update it.
Parameters: - context – The security context
- id – ID of the scheduled operation
- values – Dictionary containing scheduled operation properties to be updated
Returns: Dictionary-like object containing the properties of the updated scheduled operation
Raises ScheduledOperationNotFound if scheduled operation with the given ID doesn’t exist.
-
karbor.db.api.
service_create
(context, values)¶ Create a service from the values dictionary.
-
karbor.db.api.
service_destroy
(context, service_id)¶ Destroy the service or raise if it does not exist.
-
karbor.db.api.
service_get
(context, service_id)¶ Get a service or raise if it does not exist.
-
karbor.db.api.
service_get_all
(context, disabled=None)¶ Get all services.
-
karbor.db.api.
service_get_all_by_topic
(context, topic, disabled=None)¶ Get all services for a given topic.
-
karbor.db.api.
service_get_by_args
(context, host, binary)¶ Get the state of an service by node name and binary.
-
karbor.db.api.
service_get_by_host_and_topic
(context, host, topic)¶ Get a service by host it’s on and topic it listens to.
-
karbor.db.api.
service_update
(context, service_id, values)¶ Set the given properties on an service and update it.
Raises NotFound if service does not exist.
-
karbor.db.api.
trigger_create
(context, values)¶ Create a trigger from the values dictionary.
Parameters: - context – The security context
- values – Dictionary containing trigger properties
Returns: Dictionary-like object containing the properties of the created trigger
-
karbor.db.api.
trigger_delete
(context, id)¶ Delete a trigger from the database.
Parameters: - context – The security context
- id – ID of the trigger
Raises TriggerNotFound if trigger with the given ID doesn’t exist.
-
karbor.db.api.
trigger_get
(context, id)¶ Get a trigger by its id.
Parameters: - context – The security context
- id – ID of the trigger
Returns: Dictionary-like object containing properties of the trigger
Raises TriggerNotFound if trigger with the given ID doesn’t exist.
-
karbor.db.api.
trigger_get_all_by_filters_sort
(context, filters, limit=None, marker=None, sort_keys=None, sort_dirs=None)¶ Get all triggers that match all filters sorted by multiple keys.
sort_keys and sort_dirs must be a list of strings.
-
karbor.db.api.
trigger_update
(context, id, values)¶ Set the given properties on a trigger and update it.
Parameters: - context – The security context
- id – ID of the trigger
- values – Dictionary containing trigger properties to be updated
Returns: Dictionary-like object containing the properties of the updated trigger
Raises TriggerNotFound if trigger with the given ID doesn’t exist.