Resource

GET /api/v1/container/(string: container_type)/(string: container_id)/all
Parameters:
  • container_typelxc, docker
  • container_id – container id

resource list

Example request

$ curl -sq -XGET -b cookies.txt \
    http://${QIP}:${QPORT}/api/v1/container/lxc/utest/all

Example response

{
    "arch": "amd64",
    "autostart": false,
    "image": "ubuntu-trusty",
    "name": "utest",
    "network": {
        "hostname": "utest",
        "port": []
    },
    "resource": {
        "device": [],
        "limit": {}
    },
    "type": "lxc",
    "volume": {
        "host": {}
    }
}

Auto start

PUT /api/v1/container/(string: container_type)/(string: container_id)/autostart/(string: state)

Update container auto start setting.

Parameters:
  • container_typelxc, docker
  • container_id – container id
  • stateon, off

Example request

$ curl -sq -XPUT -b cookies.txt \
    http://${QIP}:${QPORT}/api/v1/container/lxc/utest/autostart/on
$ curl -sq -XPUT -b cookies.txt \
    http://${QIP}:${QPORT}/api/v1/container/lxc/utest/autostart/off

Example response

{
    "arch": "amd64",
    "autostart": true,
    "image": "ubuntu-trusty",
    "name": "utest",
    "network": {
        "hostname": "utest",
        "port": []
    },
    "resource": {
        "device": [],
        "limit": {}
    },
    "type": "lxc",
    "volume": {
        "host": {}
    }
}
{
    "arch": "amd64",
    "autostart": false,
    "image": "ubuntu-trusty",
    "name": "utest",
    "network": {
        "hostname": "utest",
        "port": []
    },
    "resource": {
        "device": [],
        "limit": {}
    },
    "type": "lxc",
    "volume": {
        "host": {}
    }
}

Port Forwarding

POST /api/v1/container/(string: container_type)/(string: container_id)/network/port

Add port forwarding.

Parameters:
  • container_typelxc, docker
  • container_id – container id

Example request

$ curl -sq -XPOST -b cookies.txt -d '[12345, 12345, "tcp"]' \
    http://${QIP}:${QPORT}/api/v1/container/lxc/utest/network/port

Example response

{
    "arch": "amd64",
    "autostart": false,
    "image": "ubuntu-trusty",
    "name": "utest",
    "network": {
        "hostname": "utest",
        "port": [
            [
                12345,
                12345,
                "tcp"
            ]
        ]
    },
    "resource": {
        "device": [],
        "limit": {}
    },
    "type": "lxc",
    "volume": {
        "host": {}
    }
}
DELETE /api/v1/container/(string: container_type)/(string: container_id)/network/port

Delete port forwarding.

Parameters:
  • container_typelxc, docker
  • container_id – container id

Example request

$ curl -sq -XDELETE -b cookies.txt -d '[12345, 12345, "tcp"]' \
    http://${QIP}:${QPORT}/api/v1/container/lxc/utest/network/port

Example response

[]

Devices

GET /api/v1/resource/device

Get available device list. The device allows access inside container.

Example request

$ curl -sq -XGET http://${QIP}:${QPORT}/api/v1/resource/device

Example response

[
    "Direct_Render_Infrastructure_(226)",
    "Input_(13)",
    "video4linux_(81)",
    "Sound_and_ALSA_(14,_116)",
    "TTY_(4)"
]
POST /api/v1/container/(string: container_type)/(string: container_id)/resource/device

Add device permission.

Parameters:
  • container_typelxc, docker
  • container_id – container id
Access is a sequence of one or more of the following letters:
 

r — allows tasks to read from the specified device

w — allows tasks to write to the specified device

m — allows tasks to create device files that do not yet exist

Example request

$ curl -sq -XPOST -b cookies.txt -d '["allow", "Input_(13)", "rwm"]' \
    http://${QIP}:${QPORT}/api/v1/container/lxc/utest/resource/device

Example response

{
    "arch": "amd64",
    "autostart": false,
    "image": "ubuntu-trusty",
    "name": "utest",
    "network": {
        "hostname": "utest",
        "port": []
    },
    "resource": {
        "device": [
            [
                "allow",
                "Input_(13)",
                "rwm"
            ]
        ],
        "limit": {}
    },
    "type": "lxc",
    "volume": {
        "host": {}
    }
}
DELETE /api/v1/container/(string: container_type)/(string: container_id)/resource/device

Delete device permission.

Parameters:
  • container_typelxc, docker
  • container_id – container id

Example request

$ curl -sq -XDELETE -b cookies.txt -d '["allow", "Input_(13)", "rwm"]' \
    http://${QIP}:${QPORT}/api/v1/container/lxc/utest/resource/device

Example response

[]

Limit

POST /api/v1/container/(string: container_type)/(string: container_id)/resource/limit

Add resource limitation.

Parameters:
  • container_typelxc, docker
  • container_id – container id
Request JSON Object:
 
  • cputime (int) – (optional) [10-999]. cpu usage time in milliseconds(ms)
  • cpuweight (int) – (optional) [2-1024]. relative cpu usage
  • memory (string) – (optional) Unit in MB. Must higher than 64m

Example request

$ curl -sq -XPOST -b cookies.txt -d '{"cputime": 100, "cpuweight": 600, "memory": "512m"}' \
    http://${QIP}:${QPORT}/api/v1/container/lxc/utest/resource/limit

Example response

{
    "arch": "amd64",
    "autostart": false,
    "image": "ubuntu-trusty",
    "name": "utest",
    "network": {
        "hostname": "utest",
        "port": []
    },
    "resource": {
        "device": [],
        "limit": {
            "cputime": 100,
            "cpuweight": 600,
            "memory": "512m"
        }
    },
    "type": "lxc",
    "volume": {
        "host": {}
    }
}
DELETE /api/v1/container/(string: container_type)/(string: container_id)/resource/limit

Delete resource limitation.

Parameters:
  • container_typelxc, docker
  • container_id – container id

Example request

$ curl -sq -XDELETE -b cookies.txt -d '{"cputime": 0}' \
    http://${QIP}:${QPORT}/api/v1/container/lxc/utest/resource/limit

Example response

[]