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

ChrisMacNaughton on Github lxc-bot at linuxcontainers.org
Wed Sep 27 15:52:05 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 439 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170927/144268d4/attachment.bin>
-------------- next part --------------
From 6cbb80e5fab0c10c02a63cb939aa0fd8df0ac4dd Mon Sep 17 00:00:00 2001
From: Chris MacNaughton <chris at centaurisolutions.nl>
Date: Wed, 27 Sep 2017 11:25:55 -0400
Subject: [PATCH] Update cert check to look in snap path as well

When using a snap installed LXD, we need to look in the $HOME/snap
directory rather than looking in ~ for the certificates

Fixes #251
---
 pylxd/client.py | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/pylxd/client.py b/pylxd/client.py
index 499ce7d..9705435 100644
--- a/pylxd/client.py
+++ b/pylxd/client.py
@@ -192,10 +192,15 @@ class Client(object):
             >>> print api.containers['test'].get().json()
 
     """
-
-    DEFAULT_CERTS = (
-        os.path.expanduser('~/.config/lxc/client.crt'),
-        os.path.expanduser('~/.config/lxc/client.key'))
+    if os.path.exists(
+            os.path.expanduser('~/snap/lxd/current/.config/lxc/client.crt')):
+        DEFAULT_CERTS = (
+            os.path.expanduser('~/snap/lxd/current/.config/lxc/client.crt'),
+            os.path.expanduser('~/snap/lxd/current/.config/lxc/client.key'))
+    else:
+        DEFAULT_CERTS = (
+            os.path.expanduser('~/.config/lxc/client.crt'),
+            os.path.expanduser('~/.config/lxc/client.key'))
 
     def __init__(
             self, endpoint=None, version='1.0', cert=None, verify=True,


More information about the lxc-devel mailing list