Plugins

Discovery

Zeroconf

Zeroconf multicast discovery service implementation

class beiran_discovery_zeroconf.zeroconf.ZeroconfDiscovery(config: dict)[source]

Bases: beiran.plugin.BaseDiscoveryPlugin

Beiran Implementation of Zeroconf Multicast DNS Service Discovery

DEFAULTS = {'domain': '_beiran._tcp.local.'}
Creates an instance of Zeroconf Discovery Service
advertise_name

Return concatenated string as advertise name

Initialization of discovery service with all information and starts service browser

Get already registered services on zeroconf :returns: List of services :rtype: tuple

Registering own service to zeroconf

Starts discovery service

Start browsing changes on discovery

Unregister service and close zeroconf

class beiran_discovery_zeroconf.zeroconf.ZeroconfListener(discovery: beiran_discovery_zeroconf.zeroconf.ZeroconfDiscovery)[source]

Bases: object

Listener instance for zeroconf discovery to monitor changes

Initialize self. See help(type(self)) for accurate signature.

Service added change receives

Service Info for newly added node :param zeroconf: Zeroconf instance :param typeos: Type of the service :param name: Name of the service

Service removed change receives

Service Info for removed node :param zeroconf: Zeroconf instance :param typeos: Type of the service :param name: Name of the service

DNS

Zeroconf multicast discovery service implementation

class beiran_discovery_dns.dns.DNSDiscovery(config: dict)[source]

Bases: beiran.plugin.BaseDiscoveryPlugin

Beiran Implementation of DNS Service Discovery

DEFAULTS = {'discovery_service_address': 'beirand', 'domain': '_beiran._tcp.local.'}

Creates an instance of Dns Discovery Service

Browsing other nodes of beirand

Query address to discover other beiran daemons :returns: hostname to query :rtype: str

Dns query coroutine :param name: address to look for :param query_type: dns type

Returns: List of dns records

Starts discovery service

Package

Docker

Docker packaging plugin

class beiran_package_docker.plugin_docker.DockerPackaging(config: dict)[source]

Bases: beiran.plugin.BasePackagePlugin

Docker support for Beiran

DEFAULTS = {'storage': '/var/lib/docker'}

Daemon error emitter. :param error: error message :type error: str

Daemon lost emitter.

Unset available image, delete it if no node remains

param image_id:image identifier
type image_id:str

Unset available layer, delete it if no image refers it

placeholder method for existing_image_deleted event

fetch image list from the node and update local db

fetch layer list from the node and update local db

Init plugin

Subscribes aiodocker events channel and logs them. If docker daemon is unavailable calls deamon_lost method to emit the lost event.

placeholder method for new_image_saved event

Deal with local docker daemon states

Save existing image and layers identified by id_or_tag to database.

param id_or_tag:
 image identifier (hash_id or tag)
type id_or_tag:str

Save an image from a node into db

Save a layer from a node into db

Update ‘cache_path’ and ‘cache_gz_path’ and ‘docker_path’ with paths of local node

Set dynamic configuration value like using run_dir

Start plugin

Stop plugin

Sync with another peer node object is accessible at peer.node

Tag an image existing in database. If already same tag exists, move it from old one to new one.

Unset image_id from local_image_refs of layers

Remove a tag from an image.

Docker API endpoints

class beiran_package_docker.api.ImageConfigHandler(application, request, **kwargs)[source]

Bases: tornado.web.RequestHandler

Image config handler (for testing)

Implement this method to handle streamed request data.

Requires the .stream_request_body decorator.

Create or download config (this endpoint for test)

class beiran_package_docker.api.ImageInfoHandler(application, request, **kwargs)[source]

Bases: tornado.web.RequestHandler

Image info handler

Implement this method to handle streamed request data.

Requires the .stream_request_body decorator.

Get image information

class beiran_package_docker.api.ImageList(application: tornado.web.Application, request: tornado.httputil.HTTPServerRequest, **kwargs)[source]

Bases: beiran.cmd_req_handler.RPCEndpoint

List images

Initialize self. See help(type(self)) for accurate signature.

Implement this method to handle streamed request data.

Requires the .stream_request_body decorator.

Return list of docker images.

returns:list of images, it is a dict, since tornado does not write list for security reasons; see: http://www.tornadoweb.org/en/stable/web.html#tornado.web.RequestHandler.write
rtype:(dict)
public_methods = ['pull']

Pulling image in cluster

Coroutine to pull image in cluster

Coroutine to pull image (download distributed layers)

class beiran_package_docker.api.ImagesHandler(application, request, **kwargs)[source]

Bases: tornado.web.RequestHandler

Endpoint to list docker images

Initialize self. See help(type(self)) for accurate signature.

Implement this method to handle streamed request data.

Requires the .stream_request_body decorator.

Loads tarball to docker

Called at the beginning of a request before get/post/etc.

Override this method to perform common initialization regardless of the request method.

Asynchronous support: Decorate this method with .gen.coroutine or .return_future to make it asynchronous (the asynchronous decorator cannot be used on prepare). If this method returns a .Future execution will not proceed until the .Future is done.

New in version 3.1: Asynchronous support.

class beiran_package_docker.api.ImagesTarHandler(application, request, **kwargs)[source]

Bases: tornado.web.RequestHandler

Images export handler

Implement this method to handle streamed request data.

Requires the .stream_request_body decorator.

Get image as a tarball

HEAD endpoint

class beiran_package_docker.api.LayerDownload(application, request, **kwargs)[source]

Bases: tornado.web.RequestHandler

Container image layer downloading handler

Implement this method to handle streamed request data.

Requires the .stream_request_body decorator.

Get layer info by given layer_id

Head response with actual Content-Lenght of layer

Finds docker layer path and prepare a tar archive for layer_id.

param layer_id:uuid str of layer
type layer_id:str
returns:(str) tar path
raises 404 if layer not found:
 
class beiran_package_docker.api.LayerList(application, request, **kwargs)[source]

Bases: tornado.web.RequestHandler

List images

Implement this method to handle streamed request data.

Requires the .stream_request_body decorator.

Return list of docker layers.

returns:list of layers, it is a dict, since tornado does not write list for security reasons; see: http://www.tornadoweb.org/en/stable/web.html#tornado.web.RequestHandler.write
rtype:(dict)
class beiran_package_docker.api.Services[source]

Bases: object

These needs to be injected from the plugin init code

aiodocker = None
daemon = None
docker_util = None
local_node = None
logger = None
loop = None

Interface

Kubernetes

k8s interface plugin

class beiran_interface_k8s.k8s.K8SInterface(plugin_config: dict)[source]

Bases: beiran.plugin.BaseInterfacePlugin

CRI v1alpha2 support for Beiran

DEFAULTS = {}

Initialization of plugin class with async loop

Init plugin

Set dynamic configuration value like using run_dir

Start gRPC server

Stop gRPC server