Child pages
  • OpenVZ-daemon Message Specification
Skip to end of metadata
Go to start of metadata

The daemon responds to commands issued by the host machine sent to it over the internet encrypted. Certain tasks are performed on the machine running the daemon, and then information must be returned to the host machine. To do this, the JSON specification was chosen to encapsulate data being sent back and forth between the machines. To minimize any damage that can be done by malacious users, the daemon responds to a certain API written in JSON form. These specific forms are outlined below, with their effect on the machine running the daemon process, along with the content the machines return upon execution.

Request

A request has four name/value pairs as JSON, which are id, action, args, and kwargs.

{
    "id" : 100,
    "action" : "create",
    "args" : [1, 2, 3],
    "kwargs" : {
                   "alpha" : 1,
                   "bravo" : 2,
               }
}
  • The id is a unique positive integer. The response must contain the same id.
  • The action specifies the vzctl command to execute.
  • The args are the positional arguments passed to the action, usually the VEID.
  • The kwargs are the keyword arguments passed to the action.

For example, the usage for `vzctl create` is,

vzctl create <veid> [--ostemplate <name>] [--config <name>]
   [--private <path>] [--root <path>] [--ipadd <addr>] | [--hostname <name>]

To create a VE with VEID 100, the Django template, 10.0.0.1 as the ip address, and the hostname foo,

{
    "id" : 1,
    "action" : "create",
    "args" : [100],
    "kwargs" : {
                   "ostemplate" : "django",
                   "ipadd" : "10.0.0.1",
                   "hostname" : "foo"
               }
}

Response

The response is similar.

{
    "id" : 100,
    "code" : 0,
    "returned" : "anything you want"
}

The id is the same id as the request.
The code is always 0 for a successful execution of the command. A non-zero code indicates failure.
The response is an optional element for the return value(s) from the command.

NOTE: If the execution fails, returned is always an array of string representing the STDERR.

  • No labels