Skip to content

How to launch an Application

Stefano edited this page Jun 27, 2019 · 1 revision

The application lifecycle is described by 5 states: Lifecycle automa

The application package journey, from your computer to the simulator database

The application file during the start state is on your computer. It is a .tar.gz file, compiled with IOx that includes a yaml description of your application. The simulator uses that description to know the application's name and the estimated resources usage.

Then, you can upload the application on the simulator (equally on FogDirector). To do this you can use POST /api/v1/appmgr/localapps/upload specifying the x-token-id (we assume from now that every future calls have that parameter) and publish-on-upload (optional) parameters. The simulator receives the application and saves it. A new application id is returned and a document in the applications collection is created.

In order to install it on a device (assumed already inserted), a myapp have to be created. A myapp is a deployment and can be created using the function POST /api/v1/appmgr/myapps and as payload the application description: {"name":appname,"sourceAppName":"c36d727c-e9c5-46ed-bc7ecbdd5cf49786:1.0","version":"1.0","appSourceType":"LOCAL_APPSTORE"}. Even in that case, an identifier is returned. In the simulator, the myapp is saved as a document in the myapps collection.

Now, it is possible to install a myapp on several devices using POST /api/v1/appmgr/myapps/<myappid>/action and passing as payload the following json conveniently set:

{
 "deploy": {
   "config": {
     
   },
   "metricsPollingFrequency": "3600000",
   "startApp": true,
   "devices": [
     {
       "deviceId": "0123abcd",
       "resourceAsk": {
         "resources": {
           "profile": "c1.tiny",
           "cpu": 100,
           "memory": 32,
           "network": [
             {
               "interface-name": "eth0",
               "network-name": "iox-bridge0"
             }
           ]
         }
       }
     }
   ]
 }
}

Even if the JSON accepts a device array, we suggest to instance one myapp for every device in order to maintain a one-to-one correspondence between myapp and job, that permits a more easily analysis of the entire system.

Performin the previous POST /api/v1/appmgr/myapps/<myappid>/action, the application files are uploaded on the devices and the application is ready to be started. In order to start the application use the same endpoin before, POST /api/v1/appmgr/myapps/<myappid>/action, with the following payload:

{
 "start":{}
}

All endpoint can be used using the python wrapper present in the management-scripts folder of this project.