Version: 1.0
Status: ⚪⚪⚪
Containers plugin for Thunder framework.
This document describes purpose and functionality of the Containers plugin. It includes detailed specification about its configuration, methods and properties provided.
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.
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. |
Ref ID | Description |
---|---|
HTTP | HTTP specification |
JSON-RPC | JSON-RPC 2.0 specification |
JSON | JSON specification |
Thunder | Thunder API Reference |
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].
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 |
This plugin implements the following interfaces:
- Containers.json (version 1.0.0) (compliant format)
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.
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) |
Name | Type | Description |
---|---|---|
result | null | Always null |
Code | Message | Description |
---|---|---|
2 | ERROR_UNAVAILABLE |
Container not found |
1 | ERROR_GENERAL |
Failed to start container |
{
"jsonrpc": "2.0",
"id": 42,
"method": "Containers.1.start",
"params": {
"name": "ContainerName",
"command": "lsof",
"parameters": [
"-i"
]
}
}
{
"jsonrpc": "2.0",
"id": 42,
"result": null
}
stop method
Stops a container.
Name | Type | Description |
---|---|---|
params | object | |
params.name | string | Name of container |
Name | Type | Description |
---|---|---|
result | null | Always null |
Code | Message | Description |
---|---|---|
2 | ERROR_UNAVAILABLE |
Container not found |
{
"jsonrpc": "2.0",
"id": 42,
"method": "Containers.1.stop",
"params": {
"name": "ContainerName"
}
}
{
"jsonrpc": "2.0",
"id": 42,
"result": null
}
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.
Name | Type | Description |
---|---|---|
result | array | List of names of all containers |
result[#] | string |
{
"jsonrpc": "2.0",
"id": 42,
"method": "Containers.1.containers"
}
{
"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.
The name argument shall be passed as the index to the property, e.g. Containers.1.networks@ContainerName.
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 |
Code | Message | Description |
---|---|---|
2 | ERROR_UNAVAILABLE |
Container not found |
{
"jsonrpc": "2.0",
"id": 42,
"method": "Containers.1.networks@ContainerName"
}
{
"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.
The name argument shall be passed as the index to the property, e.g. Containers.1.memory@ContainerName.
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 |
Code | Message | Description |
---|---|---|
2 | ERROR_UNAVAILABLE |
Container not found |
{
"jsonrpc": "2.0",
"id": 42,
"method": "Containers.1.memory@ContainerName"
}
{
"jsonrpc": "2.0",
"id": 42,
"result": {
"allocated": 0,
"resident": 0,
"shared": 0
}
}
cpu property
Provides access to the CPU time.
This property is read-only.
The name argument shall be passed as the index to the property, e.g. Containers.1.cpu@ContainerName.
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) |
Code | Message | Description |
---|---|---|
2 | ERROR_UNAVAILABLE |
Container not found |
{
"jsonrpc": "2.0",
"id": 42,
"method": "Containers.1.cpu@ContainerName"
}
{
"jsonrpc": "2.0",
"id": 42,
"result": {
"total": 2871287421,
"cores": [
2871287421
]
}
}