Skip to content

Latest commit

 

History

History
419 lines (305 loc) · 9.81 KB

ContainersPlugin.md

File metadata and controls

419 lines (305 loc) · 9.81 KB

Containers Plugin

Version: 1.0

Status: ⚪⚪⚪

Containers plugin for Thunder framework.

Table of Contents

Introduction

Scope

This document describes purpose and functionality of the Containers plugin. It includes detailed specification about its configuration, methods and properties provided.

Case Sensitivity

All identifiers of the interfaces described in this document are case-sensitive. Thus, unless stated otherwise, all keywords, entities, properties, relations and actions should be treated as such.

Acronyms, Abbreviations and Terms

The table below provides and overview of acronyms used in this document and their definitions.

Acronym Description
API Application Programming Interface
HTTP Hypertext Transfer Protocol
JSON JavaScript Object Notation; a data interchange format
JSON-RPC A remote procedure call protocol encoded in JSON

The table below provides and overview of terms and abbreviations used in this document and their definitions.

Term Description
callsign The name given to an instance of a plugin. One plugin can be instantiated multiple times, but each instance the instance name, callsign, must be unique.

References

Ref ID Description
HTTP HTTP specification
JSON-RPC JSON-RPC 2.0 specification
JSON JSON specification
Thunder Thunder API Reference

Description

The Containers plugin provides informations about process containers running on system.

The plugin is designed to be loaded and executed within the Thunder framework. For more information about the framework refer to [Thunder].

Configuration

The table below lists configuration options of the plugin.

Name Type Description
callsign string Plugin instance name (default: Containers)
classname string Class name: Containers
locator string Library name: libWPEContainers.so
startmode string Determines if the plugin shall be started automatically along with the framework

Interfaces

This plugin implements the following interfaces:

Methods

The following methods are provided by the Containers plugin:

Containers interface methods:

Method Description
start Starts a new container
stop Stops a container

start method

Starts a new container.

Parameters

Name Type Description
params object
params?.name string (optional) Name of container
params?.command string (optional) Command that will be started in the container
params?.parameters array (optional) List of parameters supplied to command
params?.parameters[#] string (optional)

Result

Name Type Description
result null Always null

Errors

Code Message Description
2 ERROR_UNAVAILABLE Container not found
1 ERROR_GENERAL Failed to start container

Example

Request

{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "Containers.1.start",
  "params": {
    "name": "ContainerName",
    "command": "lsof",
    "parameters": [
      "-i"
    ]
  }
}

Response

{
  "jsonrpc": "2.0",
  "id": 42,
  "result": null
}

stop method

Stops a container.

Parameters

Name Type Description
params object
params.name string Name of container

Result

Name Type Description
result null Always null

Errors

Code Message Description
2 ERROR_UNAVAILABLE Container not found

Example

Request

{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "Containers.1.stop",
  "params": {
    "name": "ContainerName"
  }
}

Response

{
  "jsonrpc": "2.0",
  "id": 42,
  "result": null
}

Properties

The following properties are provided by the Containers plugin:

Containers interface properties:

Property Description
containers RO List of active containers
networks RO List of network interfaces of the container
memory RO Memory taken by container
cpu RO CPU time

containers property

Provides access to the list of active containers.

This property is read-only.

Value

Result

Name Type Description
result array List of names of all containers
result[#] string

Example

Get Request

{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "Containers.1.containers"
}

Get Response

{
  "jsonrpc": "2.0",
  "id": 42,
  "result": [
    "ContainerName"
  ]
}

networks property

Provides access to the list of network interfaces of the container.

This property is read-only.

Value

The name argument shall be passed as the index to the property, e.g. Containers.1.networks@ContainerName.

Result

Name Type Description
result array List of all network interfaces related to the container
result[#] object Returns networks associated with the container
result[#]?.interface string (optional) Interface name
result[#]?.ips array (optional) List of ip addresses
result[#]?.ips[#] string (optional) IP address

Errors

Code Message Description
2 ERROR_UNAVAILABLE Container not found

Example

Get Request

{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "Containers.1.networks@ContainerName"
}

Get Response

{
  "jsonrpc": "2.0",
  "id": 42,
  "result": [
    {
      "interface": "veth3NF06K",
      "ips": [
        "192.168.0.12"
      ]
    }
  ]
}

memory property

Provides access to the memory taken by container.

This property is read-only.

Value

The name argument shall be passed as the index to the property, e.g. Containers.1.memory@ContainerName.

Result

Name Type Description
result object Memory allocated by the container, in bytes
result?.allocated number (optional) Memory allocated by container
result?.resident number (optional) Resident memory of the container
result?.shared number (optional) Shared memory in the container

Errors

Code Message Description
2 ERROR_UNAVAILABLE Container not found

Example

Get Request

{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "Containers.1.memory@ContainerName"
}

Get Response

{
  "jsonrpc": "2.0",
  "id": 42,
  "result": {
    "allocated": 0,
    "resident": 0,
    "shared": 0
  }
}

Provides access to the CPU time.

This property is read-only.

Value

The name argument shall be passed as the index to the property, e.g. Containers.1.cpu@ContainerName.

Result

Name Type Description
result object CPU time spent on running the container, in nanoseconds
result?.total number (optional) CPU-time spent on container, in nanoseconds
result?.cores array (optional) Time spent on each cpu core, in nanoseconds
result?.cores[#] number (optional)

Errors

Code Message Description
2 ERROR_UNAVAILABLE Container not found

Example

Get Request

{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "Containers.1.cpu@ContainerName"
}

Get Response

{
  "jsonrpc": "2.0",
  "id": 42,
  "result": {
    "total": 2871287421,
    "cores": [
      2871287421
    ]
  }
}