canonical/pycloudlib

Xenial VM pull_file(): Error: Failed to connect to lxd-agent

Closed this issue · 1 comments

With 96b146e landing pycloudlib is not able to pull_file() from Xenial VM instances anymore:

In [11]: i.execute("ls -l")
Out[11]: 'total 0\n-rw-rw-r-- 1 ubuntu ubuntu 0 Mar 18 15:46 testfile'
In [14]: i.pull_file("testfile", "/tmp/ttttt")
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-14-ee6e80df3717> in <module>
----> 1 i.pull_file("testfile", "/tmp/ttttt")

~/canonical/venv/pycloudlib.venv/lib/python3.9/site-packages/pycloudlib/lxd/instance.py in pull_file(self, remote_path, local_path)
    201             self._log.debug("Absolute remote path: %s", remote_path)
    202 
--> 203         subp(['lxc', 'file', 'pull', '%s%s' %
    204               (self.name, remote_path), local_path])
    205 

~/canonical/venv/pycloudlib.venv/lib/python3.9/site-packages/pycloudlib/util.py in subp(args, data, env, shell, rcs, shortcircuit_stdin)
    199             errmsg = "command failed silently"
    200         errmsg = "Failure (rc=%s): %s" % (rc, errmsg)
--> 201         raise RuntimeError(errmsg)
    202 
    203     return Result(out, err, rc)

RuntimeError: Failure (rc=1): Error: Failed to connect to lxd-agent

This likely needs an if self.execute_via_ssh: return super().pull_file(...) adding, to mirror the one in LXDInstance._run_command.