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: 's avatarStéphane Graber <stgraber@ubuntu.com> Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
parent a2abaa9e
...@@ -89,12 +89,13 @@ def getTerminalSize(): ...@@ -89,12 +89,13 @@ def getTerminalSize():
def getSubContainers(container, lxcpath): 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"] '--', sys.argv[0], "--nesting"]
with open(os.devnull, "w") as fd: with open(os.devnull, "w") as fd:
newenv = dict(os.environ) 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, sp = subprocess.Popen(attach, stderr=fd, stdout=subprocess.PIPE,
env=newenv, universal_newlines=True) env=newenv, universal_newlines=True)
sp.wait() sp.wait()
......
...@@ -347,7 +347,8 @@ class Container(_lxc.Container): ...@@ -347,7 +347,8 @@ class Container(_lxc.Container):
if count != 0: if count != 0:
time.sleep(1) 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"] "ip"]
# Get IPv6 # Get IPv6
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment