Skip to main content

An adapter to use the lab orchestrator lib in django projects.

Project description

Status Version License Issues Downloads Dependencies Docs

Lab Orchestrator Lib Django Adapter

This package implements the adapters to use the lab orchestrator library in django projects. That means that some data of the lab orchestrator library will be saved in the django database.

Github
PyPi
Read The Docs

Setup

Installation

Install this library with: pip install lab-orchestrator-lib-django-adapter.

Project setup

Assuming you have a django application, first define the following variables in your settings.py:

  • DEVELOPMENT (bool): If this is true the development mode is activated. This means, that no cacert is used and insecure certs are allowed. If false this assumes you are running this inside a Kubernetes cluster.
  • SECRET_KEY (str): This key is used to create jwt tokens. Create a random key for this and keep this key safe.

After that add lab_orchestrator_lib_django_adapter to the INSTALLED_APPS variable in your settings.py.

Environment Variables

The library makes use of some environment variables that you need to set:

  • KUBERNETES_SERVICE_HOST (str): Host of your Kubernetes API (if you run kubectl proxy: localhost)
  • KUBERNETES_SERVICE_PORT (int): Port of your Kubernetes API (if you run kubectl proxy: 8001)
  • DEVELOPMENT (bool): If this is true the development mode is activated. This means, that no cacert is used and insecure certs are allowed. If false this assumes you are running this inside a Kubernetes cluster.

Usage

You have three Model classes:

  • DockerImageModel
  • LabModel
  • LabInstanceModel

Those three models are used to save data from the library in the django database and those can all be used safely in read only view sets. The DockerImageModel and LabModel can also be used safely in a delete, update and create view sets. To create and delete a LabInstanceModel you need to use the lab instance controller. Updating a LabInstanceModel is not allowed.

To get extra information from Kubernetes resources you need to use the controllers.

A default ControllerCollection can be got with the get_default_cc method in lab_orchestrator_lib_django_adapter.controller_collection module. The controllers are part of the lab orchestrator lib and there you can find documentation about how to use this.

An example on how to use this library in ViewSets can be found in the views.py.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page