Introducing Murano plugins: Extending OpenStack catalog capabilities

Ekaterina Chernova - July 30, 2015 -

Murano, the Application Catalog for Openstack, is more than app storage. Murano enables the easy building of compound environments that include multiple interconnected applications. But what if you want your application to integrate with an external service directly? In previous versions of Murano, you would have had to modify the code directly. The introduction of Murano plugins has simplified the process. Let’s have a look at where Murano plugins can be useful, and how to use your own plugins.

Murano plugins can be used for:

  • Providing interaction with external services

    Suppose you want to interact with the OpenStack Glance service to get information about images suitable for deployment. A plugin may request image data from Glance during deployment, performing any necessary checks. (In the second half of this article, we’ll show you how to do that.)

  • Enabling connections between Murano applications and external hardware

    Suppose you have an external load balancer located on a powerful hardware, and you want your applications launched in OpenStack to use that load balancer. You can write a plugin that interacts with the load balancer API. Once you’ve done that, you can add new apps to the pool of your load balancer or make any other configurations from within your application definition.

  • Extending core-library class functionality, which is responsible for creating networks, interaction with murano-agent and so on

    Suppose you want to create networks with special parameters for all of your applications. You can just copy the class that is responsible for network management from the Murano core library, make the desired modification, and load the new class as a plugin. Both classes will be available, and it’s up to you to decide which way to create your networks.

  • Optimization of frequently used operations. (Plugin classes are written in Python, so opportunity for improvement is significant.)

    Depending on what you need to improve, Murano provides plenty of opportunities for optimization. For example, classes in the murano-core library, can be rewritten in C and used from python code to improved their performance in particular use cases.

Creating a Murano plugin

Let’s consider the use case of adding additional validation before using a chosen image to spawn an image as part of the application deployment process.. The plugin that implements this use case connects to the OpenStack Glance service using glanceclient.

The full code of the plugin is available at Murano repository adn https://github.com/openstack/murano/tree/master/contrib/plugins/murano_exampleplugin.

To implement this plugin, perform the following steps:

  1. Create a simple Python class for image validation, and use it to send http requests to the Glance API server.

           class GlanceClient(object):
def initialize(self, _context):
client_manager = helpers.get_environment(_context).clients
self.client = client_manager.get_client(_context, "glance", True,
self.create_glance_client)
def list(self):
images = self.client.images.list()
while True:
try:
image = images.next()
yield GlanceClient._format(image)
except StopIteration:
break

...
def getById(self, imageId):
image = self.client.images.get(imageId)
return GlanceClient._format(image)
@classmethod
def init_plugin(cls):
cls.CONF = cfg.init_config(config.CONF)
class AmbiguousNameException(Exception):
def __init__(self, name):
super(AmbiguousNameException, self).__init__("Image name '%s'"
" is ambiguous" % name)
  1. Create a setuptools-compliant python package with setup.py and all other nessesary files. It exports the created class as plugin entry-point at ‘io.murano.extensions’ namespace. This makes the plugin compatible with stevedore, a common way to dynamically load code in OpenStack.  (You can find more information about defining stevedore plugins in the stevedore documentation at https://wiki.openstack.org/wiki/Oslo#stevedore.)

  1. Install the created python package into the Murano environment by either executing its setup script or by using a package deployment tool such as pip. Make sure to restart the Murano engine after installation.

      $ user@host:~/murano_exampleplugin python setup.py install
  1. Zip and upload an app which uses this plugin to test it.

Murano app screen
$ user@host:~/murano_exampleplugin pushd example-app/io.murano.apps.demo.DemoApp; zip -r ../../murano-app.zip *; popd;
$ user@host:~/murano_exampleplugin murano package-import murano-app.zip

And that’s it.  In just 4 easy steps you have the limitless possibilities of improving, customizing and upgrading the application deployment process.

What kinds of deployment use-cases are you working on?  Please share in the comments; we really want to know how you’re using Murano, and we’ll be happy to provide advice on how to implement them!

banner-img
From Virtualization to Containerization
Learn how to move from monolithic to microservices in this free eBook
Download Now
Radio Cloud Native – Week of May 11th, 2022

Every Wednesday, Nick Chase and Eric Gregory from Mirantis go over the week’s cloud native and industry news. This week they discussed: Docker Extensions Artificial Intelligence shows signs that it's reaching the common person Google Cloud TPU VMs reach general availability Google buys MobileX, folds into Google Cloud NIST changes Palantir is back, and it's got a Blanket Purchase Agreement at the Department of Health and Human …

Radio Cloud Native – Week of May 11th, 2022
Where do Ubuntu 20.04, OpenSearch, Tungsten Fabric, and more all come together? In the latest Mirantis Container Cloud releases!

In the last several weeks we have released two updates to Mirantis Container Cloud - versions 2.16 and 2.17, which bring a number of important changes and enhancements. These are focused on both keeping key components up to date to provide the latest functionality and security fixes, and also delivering new functionalities for our customers to take advantage of in …

Where do Ubuntu 20.04, OpenSearch, Tungsten Fabric, and more all come together? In the latest Mirantis Container Cloud releases!
Monitoring Kubernetes costs using Kubecost and Mirantis Kubernetes Engine [Transcript]

Cloud environments & Kubernetes are becoming more and more expensive to operate and manage. In this demo-rich workshop, Mirantis and Kubecost demonstrate how to deploy Kubecost as a Helm chart on top of Mirantis Kubernetes Engine. Lens users will be able to visualize their Kubernetes spend directly in the Lens desktop application, allowing users to view spend and costs efficiently …

Monitoring Kubernetes costs using Kubecost and Mirantis Kubernetes Engine [Transcript]
Technical training
Learn Kubernetes & OpenStack from Deployment Experts
Prep for certification!
View schedule
LIVE WEBINAR
Getting started with Kubernetes part 2: Creating K8s objects with YAML

Thursday, December 30, 2021 at 10:00 AM PST
SAVE SEAT
Mirantis Webstore
Purchase Kubernetes support
SHOP NOW