Supply A Software & Request An Instance

Agenda

  1. Prerequisite
  2. Supplying a Software
  3. Request an Instance
  4. Use a Script to supply and request
  5. Slapos supply output
  6. Slapos request output

This tutorial will teach you how to create a useful Bash script on Theia for supplying a software and requesting an instance on Theia.  

Prerequisites

You can follow the preview tutorial: HowTo Request A Theia Runner and Prepare For The Deployment of Software on Theia to get started.

Supplying a Software

slapos supply: This command is used to add the software to the list of software to be supplied to a node.

$ slapos supply $software_release_uri slaprunner

slapos supply [software] [node]

For example, the software is html5as-base, located in ~/srv/project/slapos/software/html5as-base/software.cfg. We can set a variable named software_release_uri and the value is ~/srv/project/slapos/software/html5as-base/software.cfg

In the case of Rapid.Space Theia, Node is the embedded node named slaprunner

When you are inside theia, you are actually talking to a slapproxy (small slapos master) dedicated to your Theia. 

After supply, the master will list the software as to be supplied by the node. And on the next run of slapos node software in the node will start installing the software.

Requesting an Instance

slapos request: request the allocation of an instance to the master. This commands also get status and parameters of the instance if it has any (the command is meant to be run multiple time until you get the status).

$ slapos request $software_name'_1' $software_release_uri

slapos request "instance_name" [software]

In order to deploy a service, use slapos request to ask the master to allocate an instance for you. Since the slapproxy (small master in Theia) only knows a local node, you are sure the master will allocate the software to your local node. “instance_name” is up to you, and [software] must be exactly the same path you supplied earlier.

request is the command to:

  • create the service if it’s not yet created
  • get parameters from a service

 Use a Script to supply and request

#!/bin/sh
software_name=html5as-base
software_release_uri=~/srv/project/slapos/software/$software_name/software.cfg
slapos supply $software_release_uri slaprunner
slapos request $software_name'_1' $software_release_uri

From terminal, we can use the command presented before to supply a software and request an instance. More documentation is available here: slapos command line.

For convenience, and to make sure you always request the proper software, it is recommended to use a script like the one presented here. Change the software_name of the software release to the one you need, which should be listed in ~/srv/project/slapos/software/

Instances are identified by their name, make sure your instance name is unique. Requesting the same instance with a different software release url is possible, it is used to update instances.

Access Theia

Locate the connection parameter on your Theia service. You can access the Theia using the url and logging in with username and password.

Create the script file

Create a new file under slapos directory and name it as a Bash file (end with .sh)

Edit Script

Edit the file to suit your situation. Here, for example, we would like to deploy html5as-base. The software.cfg is located: ~/srv/project/slapos/software/html5as-base/software.cfg. So we set software_name as html5as_base so the software_release_uri will be ~/srv/project/slapos/software/html5as-base/software.cfg.

As the computer name is slaprunner, we supply $software_release_uri to slaprunner$software_name'_1' is the name for your software's instance.

#!/bin/sh
software_name=html5as-base
software_release_uri=~/srv/project/slapos/software/$software_name/software.cfg
slapos supply $software_release_uri slaprunner
slapos request $software_name'_1' $software_release_uri

Run Script

Open a Terminal by clicking the button on the toolbar or hitting Ctrl+Shift+`.

Locate the script and launch it by

. request-html5as-base.sh
For example, here we are at ~/srv/project, to launch request-html5as-base.sh, we need type
. slapos/request-html5as-base.sh

Reading the output

This the output of slapos supply and slapos request.

 

 

Slapos supply ouput

2021-03-05 17:48:23 slapos[37281] INFO Requesting software installation of /srv/slapgrid/slappart73/srv/project/slapos/software/html5as-base/software.cfg...
2021-03-05 17:48:23 slapos[37281] INFO Done.

This the output of slapos supply. 

 

 

Slapos request output

2021-03-05 17:48:23 slapos[37297] INFO Requesting html5as-base_1 as instance of /srv/slapgrid/slappart73/srv/project/slapos/software/html5as-base/software.cfg...
2021-03-05 17:48:23 slapos[37297] INFO Instance requested.
State is : started.
2021-03-05 17:48:23 slapos[37297] INFO Connection parameters of instance are:
2021-03-05 17:48:23 slapos[37297] INFO {}
2021-03-05 17:48:23 slapos[37297] INFO You can rerun the command to get up-to-date information.

This the output of slapos request.

As it is the first time that we launched the request script, the script is creating the service. After the instance instantiate, you can return the script to get up-to-date information. The connection parameters will be listed. 

 

 

 

Thank You

  • Nexedi SA
  • 147 Rue du Ballon
  • 59110 La Madeleine
  • France
  • +33629024425

For more information, please contact Jean-Paul, CEO of Nexedi (+33 629 02 44 25).