[lxc-devel] [python3-lxc/master] Fixes incorrect behavior with create() after destroy()

anirudh-goyal on Github lxc-bot at linuxcontainers.org
Wed Dec 2 18:33:07 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 778 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20201202/470c71a7/attachment.bin>
-------------- next part --------------
From 998e80e1754654957bbe9a73ac5cd9a22ffe56b4 Mon Sep 17 00:00:00 2001
From: anirudh-goyal <anirudhgoyal at utexas.edu>
Date: Wed, 2 Dec 2020 23:58:15 +0530
Subject: [PATCH] create() saves config if not defined. destroy() clears config
 on success. Signed-off-by: Anirudh Goyal <anirudhgoyal at utexas.edu>

---
 lxc/__init__.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lxc/__init__.py b/lxc/__init__.py
index ccc4d18..b23b950 100644
--- a/lxc/__init__.py
+++ b/lxc/__init__.py
@@ -217,6 +217,9 @@ def create(self, template=None, flags=0, args=(), bdevtype=None):
             "args" (optional) is a tuple of arguments to pass to the
             template. It can also be provided as a dict.
         """
+        if(not self.defined):
+           self.save_config()
+
         if isinstance(args, dict):
             tmp_args = []
             for item in args.items():
@@ -232,6 +235,12 @@ def create(self, template=None, flags=0, args=(), bdevtype=None):
             template_args['bdevtype'] = bdevtype
         return _lxc.Container.create(self, **template_args)
 
+    def destroy(self):
+        rv = _lxc.Container.destroy(self)
+        if(rv):
+            self.clear_config()
+        return rv
+
     def clone(self, newname, config_path=None, flags=0, bdevtype=None,
               bdevdata=None, newsize=0, hookargs=()):
         """


More information about the lxc-devel mailing list