如何使用 lxc 配置文件集?

WoJ*_*WoJ 3 lxc lxd

我想从命令行编辑 LXD 配置文件。这是由lxc profile set

lxc profile get <profile> <key> 获取配置文件配置。

lxc profile set <profile> <key> <value> 设置配置文件配置。

的预期格式是<key> <value>什么?来自的输出lxc show profile表明了一个点状结构:

root@ubuntu ~# lxc profile show zoneminder
name: zoneminder
config:
  raw.lxc: lxc.aa_allow_incomplete=1
description: ""
devices:
  eth0:
    name: eth0
    nictype: bridged
    parent: zoneminder0
    type: nic
Run Code Online (Sandbox Code Playgroud)

但我get什么也没做(更不用说 - set)。我尝试了各种咒语(例如lxc profile get zoneminder name, lxc profile get zoneminder lxc.name, ... 以获得上述值name),但它们都没有返回任何内容。

Ste*_*ren 8

获取值的基本语法是:

$ lxc profile get default somekey
Run Code Online (Sandbox Code Playgroud)

但是,要获得某些东西,您需要先设置它。看来您只能设置已知的键值,即那些对 lxd 具有积极意义的键值:

$ lxc profile set default rubbish 1
error: Bad key: rubbish

$ lxc profile set default limits.cpu 1
Run Code Online (Sandbox Code Playgroud)

...然后你可以检索它:

$ lxc profile get default limits.cpu
1

$ lxc profile show default
name: default
config:
  limits.cpu: "1"
description: Default LXD profile
devices:
  eth0:
    name: eth0
    nictype: bridged
    parent: lxdbr0
    type: nic
Run Code Online (Sandbox Code Playgroud)

设备似乎很特别;常规 get/set 访问配置文件的“config”子字段,但您需要使用特殊命令来操作设备:

$ lxc profile device get default eth0 nictype
bridged
Run Code Online (Sandbox Code Playgroud)