The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/python3-lxc/pull/23

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Fixes #16 

> the issue here is that create() creates a rootfs for a container while destroy() deletes the container itself including its path. It's that step which is preventing it be re-created as the object still has its old config, causing it to prevent a new create() run.

Changes:
- `create()` calls `save_config()` if the container is not defined 
- `destroy()` calls `clear_config()` on success

Signed-off-by: Anirudh Goyal <anirudhgo...@utexas.edu>


From 998e80e1754654957bbe9a73ac5cd9a22ffe56b4 Mon Sep 17 00:00:00 2001
From: anirudh-goyal <anirudhgo...@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 <anirudhgo...@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=()):
         """
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to