Skip to content
Python HTML Other
Branch: master
Clone or download

Latest commit

baljanak Merge pull request #32 from nutanixdev/topic/fix_cache_entity_request…
…_length

Topic/fix cache entity request length
Latest commit 4e50e2b Apr 8, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows Delete build_tests.yml Apr 1, 2020
calm/dsl Merge pull request #32 from nutanixdev/topic/fix_cache_entity_request… Apr 8, 2020
docs Tweaked docs verbiage Feb 3, 2020
examples format script in examples using black Apr 6, 2020
tests Removing unnecessary context from various entity commands Mar 10, 2020
venv add venv folder Jan 28, 2019
.coveragerc Move RenderJSON to another file, omit from coverage Feb 22, 2019
.gitignore Add DB location as a config param Dec 26, 2019
Dockerfile Install packages in user-site while building docker image Feb 21, 2020
LICENSE Add Apache 2.0 License Dec 21, 2019
MANIFEST.in add missing init template to manifest Mar 19, 2020
Makefile makefile changes Feb 25, 2020
README.md Add link to latest blog on generating vm specs Apr 7, 2020
_config.yml Set theme jekyll-theme-cayman Feb 21, 2020
dev-requirements.txt fixes #31 Set maximum pytest version to 5.3.5 Apr 8, 2020
gui-requirements.txt Fix `make gui` and `make docker` Nov 8, 2019
pytest.ini add markers for slow running tests Jul 1, 2019
requirements.txt Add cli to format blueprint using black Mar 25, 2020
setup.cfg W503 is not PEP8 compliant Apr 22, 2019
setup.py update github link in setup.py Jan 23, 2020

README.md

Code style: black

Build

calm-dsl

About Calm DSL

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.

Why Python3 as DSL ?

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.

Getting Started

  • 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 see calm set config --help for details to update config.
  • First blueprint: calm init bp. This will create a folder HelloBlueprint 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 like calm get bps --name <blueprint_name> and so on. Please look at calm 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 {}.

Dev Setup

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 calling source venv/bin/activate. Use deactivate to deactivate virtualenv.
  • make test to run quick tests. make test-all to run all tests.
  • make dist to generate a calm.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

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.

Video Links

Blogs

You can’t perform that action at this time.