This module allows interaction with multiple Sandbox servers.
Sandbox
Multiple Sandbox can be defined, each Sandbox must have a unique name and url, they also have a booleansandbox.enabled, allowing to enable/disable Sandbox on command.
SandboxSpecs, ContainerSpecs and Usage
When a new Sandbox is created, two django_celery_beat.models.PeriodicTask are created :
One to run Sandbox.poll_specifications() every settings.SANDBOX_POLL_SPECS_EVERY
The other to run Sandbox.poll_usage() every settings.SANDBOX_POLL_USAGE_EVERY
The tasks will only run if Celery is running (through ./bin/celery.sh). Celery also need Redis, which can be easily ran inside a container with ./bin/redis_docker.sh (Redis will also be needed for websocket).
Specifications are stored inside two models :
SandboxSpecs, accessed through sandbox.server_specs, which contains information about the hosting machine.
ContainerSpecs, accessed through sandbox.container_specs, which contains information about a container on the sandbox.
Usages are stored in the model Usage, a sandbox can list all its usage (sorted by date) with sandbox.usages.all().
Request, Response and CommandResult
Sandbox has an execute() method that sends an execute/ request to the corresponding server. This method create a new Request instance, containing information about the execution such as user, date, config and status.
If status is False, it means that an error occured during the execution. The field traceback will contains information about the error (response field will be None).
If status is True, the field response will contain the details of the execution (traceback will be set to an empty string).
A Response contains all the general information about the execution, and a list of CommandResult, which contain details for each command.
This module allows interaction with multiple Sandbox servers.
Sandbox
Multiple
Sandbox
can be defined, eachSandbox
must have a uniquename
andurl
, they also have aboolean
sandbox.enabled
, allowing to enable/disableSandbox
on command.SandboxSpecs, ContainerSpecs and Usage
When a new
Sandbox
is created, twodjango_celery_beat.models.PeriodicTask
are created :Sandbox.poll_specifications()
everysettings.SANDBOX_POLL_SPECS_EVERY
Sandbox.poll_usage()
everysettings.SANDBOX_POLL_USAGE_EVERY
The tasks will only run if Celery is running (through
./bin/celery.sh
). Celery also need Redis, which can be easily ran inside a container with./bin/redis_docker.sh
(Redis will also be needed for websocket).Specifications are stored inside two models :
SandboxSpecs
, accessed throughsandbox.server_specs
, which contains information about the hosting machine.ContainerSpecs
, accessed throughsandbox.container_specs
, which contains information about a container on the sandbox.Usages are stored in the model
Usage
, asandbox
can list all its usage (sorted by date) withsandbox.usages.all()
.Request, Response and CommandResult
Sandbox
has anexecute()
method that sends anexecute/
request to the corresponding server. This method create a newRequest
instance, containing information about the execution such asuser
,date
,config
andstatus
.status
isFalse
, it means that an error occured during the execution. The fieldtraceback
will contains information about the error (response
field will beNone
).status
isTrue
, the fieldresponse
will contain the details of the execution (traceback
will be set to an empty string).A
Response
contains all the general information about the execution, and a list ofCommandResult
, which contain details for each command.See django_sandbox.models for more information.