How to create a Beiran Plugin

Before starting, please check our contribution guideline.

Creating a Plugin

Beiran’s modular architecture allows adding new capabilities, such as new package systems, different network discovery methods or new interfaces for k8s like cluster orchestration systems.

Till now, we have 3 kinds of plugins and implementations are followings:

  • package plugins (docker, apt, npm)
  • discovery plugins (dns, zeroconf)
  • interface plugins (k8s)

A plugin basically extends Beiran Daemon’s objects such as API endpoints, discovery classes, data models, cli commands, etc. Also Beiran library has some useful classes which are ready to use while developing a package plugin and other kinds of plugins as well.

A Beiran plugin is basically a python package which contains python modules such as:

  • (eg.
  • (eg.

Most of them are optional. contains the main object which is extended on base plugin classes. For example base class would be BasePackagePlugin, if it is a package plugin or BaseDiscoveryPlugin if it is a discovery plugin. is for data models and unless lack of extraordinary situation, its objects must be extended on base model class which can be easily imported on path beiran.models.base.BaseModel

The module includes http / ws endpoints which are appended to daemon’s main endpoint set. Beiran use Tornado to serve http / ws endpoints. So handlers and enpoint routes must be written how Tornado requires.

Plugin’s routes must be prefixed by suitable name to make them distinguishable. For example docker plugin’s routes have docker:

    (r'/docker/images', ImageList),
    (r'/docker/layers', LayerList),
    (r'/docker/images/(.*(?<!/info)$)', ImagesTarHandler),
    (r'/docker/images/(.*/info)', ImageInfoHandler),
    (r'/docker/layers/([0-9a-fsh:]+)', LayerDownload),

Beiran have also some base handlers which are ready to use and allow developers to handle easily many cases, such as RPCEndpoint, JSONEndpoint.

The module is for command line interface methods. This module’s methods (commands and sub-commands) are appended as a sub-command named plugin_name to main command beiran, such as:

$ beiran plugin_name sub-command
$ beiran plugin_name sub-command sub-command

The cli module must have an empty method called cli for auto discovery and import purposes. For example docker plugin cli modlue has method below:"docker", short_help="docker subcommands")
def cli():
    """Main subcommand method."""

Other modules are arbitrary and depends on how your implementation is structured.