chaosmonkey.dal package¶
Submodules¶
chaosmonkey.dal.cme_sqlalchemy_store module¶
CMESQLAlchemyStore replaces the default SQLAlchemyJobstore from apscheduler
It controls the persistence layer.
-
class
chaosmonkey.dal.cme_sqlalchemy_store.
CMESQLAlchemyStore
(pickle_protocol=4)[source]¶ Bases:
apscheduler.jobstores.base.BaseJobStore
Manage persistence for apscheduler and CMEEngine.
This class is used by the apscheduler, all overridden methods should return appscheduler.job.Job objects.
The store handles 2 types of models: plans and executors. Internally apscheduler names the executors as jobs.
- TODO: executors are marked as executed when they are processed
- (no mather if they fail or succeed. We need to handle execution errors in order to know whats going on with the execution and what was its result.)
- Plans:
chaosmonkey.dal.plan_model.Plan()
- Executors:
chaosmonkey.dal.executor_model.Executor()
-
delete_plan
(plan_id)[source]¶ Delete a plan.
All the executors related to the plan are deleted. (ON_DELETE constrain in db.Models)
Parameters: plan_id – string
-
get_executor
(executor_id)[source]¶ Get an executor
Parameters: executor_id – string Returns: List of Executor
-
get_executors_for_plan
(plan_id)[source]¶ Get a list of executors related to a plan by its plan_id
Parameters: plan_id – string Returns: List of Executor
-
get_plans
(show_all=False)[source]¶ Return a list of plans created on db. For each plan return the number of pending executors and the next_run_time of the first executor
Returns: List of Plans
chaosmonkey.dal.database module¶
SQLAlchemy database
chaosmonkey.dal.executor_model module¶
-
class
chaosmonkey.dal.executor_model.
Executor
(job_id, next_run_time, plan_id, job_state=None)[source]¶ Bases:
flask_sqlalchemy.Model
Executors are persistent representations of scheduled jobs. This model is shared between the cme and apscheduler.
-
executed
¶ if the job was executed
-
id
¶ unique identifier
-
job_state
¶ store the full state of the executor (with pickle)
-
next_run_time
¶ DateTime for the executor to be executed
-
plan_id
¶ plan id reference
-
to_dict
()[source]¶ Return a
chaosmonkey.api.hal.document()
representation for the ExecutorReturns: chaosmonkey.dal.executor_model.HalExecutor()
-
chaosmonkey.dal.plan_model module¶
-
class
chaosmonkey.dal.plan_model.
HalPlan
(data=None, links=None, embedded=None)[source]¶ Bases:
chaosmonkey.api.hal.BaseDocument
Class to represent a Plan as a
chaosmonkey.api.hal.document()
-
class
chaosmonkey.dal.plan_model.
Plan
(_id=None, name=None, created=None, next_execution=None, executors_count=0, executed=False)[source]¶ Bases:
flask_sqlalchemy.Model
Store information about the plan and its executors.
This model is only used by the cme.
-
created
¶ creation datetime
-
executed
¶ if all the executors in the plan has been executed
-
executors_count
= None¶ number of pending executors
-
id
¶ unique identifier
-
jobs
¶
-
name
¶ plan name
-
next_execution
= None¶ DateTime for the next executor execution time
-
to_dict
()[source]¶ Returns a
chaosmonkey.api.hal.document()
representation for the ExecutorReturns: chaosmonkey.dal.plan_model.HalPlan()
-