From: Stéphane Graber Date: Sun, 21 Apr 2013 20:42:06 +0000 (+0200) Subject: python: Fix get_ips and nesting with lxcpath X-Git-Tag: lxc-1.0.0.alpha1~1^2~278 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=599d42525144cf0fcc7de6ac1b576c5c6ae290c2;p=thirdparty%2Flxc.git python: Fix get_ips and nesting with lxcpath 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 Acked-by: Serge E. Hallyn --- diff --git a/src/lxc/lxc-ls b/src/lxc/lxc-ls index 4308edea7..d4e369b6f 100644 --- a/src/lxc/lxc-ls +++ b/src/lxc/lxc-ls @@ -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() diff --git a/src/python-lxc/lxc/__init__.py b/src/python-lxc/lxc/__init__.py index e3ce8ebf0..c235d1826 100644 --- a/src/python-lxc/lxc/__init__.py +++ b/src/python-lxc/lxc/__init__.py @@ -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