[lxc-devel] [pylxd/master] Update pylxd to look in snap path as well

ChrisMacNaughton on Github lxc-bot at linuxcontainers.org
Tue Sep 26 19:02:56 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 411 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170926/f527cdd0/attachment.bin>
-------------- next part --------------
From 060bb3c903951a63123e020faaf6fc4ccbc5c1dd Mon Sep 17 00:00:00 2001
From: Chris MacNaughton <chris at centaurisolutions.nl>
Date: Tue, 26 Sep 2017 15:02:12 -0400
Subject: [PATCH] Update pylxd to look in snap path as well

This adds support for LXD being installed via snap
in addition to the traditional apt package.

Fixes #248
---
 pylxd/client.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/pylxd/client.py b/pylxd/client.py
index 19c4ff1..499ce7d 100644
--- a/pylxd/client.py
+++ b/pylxd/client.py
@@ -219,7 +219,10 @@ def __init__(
                 path = os.path.join(
                     os.environ.get('LXD_DIR'), 'unix.socket')
             else:
-                path = '/var/lib/lxd/unix.socket'
+                if os.path.exists('/var/snap/lxd/common/lxd/unix.socket'):
+                    path = '/var/snap/lxd/common/lxd/unix.socket'
+                else:
+                    path = '/var/lib/lxd/unix.socket'
             self.api = _APINode('http+unix://{}'.format(
                 parse.quote(path, safe='')), timeout=timeout)
         self.api = self.api[version]


More information about the lxc-devel mailing list