0

I am trying to create a new profile for LXC.

I did this;

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
}

The output is success but no profile actually gets created.

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"
  ]
}

The logs doesnt show any error or warnings either. /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

What sins have I committed? Please help.

Nagri
  • 3,008
  • 5
  • 34
  • 63

1 Answers1

0

You stupid stupid person. Read the docs properly.

Apparently with POST all you can do is change the name of a profile. To Update a profile you'll have to use PUT.

first create an empty profile named testing by

$ lxc profile create testing

This will create an empty profile testing.

The go ahead and do this;

$ 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 .

This will update your profile.

Enjoy.

Nagri
  • 3,008
  • 5
  • 34
  • 63