Skip to content

Create Template Repository

This section demonstrates the process of creating an individual repository, including templates that are already uploaded on the Sunlight.io Portal. By selecting the Administration option tab, the user can view information about the existing system Template repositories. In order to create a new template, click on the "plus" sign, as indicated in the following figure:

Administration Template Repositories

Authentication based Repository - Cloud edition

As a first step, fill in the required (Username/Password) credentials and provide a name for the new repository.

Add new template repository

The new repository, representing the template portal repo, will appear in the templates repository section with the provided name, as depicted in the following image. The user is also able to delete created repositories by selecting the "Actions" option on the left side of the screen.

Templates Repositories Administration section

The user is now able to select the 'Instances' tab and navigate to the 'Image Templates' section. The new repository has been created and is available for selection. It is evident that this repository is composed of already uploaded templates from the Portal, as demonstrated in the following image.

Templates Repositories Administration section

URL based Repository - Local template server

A second option is also available, where instead of adding the requested credentials, users are able to add the URL of their own repository, besides Sunlight.io Portal, including a custom.json format, as it is documented below.

"Own repository" is defined as being a web server serving a simple directory, ie directory index function.


A simple example for installing such a server is presented below:

  • It is assumed that a VM already exists (named as the local template serving VM), local to the network of the controller (meaning that the controller will have access to that VM, for simple HTTP requests)
  • For this example, UBUNTU is the VM's installed distro.

Step 1

Install apache2 web server on the VM, using the following commands:

sudo apt update
sudo apt install apache2

Step 2

Verify that the apache2 webserver is installed, as well as that it is running:

apache2 -version
sudo systemctl status apache2

Step 3

In order to verify that the default webpage of apache2 is visible, please visit the following address through a web browser:

http://<VM ip>/

The apache2 Ubuntu default page should be visible.

Step 4

During installation, apache2 creates a default vhost entry, usually called 000-default.conf. The root directory of this vhost is normally set to /var/www/html/.

This root directory is where all the converted template files, their corresponding compressed versions, as well as the json files (described above) should be copied.

these few steps are meant as the most basic and simple installation, in order to create a webserver "serving" the required templates to the Sunlight controler

Please continue with the steps below

In the URL field, please fill in the address of the reposiroty that contains the template images, that is the VM IP tested above. It is also requested to provide a unique name for this repo.

The format of the URL address that indicates the template images' repository should have the following format:

URL : https://<client_local_address>/<filename>.json

Templates Repositories Administration section

Two necessary files for each template image should be included into the templates' repository. The first one is the image file in .qcow2 format and the second is the corresponding compressed file of this image in .tar.gz format.

A templates.json file should also be provided, describing the specifications of each template image.

Please follow the actions below, each time you wish to alter (add or remove) the template specifications in the tempaltes.json file.

Action 1

Download the templates genarator script called json_gen.py to the root directory of the vhost /var/www/html/, in the local template serving VM.

$: cd /var/www/html/
$: wget assets.sunlight.io/scripts/json_gen.py

Action 2

Add the specifications of a new template into the templates.json file, by executing the following command:

$: ./json_gen.py --provider <provider_name> //
    --image_name <tempalte_name> --os_version //
    <version_id> --os_distro <distro_name> //
    --min_ram <ram_size in MB> --add_template

e.g $: ./json_gen.py --provider sunlight.io // 
          --image_name sunlight.qcow2 --os_version 7 //
          --os_distro centos --min_ram 4096 --add_template

Run the above command every time you wish to add a new template specification into the templates.json

Action 3

Remove the specifications of an existing template from the templates.json file, by executing the following command:

$: ./json_gen.py --delete_template  //
    --image_name <template_name>

e.g $: ./json_gen.py --delete_template  //
          --image_name sunlight.qcow2

Run the above command every time you wish to delete the specifications of an existing template from the templates.json file.

Action 4

Check the current version of the json_gen.py script, by executing the following command:

$: ./json_gen.py --version

An explanation of the required fields is presented below:

  • Provider name : type a name of your choice as provider (e.g. company name)
  • architecture: x86_64 supported
  • cluster_type: vm supported
  • requirements_meta: This feature will be supported in a future release (currently this field should remain blank)
  • name: name of the qccow2 image that is included on tar.gz file. The complete filename should be provided
  • os_version: OS distribution version
  • os_distro: OS distribution type
  • vm_type: one option available: hvm
  • metadata: blank
  • min_ram: minimum image ram size
  • min_disk: minimum image disk size in GBs
  • date: the date of providing the template image (in a string format)
  • has_cloudinit: true for linux distributions, false for windows distributions
  • container_format: one option available: bare
  • disk_format: qcow2
  • remote_status: this option should be enabled
  • hash: sha1sum checksum of qcow2 image (not tar.gz)

The following example serves as an indication of how the required fields should be filled in:

For example : Filename.json

{
  "templates": [
      {
            "provider": "Sunlight.io",
            "architecture": "x86_64",
            "cluster_type": "vm",
            "requirements_meta": "",
            "name": "Sunlight_instance.qcow2",
            "os_version": "7",
            "os_distro": "centos",
            "vm_type": "hvm",
            "metadata": "",
            "min_ram": 4096,
            "min_disk": 25,
            "filesize": "5120"
            "date": "20190708",
            "has_cloudinit":true,
            "container_format":"bare",
            "disk_format":"qcow2",
            "remote_status":"enabled",
            "hash": "4a7a60a404d167ec0e991faf6cb966e453b3b703"
        }
   ]
}

Download Template

In case the user needs to use one of the available templates from the remote repository, it is initially requested to download these templates locally by selecting the 'Actions' option, followed by the 'Download' option, as illustrated in the following image.

Templates Repositories Administration section

Delete Template Repository

In case the user would like to delete a custom repository from Sunlight Platform, it is requested to click on 'Administration' option tab, navigate to the 'Template Repositories' section by selecting the 'Actions' option, followed by the 'Delete' option, as illustrated in the following image.

Delete Template Repository