Skip to content

DSP Server Implementation

Gaetano Perrone edited this page Dec 14, 2019 · 1 revision

Server-side

All server-side code is located on app directory. It is composed by the following subdirectories:

  • handler: all restful requests are managed by modules inside this directory;

  • data: all data modules help to resolve different low-level problems, such as to save labs, to convert graphic network description in a docker-compose file, to save the graphic network description;

  • utils: all util modules are helper modules for handler and data modules.

Handler layer

Handler layer manages all restful api requests

  • config manages configuration requests, by updating the user configuration file located in /config directory (config_user.json)

  • tree_routes manages all file requests, for example when the user uploads a new file to .data directory, or when the user selects a directory from the tree directory interface:

  • labels module manages all labels operations (allLabels returns all user repository labels, deleteLabel delete a label from labels.json);

  • labs module manages all labs operation (delete lab, save and delete descriptive informations, create a new lab or save a lab);

  • network manages all graphic network operations: save a graphic network description, return the complete list of images, check if the graphic network has been created (dirExists), return the graphic network description.

Modules use data layer to interact with docker and the file system.

Data layer

Data layer is an helper module for the layer data.

labs, labels and network data modules are basic data modules to manage all main DSP json files (labs manages descriptions.json, labels manages labels.json and network manages network.json).

Docker modules offer docker services, while walker module walks all directories to return a json rappresentation of all repositories and labs.

docker modules

All these modules offer docker services to handlers layer:

  • docker-images.js returns the list of docker images, by using a NPM module called mydockerjs;

  • docker_actions.js module has a method that accepts a list of containers and returns the list of commands to send to docker-compose when the lab runs;

  • docker_capabilities.js module is a simple module that checks if a given capability is compatible with docker-compose capabilities;

  • docker-converter.js converts a json object rappresentation of containers (sent by the user through docker_graph_editor.html) into a docker-compose file;

  • docker_filesToCopy.js module has a method that accepts a list of containers and returns the list of files to copy.

  • dockerVolumes.js manage volume operations: when the user create a network with some containers that uses the volume option, a new volume dir is created on lab directory. If then the user deletes that container from the graphic network description, volume dir is not more used, so it should be destroyed. dockerVolumes manages all these operations.