Creating your own VNF charm (Release ONE): Difference between revisions
No edit summary |
No edit summary |
||
Line 34: | Line 34: | ||
===Creating a proxy charm=== | ===Creating a proxy charm=== | ||
====Setup==== | |||
If you are running Ubuntu, you can install the latest Juju via its stable PPA: | |||
<nowiki> | |||
sudo add-apt-repository ppa:juju/stable | |||
sudo apt update | |||
sudo apt install juju | |||
</nowiki> | |||
Otherwise, you can [https://jujucharms.com/docs/stable/reference-releases install the latest release] for CentOS, OS X, or Windows. | |||
Once Juju is installed, there are a few steps to prepare for writing your charm. | |||
<nowiki> | |||
mkdir -p ~/charms/layers | |||
export JUJU_REPOSITORY=~/charms | |||
export LAYER_PATH=$JUJU_REPOSITORY/layers | |||
cd $LAYER_PATH | |||
</nowiki> | |||
====Layers==== | ====Layers==== | ||
Create the layer for your proxy charm: | |||
<nowiki> | |||
charm create pingpong | |||
cd pingpong | |||
</nowiki> | |||
This will create a charm layer ready for customization: | |||
<nowiki> | |||
. | |||
├── config.yaml | |||
├── icon.svg | |||
├── layer.yaml | |||
├── metadata.yaml | |||
├── reactive | |||
│ └── pingpong.py | |||
├── README.ex | |||
└── tests | |||
├── 00-setup | |||
└── 10-deploy | |||
</nowiki> | |||
Next, modify ''layers.yaml'' to the following: | |||
<nowiki> | |||
includes: | |||
- layer:basic | |||
- layer:vnfproxy | |||
</nowiki> | |||
This means that your charm will include the basic layer, required for all charms, and the vnfproxy layer, which has been designed to aid in the development in proxy charms by implementing common functionality. | |||
====Actions==== | ====Actions==== | ||
There are three pieces that make up an action: ''actions.yaml'', which define an action, the ''actions/'' directory where we'll place a small script that invokes the reactive framework, and the python code in ''reactive/pingpong.py'' that performs said action. | |||
In ''actions.yaml'', we define the actions we wish to support: | |||
<nowiki> | |||
set-server: | |||
description: "Set the target IP address and port" | |||
params: | |||
server-ip: | |||
description: "IP on which the target service is listening." | |||
type: string | |||
default: "" | |||
server-port: | |||
description: "Port on which the target service is listening." | |||
type: integer | |||
default: 5555 | |||
required: | |||
- server-ip | |||
set-rate: | |||
description: "Set the rate of packet generation." | |||
params: | |||
rate: | |||
description: "Packet rate." | |||
type: integer | |||
default: 5 | |||
get-stats: | |||
description: "Get the stats." | |||
get-state: | |||
description: "Get the admin state of the target service." | |||
get-rate: | |||
description: "Get the rate set on the target service." | |||
get-server: | |||
description: "Get the target server and IP set" | |||
</nowiki> | |||
<nowiki> | |||
mkdir actions/ | |||
</nowiki> | |||
For each action, we need to create a script to invoke the | |||
<nowiki> | |||
</nowiki> | |||
====Building==== | ====Building==== |
Revision as of 01:26, 6 January 2017
Creating a VNF proxy charm
What is a charm
A charm is a collection of scripts and metadata that encapsulate the distilled DevOps knowledge of experts in a particular product. These charms make it easy to reliably and repeatedly deploy applications, then scale them as required with minimal effort.
Driven by Juju, these charms manage the complete lifecycle of the application, including installation, configuration, clustering, and scaling.
What is a proxy charm
OSM Release One supports a limited version of charms that we call "proxy charms". These charms is responsible for doing Day 1 configuration. Configurations are mapped to Juju Actions which manage configuration within the VNFD qcow2 image (over SSH, via RESTful API, etc).
The diagram below illustrates the OSM workflow:
+---------------------+ +---------------------+ | <----+ | | Resource | | Service | | Orchestrator (RO) +----> Orchestrator (SO) | | | | | +------------------+--+ +-------+----^--------+ | | | | | | | | | +-----v-----+ +-v----+--+ | <-------+ | | Virtual | | Proxy | | Machine | | Charm | | +-------> | +-----------+ +---------+
The SO directs the RO to create a virtual machine using the selected VNF image. When that has successfully completed, the SO will instantiate a LXD container, managed by Juju, with the proxy charm. The proxy charm will then communicate with the VNF virtual machine to do Day 1 configuration.
Creating a proxy charm
Setup
If you are running Ubuntu, you can install the latest Juju via its stable PPA:
sudo add-apt-repository ppa:juju/stable sudo apt update sudo apt install juju
Otherwise, you can install the latest release for CentOS, OS X, or Windows.
Once Juju is installed, there are a few steps to prepare for writing your charm.
mkdir -p ~/charms/layers export JUJU_REPOSITORY=~/charms export LAYER_PATH=$JUJU_REPOSITORY/layers cd $LAYER_PATH
Layers
Create the layer for your proxy charm:
charm create pingpong cd pingpong
This will create a charm layer ready for customization:
. ├── config.yaml ├── icon.svg ├── layer.yaml ├── metadata.yaml ├── reactive │ └── pingpong.py ├── README.ex └── tests ├── 00-setup └── 10-deploy
Next, modify layers.yaml to the following:
includes: - layer:basic - layer:vnfproxy
This means that your charm will include the basic layer, required for all charms, and the vnfproxy layer, which has been designed to aid in the development in proxy charms by implementing common functionality.
Actions
There are three pieces that make up an action: actions.yaml, which define an action, the actions/ directory where we'll place a small script that invokes the reactive framework, and the python code in reactive/pingpong.py that performs said action.
In actions.yaml, we define the actions we wish to support:
set-server: description: "Set the target IP address and port" params: server-ip: description: "IP on which the target service is listening." type: string default: "" server-port: description: "Port on which the target service is listening." type: integer default: 5555 required: - server-ip set-rate: description: "Set the rate of packet generation." params: rate: description: "Packet rate." type: integer default: 5 get-stats: description: "Get the stats." get-state: description: "Get the admin state of the target service." get-rate: description: "Get the rate set on the target service." get-server: description: "Get the target server and IP set"
mkdir actions/
For each action, we need to create a script to invoke the