]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
python: Fix get_ips and nesting with lxcpath
authorStéphane Graber <stgraber@ubuntu.com>
Sun, 21 Apr 2013 20:42:06 +0000 (22:42 +0200)
committerStéphane Graber <stgraber@ubuntu.com>
Mon, 22 Apr 2013 07:00:43 +0000 (09:00 +0200)
When using -P (lxcpath), the parameter path needs to be forwarded
to the various commands being run but not used by the nested lxc-ls
as it's relatively unlikely that both the host and the nested containers
use a custom path.

This isn't ideal but short of having a way to provide the container path
for every single of the nesting (with potential unlimited depth), it's
the best we can do.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/lxc-ls
src/python-lxc/lxc/__init__.py

index 4308edea7160711c1d0fea991a72c1ea858b8c64..d4e369b6f8faa86f313b4cf60ecdb025e8363993 100644 (file)
@@ -89,12 +89,13 @@ def getTerminalSize():
 
 
 def getSubContainers(container, lxcpath):
-    attach = ['lxc-attach', '-R', '-s', 'NETWORK|PID', '-n', container,
+    attach = ['lxc-attach', '-P', lxcpath, '-R', '-s', 'NETWORK|PID',
+              '-n', container,
               '--', sys.argv[0], "--nesting"]
 
     with open(os.devnull, "w") as fd:
         newenv = dict(os.environ)
-        newenv['NESTED'] = "/proc/1/root/%s" % lxcpath
+        newenv['NESTED'] = "/proc/1/root/%s" % lxc.default_config_path
         sp = subprocess.Popen(attach, stderr=fd, stdout=subprocess.PIPE,
                               env=newenv, universal_newlines=True)
         sp.wait()
index e3ce8ebf0ead96434646928f6fbfd8c8496ae09c..c235d182631432a490f37e91e2eebbfe85fd454e 100644 (file)
@@ -347,7 +347,8 @@ class Container(_lxc.Container):
             if count != 0:
                 time.sleep(1)
 
-            base_cmd = ["lxc-attach", "-s", "NETWORK", "-n", self.name, "--",
+            base_cmd = ["lxc-attach", "-s", "NETWORK",
+                        "-P", self.get_config_path(), "-n", self.name, "--",
                         "ip"]
 
             # Get IPv6