[lxc-users] configuration via Rest-API

Ingo Baab ib at baab.de
Sun Mar 3 15:34:58 UTC 2019


Hello,
I want to reconfigure an already created lxd-container (named 'baab') with
the RestAPI. I searched and read on [1] and [2], but can't figure it 
out. Can
anyone tell me, whats wrong here. What is the difference between "config"
and "expanded_config" (is the first one from the profile and the second "an
overwrite"?). I attached a "GET lxd/1.0/containers/baab" as [3].
Thank you for any hint. Here is my unsuccessful attempt:


*    jq .metadata <<< $(   curl -s --unix-socket 
/var/lib/lxd/unix.socket -X PUT -d '{"expanded_config": {"limits.cpu": 
"4"}}' lxd/1.0/containers/baab  )
*
     {
       "id": "ee4e3187-332e-44ff-b88f-531c243b4108",
       "class": "task",
       "created_at": "2019-03-03T16:32:38.036308794+01:00",
       "updated_at": "2019-03-03T16:32:38.036308794+01:00",
       "status": "Running",
       "status_code": 103,
       "resources": {
         "containers": [
           "/1.0/containers/baab"
         ]
       },
       "metadata": null,
       "may_cancel": false,
       "err": ""
     }


kind regards,
Ingo Baab

____________

[1] https://stgraber.org/2016/04/18/lxd-api-direct-interaction/
[2] https://lxd.readthedocs.io/en/latest/rest-api/

[3] jq .metadata <<< $(   curl -s --unix-socket /var/lib/lxd/unix.socket 
-X GET lxd/1.0/containers/baab  )
{
   "architecture": "x86_64",
   "config": {
     "boot.autostart": "true",
     "image.architecture": "amd64",
     "image.description": "ubuntu 16.04 LTS amd64 (release) (20180306)",
     "image.label": "release",
     "image.os": "ubuntu",
     "image.release": "xenial",
     "image.serial": "20180306",
     "image.version": "16.04",
     "raw.apparmor": "mount,",
     "volatile.base_image": 
"c5bbef7f4e1c19f0104fd49b862b2e549095d894765c75c6d72775f1d98185ec",
     "volatile.eth0.hwaddr": "00:16:3e:5b:cb:d8",
     "volatile.idmap.base": "0",
     "volatile.idmap.next": 
"[{\"Isuid\":true,\"Isgid\":false,\"Hostid\":100000,\"Nsid\":0,\"Maprange\":65536},{\"Isuid\":false,\"Isgid\":true,\"Hostid\":100000,\"Nsid\":0,\"Maprange\":65536}]",
     "volatile.last_state.idmap": 
"[{\"Isuid\":true,\"Isgid\":false,\"Hostid\":100000,\"Nsid\":0,\"Maprange\":65536},{\"Isuid\":false,\"Isgid\":true,\"Hostid\":100000,\"Nsid\":0,\"Maprange\":65536}]",
     "volatile.last_state.power": "RUNNING"
   },
   "devices": {
     "system": {
       "path": "/var/www/system",
       "source": "/root/system",
       "type": "disk"
     }
   },
   "ephemeral": false,
   "profiles": [
     "default"
   ],
   "stateful": false,
   "description": "",
   "created_at": "2019-02-22T14:51:50Z",
   "expanded_config": {
     "boot.autostart": "true",
     "environment.http_proxy": "",
     "image.architecture": "amd64",
     "image.description": "ubuntu 16.04 LTS amd64 (release) (20180306)",
     "image.label": "release",
     "image.os": "ubuntu",
     "image.release": "xenial",
     "image.serial": "20180306",
     "image.version": "16.04",
     "limits.cpu": "3",
     "limits.cpu.allowance": "10%",
     "limits.cpu.priority": "0",
     "limits.memory": "4GB",
     "raw.apparmor": "mount,",
     "user.network_mode": "",
     "volatile.base_image": 
"c5bbef7f4e1c19f0104fd49b862b2e549095d894765c75c6d72775f1d98185ec",
     "volatile.eth0.hwaddr": "00:16:3e:5b:cb:d8",
     "volatile.idmap.base": "0",
     "volatile.idmap.next": 
"[{\"Isuid\":true,\"Isgid\":false,\"Hostid\":100000,\"Nsid\":0,\"Maprange\":65536},{\"Isuid\":false,\"Isgid\":true,\"Hostid\":100000,\"Nsid\":0,\"Maprange\":65536}]",
     "volatile.last_state.idmap": 
"[{\"Isuid\":true,\"Isgid\":false,\"Hostid\":100000,\"Nsid\":0,\"Maprange\":65536},{\"Isuid\":false,\"Isgid\":true,\"Hostid\":100000,\"Nsid\":0,\"Maprange\":65536}]",
     "volatile.last_state.power": "RUNNING"
   },
   "expanded_devices": {
     "eth0": {
       "name": "eth0",
       "nictype": "bridged",
       "parent": "lxdbr0",
       "type": "nic"
     },
     "root": {
       "path": "/",
       "pool": "lxd",
       "size": "120GB",
       "type": "disk"
     },
     "system": {
       "path": "/var/www/system",
       "source": "/root/system",
       "type": "disk"
     }
   },
   "name": "baab",
   "status": "Running",
   "status_code": 103,
   "last_used_at": "2019-02-22T14:57:25.577377793Z"
}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20190303/71be1764/attachment.html>


More information about the lxc-users mailing list