Models¶
saltant model instances are repesented with model classes in saltant-py. These model classes have saltant model instance attributes as class attributes (e.g., UUIDs for task instances).
For some models, notably, the task instance models, there are convenience methods for, in the case of task instances, cloning, terminating, and waiting until completion.
Model references¶
-
class
saltant.models.container_task_instance.
ContainerTaskInstance
(uuid, name, state, user, task_queue, task_type, datetime_created, datetime_finished, arguments, manager)¶ Bases:
saltant.models.base_task_instance.BaseTaskInstance
Model for container task instances.
-
name
¶ str – The name of the task instance.
-
uuid
¶ str – The UUID of the task instance.
-
state
¶ str – The state of the task instance.
-
user
¶ str – The username of the user who started the task.
-
task_queue
¶ int – The ID of the task queue the instance is running on.
-
task_type
¶ int – The ID of the task type for the instance.
-
datetime_created
¶ datetime.datetime
– The datetime when the task instance was created.
-
datetime_finished
¶ datetime.datetime
– The datetime when the task instance finished.
-
arguments
¶ dict – The arguments the task instance was run with.
-
manager
¶ saltant.models.container_task_instance.ContainerTaskInstanceManager
– The task instance manager which spawned this task instance … instance.
-
clone
()¶ Clone this task instance.
Returns: A task instance model instance representing the task instance created due to the clone. Return type: saltant.models.base_task_instance.BaseTaskInstance
-
sync
()¶ Sync this model with latest data on the saltant server.
Note that in addition to returning the updated object, it also updates the existing object.
Returns: This task instance … instance after syncing. Return type: saltant.models.base_task_instance.BaseTaskInstance
-
terminate
()¶ Terminate this task instance.
Returns: This task instance model after it was told to terminate. Return type: saltant.models.base_task_instance.BaseTaskInstance
-
wait_until_finished
(refresh_period=5)¶ Wait until a task instance with the given UUID is finished.
Parameters: refresh_period (int, optional) – How many seconds to wait before checking the task’s status. Defaults to 5 seconds. Returns: This task instance model after it finished. Return type: saltant.models.base_task_instance.BaseTaskInstance
-
-
class
saltant.models.container_task_type.
ContainerTaskType
(id, name, description, user, datetime_created, command_to_run, environment_variables, required_arguments, required_arguments_default_values, logs_path, results_path, container_image, container_type, manager)¶ Bases:
saltant.models.base_task_type.BaseTaskType
Model for container task types.
-
id
¶ int – The ID of the task type.
-
name
¶ str – The name of the task type.
-
description
¶ str – The description of the task type.
-
user
¶ str – The user associated with the task type.
-
datetime_created
¶ datetime.datetime
– The datetime when the task type was created.
-
command_to_run
¶ str – The command to run inside the container to execute the task.
-
environment_variables
¶ list – The environment variables required on the host to execute the task.
-
required_arguments
¶ list – The argument names for the task type.
-
required_arguments_default_values
¶ dict – Default values for the tasks required arguments.
-
logs_path
¶ str – The path of the logs directory inside the container.
-
results_path
¶ str – The path of the results directory inside the container.
-
container_image
¶ str – The container name and tag. For example, ubuntu:14.04 for Docker; and docker://ubuntu:14:04 or shub://vsoch/hello-world for Singularity.
-
container_type
¶ str – The type of the container.
-
manager
¶ saltant.models.container_task_type.ContainerTaskTypeManager
– The task type manager which spawned this task type.
-
put
()¶ Updates this task type on the saltant server.
Returns: A task type model instance representing the task type just updated. Return type: saltant.models.container_task_type.ContainerTaskType
-
sync
()¶ Sync this model with latest data on the saltant server.
Note that in addition to returning the updated object, it also updates the existing object.
Returns: This task type instance after syncing. Return type: saltant.models.base_task_type.BaseTaskType
-
-
class
saltant.models.executable_task_instance.
ExecutableTaskInstance
(uuid, name, state, user, task_queue, task_type, datetime_created, datetime_finished, arguments, manager)¶ Bases:
saltant.models.base_task_instance.BaseTaskInstance
Model for executable task instances.
-
name
¶ str – The name of the task instance.
-
uuid
¶ str – The UUID of the task instance.
-
state
¶ str – The state of the task instance.
-
user
¶ str – The username of the user who started the task.
-
task_queue
¶ int – The ID of the task queue the instance is running on.
-
task_type
¶ int – The ID of the task type for the instance.
-
datetime_created
¶ datetime.datetime
– The datetime when the task instance was created.
-
datetime_finished
¶ datetime.datetime
– The datetime when the task instance finished.
-
arguments
¶ dict – The arguments the task instance was run with.
-
manager
¶ saltant.models.executable_task_instance.ExecutableTaskInstanceManager
– The task instance manager which spawned this task instance.
-
clone
()¶ Clone this task instance.
Returns: A task instance model instance representing the task instance created due to the clone. Return type: saltant.models.base_task_instance.BaseTaskInstance
-
sync
()¶ Sync this model with latest data on the saltant server.
Note that in addition to returning the updated object, it also updates the existing object.
Returns: This task instance … instance after syncing. Return type: saltant.models.base_task_instance.BaseTaskInstance
-
terminate
()¶ Terminate this task instance.
Returns: This task instance model after it was told to terminate. Return type: saltant.models.base_task_instance.BaseTaskInstance
-
wait_until_finished
(refresh_period=5)¶ Wait until a task instance with the given UUID is finished.
Parameters: refresh_period (int, optional) – How many seconds to wait before checking the task’s status. Defaults to 5 seconds. Returns: This task instance model after it finished. Return type: saltant.models.base_task_instance.BaseTaskInstance
-
-
class
saltant.models.executable_task_type.
ExecutableTaskType
(id, name, description, user, datetime_created, command_to_run, environment_variables, required_arguments, required_arguments_default_values, json_file_option, manager)¶ Bases:
saltant.models.base_task_type.BaseTaskType
Model for executable task types.
-
id
¶ int – The ID of the task type.
-
name
¶ str – The name of the task type.
-
description
¶ str – The description of the task type.
-
user
¶ str – The user associated with the task type.
-
datetime_created
¶ datetime.datetime
– The datetime when the task type was created.
-
command_to_run
¶ str – The command to run to execute the task.
-
environment_variables
¶ list – The environment variables required on the host to execute the task.
-
required_arguments
¶ list – The argument names for the task type.
-
required_arguments_default_values
¶ dict – Default values for the task’s required arguments.
-
json_file_option
¶ str – The name of a command line option, e.g., –json-file, which accepts a JSON-encoded file for the command to run.
-
manager
¶ saltant.models.executable_task_type.ExecutableTaskTypeManager
– The task type manager which spawned this task type instance.
-
put
()¶ Updates this task type on the saltant server.
Returns: An executable task type model instance representing the task type just updated. Return type: saltant.models.container_task_type.ExecutableTaskType
-
sync
()¶ Sync this model with latest data on the saltant server.
Note that in addition to returning the updated object, it also updates the existing object.
Returns: This task type instance after syncing. Return type: saltant.models.base_task_type.BaseTaskType
-
-
class
saltant.models.task_queue.
TaskQueue
(id, user, name, description, private, runs_executable_tasks, runs_docker_container_tasks, runs_singularity_container_tasks, active, whitelists, manager)¶ Bases:
saltant.models.resource.Model
Base model for a task queue.
-
id
¶ int – The ID of the task queue.
-
user
¶ str – The user who created the task queue.
-
name
¶ str – The name of the task queue.
-
description
¶ str – The description of the task queue.
-
private
¶ bool – A Booleon signalling whether the queue can only be used by its associated user.
-
runs_executable_tasks
¶ bool – A Boolean specifying whether the queue runs executable tasks.
-
runs_docker_container_tasks
¶ bool – A Boolean specifying whether the queue runs container tasks that run in Docker containers.
-
runs_singularity_container_tasks
¶ bool – A Boolean specifying whether the queue runs container tasks that run in Singularity containers.
-
active
¶ bool – A Booleon signalling whether the queue is active.
-
whitelists
¶ list – A list of task whitelist IDs.
-
manager
¶ saltant.models.task_queue.TaskQueueManager
– The task queue manager which spawned this task queue.
-
patch
()¶ Updates this task queue on the saltant server.
This is an alias for the model’s put method. (Both are identical operations on the model level.)
Returns: A task queue model instance representing the task queue just updated. Return type: saltant.models.task_queue.TaskQueue
-
put
()¶ Updates this task queue on the saltant server.
Returns: A task queue model instance representing the task queue just updated. Return type: saltant.models.task_queue.TaskQueue
-
sync
()¶ Sync this model with latest data on the saltant server.
Note that in addition to returning the updated object, it also updates the existing object.
Returns: This task queue instance after syncing. Return type: saltant.models.task_queue.TaskQueue
-
-
class
saltant.models.task_whitelist.
TaskWhitelist
(id, user, name, description, whitelisted_container_task_types, whitelisted_executable_task_types, manager)¶ Bases:
saltant.models.resource.Model
Base model for a task whitelist.
-
id
¶ int – The ID of the task whitelist.
-
user
¶ str – The user who created the task whitelist.
-
name
¶ str – The name of the task whitelist.
-
description
¶ str – The description of the task whitelist.
-
whitelisted_container_task_types
¶ list – A list of whitelisted container task type IDs.
-
whitelisted_executable_task_types
¶ list – A list of whitelisted executable task type IDs.
-
manager
¶ saltant.models.task_whitelist.TaskWhitelistManager
– The task whitelist manager which spawned this task whitelist.
-
patch
()¶ Updates this task whitelist on the saltant server.
This is an alias for the model’s put method. (Both are identical operations on the model level.)
Returns: A task whitelist model instance representing the task whitelist just updated. Return type: saltant.models.task_whitelist.TaskWhitelist
-
put
()¶ Updates this task whitelist on the saltant server.
Returns: A task whitelist model instance representing the task whitelist just updated. Return type: saltant.models.task_whitelist.TaskWhitelist
-
sync
()¶ Sync this model with latest data on the saltant server.
Note that in addition to returning the updated object, it also updates the existing object.
Returns: This task whitelist instance after syncing. Return type: saltant.models.task_whitelist.TaskWhitelist
-
-
class
saltant.models.user.
User
(username, email, manager)¶ Bases:
saltant.models.resource.Model
Base model for a user.
-
username
¶ str – The user’s username.
-
email
¶ str – The user’s email.
-
manager
¶ saltant.models.user.UserManager
– The manager which spawned this user instance.
-
sync
()¶ Sync this model with latest data on the saltant server.
Note that in addition to returning the updated object, it also updates the existing object.
Returns: This user instance after syncing. Return type: saltant.models.user.User
-