Models
The library contains two types of resources. The first is Kubernetes resources. This type contains NetworkPolicy
, VirtualMachineInstance
and Namespace
objects. These are resources from Kubernetes that doesn’t need to be saved.
The second type is database resources. They are saved in the database. For every database resource an adapter needs to be added. This type contains user
, DockerImage
, LabDockerImage
, Lab
and LabInstance
objects.
Database resources:
Abstract resources:
This guide refers to valid dns labels and valid dns subdomain names. The definitions of these two can be found here:
User
- class lab_orchestrator_lib.model.model.User(primary_key)
Bases:
lab_orchestrator_lib.model.model.Model
A User of the library.
Methods
Docker Image
- class lab_orchestrator_lib.model.model.DockerImage(primary_key, name, description, url)
Bases:
lab_orchestrator_lib.model.model.Model
Link to a Docker Image that contains a VM image.
A docker image object is a link to a docker image that contains a VM image. This is used to create labs. If your image is in docker hub the link only needs to contain username/reponame:version and no https://… stuff.
Methods
- __init__(primary_key, name, description, url)
Initializes a docker image object.
- Parameters
- Raises
ValidationError – if one of the parameters has an invalid value.
Lab Docker Image
- class lab_orchestrator_lib.model.model.LabDockerImage(primary_key, lab_id, docker_image_id, docker_image_name)
Bases:
lab_orchestrator_lib.model.model.Model
A Lab Docker Image is a docker image that is referenced to a lab.
This is needed to have multiple VMs in one lab.
Methods
- __init__(primary_key, lab_id, docker_image_id, docker_image_name)
Initializes a lab docker image.
- Parameters
- Raises
ValidationError – if one of the parameters has an invalid value.
Lab
- class lab_orchestrator_lib.model.model.Lab(primary_key, name, namespace_prefix, description)
Bases:
lab_orchestrator_lib.model.model.Model
Lab is a combination of VMs that can be started.
When you start a lab a lab_instance will be created and the VMs are started in Kubernetes. A lab is used to combine VMs in a scenario.
Methods
- __init__(primary_key, name, namespace_prefix, description)
Initializes a lab object.
- Parameters
primary_key (
Union
[str
,int
]) – A unique value to identify the object.name (
str
) – The name of the lab. (min. 1 char, max. 32 chars)namespace_prefix (
str
) – A prefix that is used in the namespace in Kubernetes where the VMs are started. (max. 32 chars and needs to be a valid dns label)description (
str
) – A short description of the docker image. (min. 1 char, max. 128 chars)
- Raises
ValidationError – if one of the parameters has an invalid value.
Lab Instance
- class lab_orchestrator_lib.model.model.LabInstance(primary_key, lab_id, user_id)
Bases:
lab_orchestrator_lib.model.model.Model
A lab instance is a lab that is started by a user.
A lab instance is linked to many Kubernetes resources. Lab instances are created by the controllers when you start a lab. When you create them by your own you’re probably doing something wrong.
Methods
- __init__(primary_key, lab_id, user_id)
Initializes a lab instance object.
- Parameters
- Raises
ValidationError – if one of the parameters has an invalid value.
Lab Instance Kubernetes
- class lab_orchestrator_lib.model.model.LabInstanceKubernetes(primary_key, lab_id, user_id, jwt_token, allowed_vmis)
Bases:
lab_orchestrator_lib.model.model.Model
A lab instance with a token.
Doesn’t need any adapter and should not be saved in the database. This is used to return the JWT access token when the lab is started.
Methods
- __init__(primary_key, lab_id, user_id, jwt_token, allowed_vmis)
Initializes a lab instance kubernetes object.
- Parameters
primary_key (
Union
[str
,int
]) – A unique value to identify the object. (if string, max. 14 chars)lab_id (
Union
[str
,int
]) – The id of the lab that is started.user_id (
Union
[str
,int
]) – The id of the user that has started the lab.jwt_token (
str
) – JWT token that can be used to access the VMs in this lab instance.allowed_vmis (
List
[str
]) – List of VMI names that the user is allowed to open.
Model
This class should not be used. It’s just a abstract base class used for all models.