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 | M/O | Description |
|---|---|---|---|
| callsign | string | mandatory | Plugin instance name (default: Containers) |
| classname | string | mandatory | Class name: Containers |
| locator | string | mandatory | Library name: libWPEContainers.so |
| startmode | string | mandatory | Determines in which state the plugin should be moved to at startup of 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:
Built-in methods:
| Method | Description |
|---|---|
| versions | Retrieves a list of JSON-RPC interfaces offered by this service |
| exists | Checks if a JSON-RPC method or property exists |
Containers interface methods:
| Method | Description |
|---|---|
| start | Starts a new container |
| stop | Stops a container |
versions method
Retrieves a list of JSON-RPC interfaces offered by this service.
This method takes no parameters.
| Name | Type | M/O | Description |
|---|---|---|---|
| result | array | mandatory | A list ofsinterfaces with their version numbers Array length must be at most 255 elements. |
| result[#] | object | mandatory | ... |
| result[#].name | string | mandatory | Name of the interface |
| result[#].major | integer | mandatory | Major part of version number |
| result[#].minor | integer | mandatory | Minor part of version number |
| result[#].patch | integer | mandatory | Patch part of version version number |
{
"jsonrpc": "2.0",
"id": 42,
"method": "Containers.1.versions"
}{
"jsonrpc": "2.0",
"id": 42,
"result": [
{
"name": "JMyInterface",
"major": 1,
"minor": 0,
"patch": 0
}
]
}exists method
Checks if a JSON-RPC method or property exists.
This method will return True for the following methods/properties: containers, networks, memory, cpu, versions, exists, start, stop.
| Name | Type | M/O | Description |
|---|---|---|---|
| params | object | mandatory | ... |
| params.method | string | mandatory | Name of the method or property to look up |
| Name | Type | M/O | Description |
|---|---|---|---|
| result | boolean | mandatory | Denotes if the method exists or not |
{
"jsonrpc": "2.0",
"id": 42,
"method": "Containers.1.exists",
"params": {
"method": "containers"
}
}{
"jsonrpc": "2.0",
"id": 42,
"result": false
}start method
Starts a new container.
| Name | Type | M/O | Description |
|---|---|---|---|
| params | object | mandatory | ... |
| 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 | mandatory | ... |
| Name | Type | M/O | Description |
|---|---|---|---|
| result | null | mandatory | Always null (default: None) |
| Message | Description |
|---|---|
ERROR_UNAVAILABLE |
Container not found |
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 | M/O | Description |
|---|---|---|---|
| params | object | mandatory | ... |
| params.name | string | mandatory | Name of container |
| Name | Type | M/O | Description |
|---|---|---|---|
| result | null | mandatory | Always null (default: None) |
| Message | Description |
|---|---|
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 | R/W | Description |
|---|---|---|
| containers | read-only | List of active containers |
| networks | read-only | List of network interfaces of the container |
| memory | read-only | Memory taken by container |
| cpu | read-only | CPU time |
containers property
Provides access to the list of active containers.
This property is read-only.
| Name | Type | M/O | Description |
|---|---|---|---|
| (property) | array | mandatory | List of names of all containers |
| (property)[#] | string | mandatory | ... |
{
"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 parameter shall be passed as the index to the property, i.e.
networks@<name>.
| Name | Type | M/O | Description |
|---|---|---|---|
| name | string | mandatory | ... |
| Name | Type | M/O | Description |
|---|---|---|---|
| (property) | array | mandatory | List of all network interfaces related to the container |
| (property)[#] | object | mandatory | Returns networks associated with the container |
| (property)[#]?.interface | string | optional | Interface name |
| (property)[#]?.ips | array | optional | List of ip addresses |
| (property)[#]?.ips[#] | string | mandatory | IP address |
| Message | Description |
|---|---|
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 parameter shall be passed as the index to the property, i.e.
memory@<name>.
| Name | Type | M/O | Description |
|---|---|---|---|
| name | string | mandatory | ... |
| Name | Type | M/O | Description |
|---|---|---|---|
| (property) | object | mandatory | Memory allocated by the container, in bytes |
| (property)?.allocated | integer | optional | Memory allocated by container |
| (property)?.resident | integer | optional | Resident memory of the container |
| (property)?.shared | integer | optional | Shared memory in the container |
| Message | Description |
|---|---|
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 parameter shall be passed as the index to the property, i.e.
cpu@<name>.
| Name | Type | M/O | Description |
|---|---|---|---|
| name | string | mandatory | ... |
| Name | Type | M/O | Description |
|---|---|---|---|
| (property) | object | mandatory | CPU time spent on running the container, in nanoseconds |
| (property)?.total | integer | optional | CPU-time spent on container, in nanoseconds |
| (property)?.cores | array | optional | Time spent on each cpu core, in nanoseconds |
| (property)?.cores[#] | integer | mandatory | ... |
| Message | Description |
|---|---|
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
]
}
}