deb-murano/contrib/plugins/murano_exampleplugin/example-app/io.murano.apps.demo.DemoApp/Classes/ImageValidatorMixin.yaml
Alexander Tivelkov 62c1f10e7b Initial implementation of Plugable Classes
Adds a PluginLoader which loads classes defined as stevedore plugins at
io.murano.extension namespace and registers them as MuranoPL classes in
class loader.

Modifies the ClientManager class to make the _get_client method public,
so other code may use it to add custom clients. This is useful for
plugins which may define their own clients.

Modifies the configuration settings adding 'enabled_plugins' parameter to
control which of the installed plugins are active.

Adds an example plugin which encapsulates Glance interaction logic to:
	* List all available glance images
	* Get Image by ID
	* Get Image by Name
	* Output image info with murano-related metadata

Adds a demo application which demonstrates the usage of plugin. The app
consist of the following components:
	* An 'ImageValidatorMixin' class which inherits generic instance
	  class (io.murano.resources.Instance) and adds a method capable to
	  validate Instance's image for having appropriate murano metadata
	  type. This class may be used as a mixin when added to inheritance
	  hierarchy of concrete instance classes.
	* A concrete class called DemoInstance which inherits from
	  io.murano.resources.LinuxMuranoInstance and ImageValidatorMixin
	  to add the image validation logic to standard Murano-enabled
	  Linux-based instance.
	* An application which deploys a single VM using the DemoInstance
	  class if the tag on user-supplied image matches the user-supplied
	  constant.

The ImageValidatorMixin demonstrates the instantiation of
plugin-provided class and its usage, as well as handling of exception
which may be thrown if the plugin is not installed in the environment.

Change-Id: I978339d87033bbe38dad4c2102612d8f3a1eb3c3
Implements-blueprint: plugable-classes
2015-03-19 14:06:24 +00:00

37 lines
1.0 KiB
YAML

Namespaces:
=: io.murano.apps.example.plugin
res: io.murano.resources
Name: ImageValidatorMixin
Extends:
- res:Instance
Properties:
requiredType:
Contract: $.string().notNull()
Workflow:
validateImage:
Body:
- Try:
- $glance: new('io.murano.extensions.mirantis.example.Glance')
Catch:
With: 'murano.dsl.exceptions.NoPackageForClassFound'
Do:
Throw: PluginNotFoundException
Message: 'Plugin for interaction with Glance is not installed'
- $glanceImage: $glance.getById($.image)
- If: $glanceImage = null
Then:
Throw: ImageNotFoundException
Message: 'Image with specified Id was not found'
- If: $glanceImage.meta = null
Then:
Throw: InvalidImageException
Message: 'Image does not contain Murano metadata tag'
- If: $glanceImage.meta.type != $.requiredType
Then:
Throw: InvalidImageException
Message: 'Image has unappropriate Murano type'