Calm DSL describes a simpler Python3 based DSL for writing Calm blueprints. As Calm uses Services, Packages, Substrates, Deployments and Application Profiles as building blocks for a Blueprint, these entities can be defined as python classes. Their attributes can be specified as class attributes and actions on those entities (procedural runbooks) can be defined neatly as class methods. Calm blueprint DSL can also accept appropriate native data formats such as YAML and JSON, allowing the reuse and leveraging that work into the larger application lifecycle context of a Calm blueprint.
Language design is black art, and building upon a well-established language is design-wise a big win. The language has also solved many issues like scoping, modules, if-else, inheritance, etc. Well established languages have great tooling support: IDEs, syntax checkers, third-party modules, coding practices, better readability, editing, syntax highlighting, code completion, versioning, collaboration, etc. They see much more community improvements as well. Python specifically comes with a very good REPL (read–eval–print-loop). Having an interactive prompt to play around and slowly build objects is an order-of-magnitude improvement in developer productivity. Python is very easy language to learn and use; and most of the ITOps/DevOps community already use Python for scripting.
- Setup:
calm init dsl
. Please fill in the right values. - Server status:
calm get server status
. - Config:
calm show config
. Check if you have the right config. By default, config is stored at~/.calm/config.ini
. Please seecalm set config --help
for details to update config. - First blueprint:
calm init bp
. This will create a folderHelloBlueprint
with all the necessary files.HelloBlueprint/blueprint.py
is the main blueprint DSL file. Please read the comments in the beginning of the file for more details about the blueprint. - Compile blueprint:
calm compile bp --file HelloBlueprint/blueprint.py
. This command will print the compiled blueprint JSON. - Create blueprint on Calm Server:
calm create bp --file HelloBlueprint/blueprint.py --name <blueprint_name>
. Please use a unique name for<blueprint_name>
. - List blueprints:
calm get bps
. You can also pass in filters likecalm get bps --name <blueprint_name>
and so on. Please look atcalm get bps --help
. - Describe blueprint:
calm describe bp <blueprint_name>
. It will print a summary of the blueprint. - Launch blueprint to create Application:
calm launch bp <blueprint_name> --app_name <app_name> -i
- List apps:
calm get apps
. - Describe app:
calm describe app <app_name>
. It will print a summary of the application and the current application state. - Delete app:
calm delete app <app_name>
. Hint: You can delete multiple apps using:calm get apps -q | xargs -I {} calm delete app {}
.
MacOS:
- Install Xcode
- Install homebrew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
. - Install python3, git and openssl:
brew install git python3 openssl
. - Add path to flags:
export LDFLAGS="-L$(brew --prefix openssl)/lib"
&export CFLAGS="-I$(brew --prefix openssl)/include"
. - Clone this repo and run:
make dev
from top directory. - Getting into virtualenv:
source venv/bin/activate
. - Getting out of virtualenv:
deactivate
.
Centos:
make _init_centos
to setup your CentOS 7 VM for development. This will install python3 and docker.
Use:
make dev
to create/use python3 virtualenv in$TOPDIR/venv
and setup dev environment. Activate it by callingsource venv/bin/activate
. Usedeactivate
to deactivate virtualenv.make test
to run quick tests.make test-all
to run all tests.make dist
to generate acalm.dsl
python distribution.make docker
to build docker container. (Assumes docker client is setup on your machine)make run
to run container.make clean
to reset.
Documentation for the Calm DSL will be stored in the docs folder, and will continually be added to. If you're not familiar with Calm Terminology basics, please review the Calm Terminology doc page.