Resource

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

resource list

Example request

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

Example response

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

Auto start

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

Update container auto start setting.

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

Example request

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

Example response

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

Port Forwarding

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

Add port forwarding.

Parameters:
  • container_typelxc, lxd, docker
  • container_id – container id

Example request

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

Example response

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

Delete port forwarding.

Parameters:
  • container_typelxc, lxd, docker
  • container_id – container id

Example request

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

Example response

[]
POST /api/v1/container/(string: container_type)/(string: container_id)/network/ports

Edit port forwarding settings.

Parameters:
  • container_typelxc, lxd
  • container_id – container id

Example request

$ curl -sq -XPOST -b cookies.txt -d \
    '[[111, 222, "udp"], [333, 444, "tcp"]]' \
    http://${QIP}:${QPORT}/container-station/api/v1/container/lxc/utest/network/ports

Example response

{
    "arch": "amd64",
    "autostart": false,
    "image": "ubuntu-bionic",
    "name": "utest",
    "network": {
        "hostname": "utest",
        "mode": "",
        "port": [
            [
                111,
                222,
                "udp"
            ],
            [
                333,
                444,
                "tcp"
            ]
        ]
    },
    "resource": {
        "device": [],
        "limit": {}
    },
    "type": "lxc",
    "version": "latest",
    "volume": {
        "container": [],
        "host": {}
    }
}

Example request: remove all settings

$ curl -sq -XPOST -b cookies.txt -d '[]' \
    http://${QIP}:${QPORT}/container-station/api/v1/container/lxc/utest/network/ports

Example response: remove all settings

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

Devices

GET /api/v1/resource/device

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

Example request

$ curl -sq -XGET -b cookies.txt http://${QIP}:${QPORT}/container-station/api/v1/resource/device

Example response

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

Add device permission with the specified device.

Parameters:
  • container_typelxc, lxd, 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 [required]

Example request

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

Example response

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

Delete device permission with the specified device.

Parameters:
  • container_typelxc, lxd, docker
  • container_id – container id

Example request

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

Example response

[]
POST /api/v1/container/(string: container_type)/(string: container_id)/resource/devices

Add multiple devices permission in one request. It will automatically remove original settings before add it.

Parameters:
  • container_typelxc, lxd, 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 [required]

Example request

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

Example response

{
    "arch": "amd64",
    "autostart": false,
    "image": "ubuntu-bionic",
    "name": "utest",
    "network": {
        "hostname": "utest",
        "mode": "",
        "port": []
    },
    "resource": {
        "device": [
            [
                "allow",
                "Input_(13)",
                "rwm"
            ],
            [
                "allow",
                "TTY_(4)",
                "rwm"
            ]
        ],
        "limit": {}
    },
    "type": "lxc",
    "version": "latest",
    "volume": {
        "container": [],
        "host": {}
    }
}

Example request: remove all settings

$ curl -sq -XPOST -b cookies.txt -d '[]' \
    http://${QIP}:${QPORT}/container-station/api/v1/container/lxc/utest/resource/devices

Example response: remove all settings

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

CPU and memory limits

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

Add CPU and memory limits.

Parameters:
  • container_typelxc, lxd, 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}/container-station/api/v1/container/lxc/utest/resource/limit

Example response

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

Delete resource limitation.

Parameters:
  • container_typelxc, lxd, docker
  • container_id – container id

Example request

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

Example response

[]

Storage

POST /api/v1/container/(string: container_type)/(string: container_id)/volume/host

Edit volume from host settings.

Parameters:
  • container_typelxc, lxd
  • container_id – container id
Request JSON Object:
 
  • host_path (object) – Host path
  • bind (string) – Mount point in container
  • ro (boolean) – Read-only

Example request

$ curl -sq -XPOST -b cookies.txt -d \
    '{
        "/test": {
            "bind": "/test1",
            "ro": false
        },
        "/test/selenium": {
            "bind": "/test2",
            "ro": true
        }
    }' \
    http://${QIP}:${QPORT}/container-station/api/v1/container/lxc/utest/volume/host

Example response

{
    "arch": "amd64",
    "autostart": false,
    "image": "ubuntu-bionic",
    "name": "utest",
    "network": {
        "hostname": "utest",
        "mode": "",
        "port": []
    },
    "resource": {
        "device": [],
        "limit": {
            "cpuweight": 600,
            "memory": "512m"
        }
    },
    "type": "lxc",
    "version": "latest",
    "volume": {
        "container": [],
        "host": {
            "/share/test": {
                "bind": "test1",
                "ro": false
            },
            "/share/test/selenium": {
                "bind": "test2",
                "ro": true
            }
        }
    }
}

Example request: remove all settings

$ curl -sq -XPOST -b cookies.txt -d '{}' \
    http://${QIP}:${QPORT}/container-station/api/v1/container/lxc/utest/volume/host

Example response: remove all settings

{
    "arch": "amd64",
    "autostart": false,
    "image": "ubuntu-bionic",
    "name": "utest",
    "network": {
        "hostname": "utest",
        "mode": "",
        "port": []
    },
    "resource": {
        "device": [],
        "limit": {
            "cpuweight": 600,
            "memory": "512m"
        }
    },
    "type": "lxc",
    "version": "latest",
    "volume": {
        "container": [],
        "host": {}
    }
}