[lxc-devel] [pylxd/master] Updated example of profile updating and saving

afreiberger on Github lxc-bot at linuxcontainers.org
Mon Aug 19 21:15:51 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 696 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190819/a8449352/attachment.bin>
-------------- next part --------------
From 08d97d126cb6d3e5b16c321cb1130d38c3dce7a7 Mon Sep 17 00:00:00 2001
From: Drew Freiberger <drew.freiberger at canonical.com>
Date: Mon, 19 Aug 2019 16:15:21 -0500
Subject: [PATCH] Updated example of profile updating and saving

It was discovered that using profile.config and profile.devices as left-hand-sides to a .update function was setting them to "none" and the profile.update() was not actually saving.  profile.save() was also causing the profile settings to be blanked out due to the NoneTypes being set to profile.config and profile.devices.  Also expanded profile attribute descriptions to explicitly note types
---
 doc/source/profiles.rst | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/doc/source/profiles.rst b/doc/source/profiles.rst
index d7dadf11..e69ebed5 100644
--- a/doc/source/profiles.rst
+++ b/doc/source/profiles.rst
@@ -21,11 +21,11 @@ methods:
 Profile attributes
 ------------------
 
-  - `config` - config options for containers
-  - `description` - The description of the profile
-  - `devices` - device options for containers
-  - `name` - The name of the profile
-  - `used_by` - A list of containers using this profile
+  - `config` - (dict) config options for containers
+  - `description` - (str) The description of the profile
+  - `devices` - (dict) device options for containers
+  - `name` - (str) name of the profile
+  - `used_by` - (list) containers using this profile
 
 
 Profile methods
@@ -51,8 +51,9 @@ Containers and Images. Profiles are keyed on a unique name.
 
 The profile can then be modified and saved.
 
-    >>> profile.config = profile.config.update({'security.nesting': 'true'})
-    >>> profile.update()
+    >>> profile.config.update({'security.nesting': 'true'})
+    >>> profile.devices.update({"eth0": {"parent": "lxdbr0", "nictype": "bridged", "type": "nic", "name": "eth0"}})
+    >>> profile.save()
 
 
 To create a new profile, use `create` with a name, and optional `config`


More information about the lxc-devel mailing list