ICG Controller
This repository contains all the required code and templates to run the ICG component, it also contains a Dockerfile that builds the complete image of the ICG with a provided REST API
Requirements
- Docker
Installation
To have a functional ICG application the following steps can be used.
- Download the full content of this repository
- Build the docker image launching the following command:
docker build -t icg:1.0.0 .
- Run the container:
docker run --name icg -d -p 5000:5000 icg:1.0.0
Usage
To use the now running ICG docker container we can call the available REST API.
The API is available at http://localhost:5000/docs. You can try here the endpoint behavior:
- POST /infrastructure/files generates iac compress folder from json intermediate representation (see input_file_example/nginx/parameters.json as an example body).
- POST /iac/files generates iac compress folder from doml model (ex. nginx-openstack_v2.domlx)
Otherwise, send a POST request at this endpoint with the indicated json body (see input_file_example/nginx/parameters.json as an example body) it will respond with a .tar.gz file containing all the required IaC files:
- curl --location --request POST localhost:5000/infrastructure/files --header "Content-Type: application/json" --data "@parameters.json" --output "OutputIaC.tar.gz"
Uninstall
Remove the docker container and the docker image:
docker container rm -f icg
docker rmi icg:0.1
Usage from command line
Usage: python main.py [-h] [-d dir] model
- -h prints usage
- -d dir loads metamodel from <dir>
- --single or --single_mmodel use the single (non-split) metamodel
- model the model to be loaded
py .\main.py -d <doml_folder> --single <metamodel_file_path>
Example:
py .\main.py -d icgparser/doml --single icgparser/doml/nginx-openstack_v2.domlx
Folders Structure
- output_file_example: in this folder there is the output of the ICG tested for the examples considered during the PIACERE interations. The output files are tested and represents how the ICG output should be.
- output_files_generated: in this folder there is the output generated by the execution of the ICG
- input_file_example: in this folder there is an example of how the ICG intermediate representation should be for the examples considered during the PIACERE interations
- input_file_generated: in this folder there is the intermediate representation generated by the execution of the ICG