Skip to content

Latest commit

 

History

History
84 lines (58 loc) · 4.57 KB

README.md

File metadata and controls

84 lines (58 loc) · 4.57 KB

Yorc Plugin example

Build Status Go Report Card

This repository provides an example of plugin extending the Ystia orchestrator, as described in Yorc documentation on plugins.

The plugin example implemented here provides :

  • a new TOSCA definition for a Compute Instance to create on demand, in file tosca/mycustom-types.yaml
  • an example of application TOSCA topology template using this new definition, in file tosca/topology.yaml
  • a delegate executor that will manage the provisioning of such compute instance (here it just prints logs and send events)
  • an operation executor allowing to execute operations (here it just prints logs and send events)
  • This plugin expects two locations named my-location and my-plugin-location to be defined in conf/locations.json (in a real case, it could be a URL and credentials to access the service allowing to manage the infrastructure).

Build

On a linux host, install go 1.13 or a newer version. Then build the plugin running :

$ make

The plugin will be available at bin/my-plugin

Test the plugin in a development environment

You can quickly setup a development environment that will allow you to test your plugin using Yorc docker images.

Download the latest Yorc docker image:

$ docker pull ystia-docker.jfrog.io/ystia/yorc:latest

Run Yorc mounting the directory bin in your host on the container directory /var/yorc/plugins (default path where Yorc expects to find plugins), and mounting as well the directory tosca where an example of TOSCA deployment topology is provided.

Two locations with properties and their own infrastructure type have been defined and are expected in this plugin. The locations file path configuration is passed as an environment variable YORC_LOCATIONS_FILE_PATH:

$ docker run -d --rm \
    -e 'YORC_LOCATIONS_FILE_PATH=/var/yorc/conf/locations.json' \
    -e 'YORC_LOG=1' \
    --mount "type=bind,src=$PWD/conf,dst=/var/yorc/conf" \
    --mount "type=bind,src=$PWD/bin,dst=/var/yorc/plugins" \
    --mount "type=bind,src=$PWD/tosca,dst=/var/yorc/topology" \
    --name yorc \
    ystia-docker.jfrog.io/ystia/yorc:latest

Now that a Yorc server is running, it has automatically loaded the plugin available through the mount in the default plugins directory /var/yorc/plugins, and delegate/operation executors able to manage our new types are now registered.

We can deploy the example application topology making use of these newly defined types:

docker exec -it yorc sh -c "yorc d deploy --id my-test-app /var/yorc/topology/topology.yaml"

You can then check the deployment logs, running :

docker exec -it yorc sh -c "yorc d logs --from-beginning  my-test-app"

You should see logs of the installation workflow describing state changes as well as the event sent by our plugin delegate executor implementation:

[INFO][install][...][Compute][][delegate][install][]**********Provisioning node "Compute" of type "mytosca.types.Compute"

as well as the event sent by our plugin operation executor:

[INFO][my-test-app][install][...][Soft][][standard][create][]******Executing operation "standard.create" on node "Soft"

Going further

You can check one of the Yorc implementation for OpenStack, AWS, Google Cloud, hosts pool, or SLURM. For example: