【问题标题】:LXD API not creating profileLXD API 未创建配置文件
【发布时间】:2016-09-07 10:56:00
【问题描述】:

我正在尝试为 LXC 创建一个新的配置文件。

我这样做了;

root@nagri:/home/nagri# curl -s -k --cert ~/.config/lxc/client.crt --key ~/.config/lxc/client.key -X POST -d '{
    "name": "testing",
    "description": "Some description string",
    "config": {
        "limits.memory": "2GB"
    },
    "devices": {
        "kvm": {
            "type": "unix-char",
            "path": "/dev/kvm"
        }
    }
}' https://localhost:8443/1.0/profiles/testing | jq .
{
  "type": "sync",
  "status": "Success",
  "status_code": 200,
  "metadata": null
}

输出成功,但实际上没有创建 profile

root@nagri:/home/nagri# curl -s --unix-socket /var/lib/lxd/unix.socket a/1.0/profiles -X GET | jq
{
  "type": "sync",
  "status": "Success",
  "status_code": 200,
  "metadata": [
    "/1.0/profiles/docker",
    "/1.0/profiles/lxd-nginx"
  ]
}

日志也不显示任何错误或警告。 /var/log/lxd/lxd.log

t=2016-09-07T16:22:18+0530 lvl=info msg=handling ip=127.0.0.1:49796 method=POST url=/1.0/profiles/testing

我犯了什么罪?请帮忙。

【问题讨论】:

    标签: curl lxc lxd


    【解决方案1】:

    你这个愚蠢的愚蠢的人。正确阅读docs

    显然,使用 POST 您所能做的就是更改个人资料的名称。 要更新配置文件,您必须使用 PUT

    首先创建一个名为testing的空配置文件

    $ lxc profile create testing
    

    这将创建一个空的配置文件测试。

    继续做这个;

    $ curl -s -k --cert ~/.config/lxc/client.crt --key ~/.config/lxc/client.key -X PUT -d '{
    "name": "testing",
    "description": "Some description string",
    "config": {
        "limits.memory": "2GB"
    },
    "devices": {
        "kvm": {
            "type": "unix-char",
            "path": "/dev/kvm"
        }
    }
      }' https://localhost:8443/1.0/profiles/testing | jq .
    

    这将更新您的个人资料。

    享受吧。

    【讨论】:

      猜你喜欢
      • 2017-01-28
      • 1970-01-01
      • 1970-01-01
      • 2019-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多