Nutanix Calm DSL – Quick Tips

Nutanix Calm DSL - Quick Tips

Table of Contents

By now many will be aware of how powerful the simplest things can be. Things like working with Nutanix Calm, which can be controlled via multiple mechanisms, are now simpler than ever.

Along the way, though, it’s easy to forget just how simple some of those things can be. Today’s quick article shines a light on three of those things, hopefully being the catalyst for an a-ha moment that hasn’t occurred until now.

Container “Quick Start”

Did you know the Nutanix Calm DSL is available as both a Docker container you can build yourself and as a published container on Docker Hub? If you have Docker installed and have access to Docker Hub, firing up a Nutanix Calm DSL container is as simple as this:

docker run -it ntnx/calm-dsl
Quickly launching the Nutanix Calm DSL container from Docker Hub

Project Switching

The Calm DSL carries out all operations by working with a Calm/Prism Central project. If an environment has multiple projects configured (a common situation) it may be a requirement to quickly switch from one project to another. Here’s the command to do that.

calm set config --project [project_name]
Example of configuring the Calm DSL and quickly switching to a different project

Specify Project within Blueprint

This is an option that hasn’t been discussed on Nutanix.dev, yet. Sure, projects can be quickly switched using “calm set config” as outlined above, but a blueprint’s project can also be defined within the blueprint itself. Take a quick look at the code snippet below.

from calm.dsl.builtins import Metadata

class BpMetadata(Metadata):
    project = Ref.Project("my_cool_project")

This is obviously not a complete blueprint, but demonstrates a couple of requirements.

  • The required modules are being imported as the first step
  • An instance of the Metadata class has been instantiated and named BpMetadata

When the BpMetadata instance is created, the Calm DSL will automatically detect the instance and use it as the “destination” project for the blueprint. Clever! One of the Calm DSL tests that uses this approach can be found here.

Bonus tips

Don’t forget the docs

The Calm DSL GitHub repo has a section entitled Examples, with a sample project flow for admin users. If you are new to the Calm DSL this example flow will demonstrate the use of Calm projects, user accounts, groups and access control policies with a view to scripting the beginnings of an entire environment. Make sure you check it out!

Delete all Blueprints – Use with caution!

While this tip isn’t specific to the Calm DSL, it shows how the Calm DSL can pipe its output to standard CLI commands. Use extreme caution with this one!

calm get bps -q | xargs -I{} calm delete bp {}

When used in a test environment, for example, commands like this clean up all blueprints so that a developer or automation engineer can “start from scratch”.

Now what?

Even though these quick tips are about as simple as things can get, there are many other Calm DSL resources available to you.

Thanks for reading and have a great day! 🙂

© 2024 Nutanix, Inc. All rights reserved. Nutanix, the Nutanix logo and all Nutanix product, feature and service names mentioned herein are registered trademarks or trademarks of Nutanix, Inc. in the United States and other countries. Other brand names mentioned herein are for identification purposes only and may be the trademarks of their respective holder(s). This post may contain links to external websites that are not part of Nutanix.com. Nutanix does not control these sites and disclaims all responsibility for the content or accuracy of any external site. Our decision to link to an external site should not be considered an endorsement of any content on such a site. Certain information contained in this post may relate to or be based on studies, publications, surveys and other data obtained from third-party sources and our own internal estimates and research. While we believe these third-party studies, publications, surveys and other data are reliable as of the date of this post, they have not independently verified, and we make no representation as to the adequacy, fairness, accuracy, or completeness of any information obtained from third-party sources.