[lxc-devel] [pylxd/master] Quote the path of unix endpoints.

pcdummy on Github lxc-bot at linuxcontainers.org
Sun Jul 24 19:06:26 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 435 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160724/21f8c3da/attachment.bin>
-------------- next part --------------
From c97532afeea0048e7672796e8a1d6d2828fafb6f Mon Sep 17 00:00:00 2001
From: Rene Jochum <rene at jochums.at>
Date: Sun, 24 Jul 2016 20:41:42 +0200
Subject: [PATCH] Quote the path of unix endpoints.

Signed-off-by: Rene Jochum <rene at jochums.at>
---
 pylxd/client.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/pylxd/client.py b/pylxd/client.py
index b9a0cca..e18028c 100644
--- a/pylxd/client.py
+++ b/pylxd/client.py
@@ -13,6 +13,7 @@
 #    under the License.
 import json
 import os
+import os.path
 
 import requests
 import requests_unixsocket
@@ -163,7 +164,11 @@ class Client(object):
     def __init__(self, endpoint=None, version='1.0', cert=None, verify=True):
         self.cert = cert
         if endpoint is not None:
-            self.api = _APINode(endpoint, cert=cert, verify=verify)
+            if endpoint.startswith('/') and os.path.isfile(endpoint):
+                self.api = _APINode('http+unix://{}'.format(
+                    parse.quote(endpoint, safe='')))
+            else:
+                self.api = _APINode(endpoint, cert=cert, verify=verify)
         else:
             if 'LXD_DIR' in os.environ:
                 path = os.path.join(


More information about the lxc-devel mailing list