Apply just device yaml on container configuration

Hello

I would like to apply just the yaml portion concerning “devices” to a container (yml extract from ‘lxc config device show xxxxx’).
would that be possible with lxd commands?

Exemple:

file:
  path: home/rustical/emaraud/file
  source: /usr/local/share/rustical/emaraud/file
  type: disk
files:
  path: home/rustical/emaraud/files
  source: /usr/local/share/rustical/emaraud/files
  type: disk

Hi!

You can create a new empty profile, and add just those devices into that profile. The idea is that you can assign profiles to containers, therefore, you assign the existing profile(s) and on top of that this new profile.

$ lxc profile show myfragmet
Error: Fetch profile: No such object
$ lxc profile create myfragment
Profile myfragment created
$ lxc profile show myfragment
config: {}
description: ""
devices: {}
name: myfragment
used_by: []

Add the devices by changing

devices: {}

with

devices: 
  file:
    path: home/rustical/emaraud/file
    source: /usr/local/share/rustical/emaraud/file
    type: disk
  files:
    path: home/rustical/emaraud/files
    source: /usr/local/share/rustical/emaraud/files
    type: disk

You can assign profiles to a container with

lxc profile assign mycontainer default,myfragment