[lxc-devel] [nova-lxd/master] Transition away from pylxd.deprecated

zulcss on Github lxc-bot at linuxcontainers.org
Wed Jun 8 15:53:33 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 477 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160608/3df9d3bc/attachment.bin>
-------------- next part --------------
From 359c4d36ad61528fc38a8d07c5b5c221a5501c75 Mon Sep 17 00:00:00 2001
From: Chuck Short <chuck.short at canonical.com>
Date: Wed, 8 Jun 2016 11:43:27 -0400
Subject: [PATCH] Transition away from pylxd.deprecated usage

Transition away from pylxd.deprecated usage since
pylxd2.0 has reached a state where nova-lxd can
use it reliably.

Signed-off-by: Chuck Short <chuck.short at canonical.com>
---
 nova/virt/lxd/session.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/nova/virt/lxd/session.py b/nova/virt/lxd/session.py
index 65d415b..da1c6e4 100644
--- a/nova/virt/lxd/session.py
+++ b/nova/virt/lxd/session.py
@@ -25,6 +25,7 @@
 from oslo_service import loopingcall
 from oslo_utils import excutils
 
+from pylxd import client
 from pylxd.deprecated import api
 from pylxd.deprecated import exceptions as lxd_exceptions
 
@@ -44,6 +45,21 @@ class LXDAPISession(object):
     def __init__(self):
         super(LXDAPISession, self).__init__()
 
+        self.client = self._get_session()
+
+    def _get_session(self):
+        """Returns a connection to the LXD hypervisor
+
+        This method should be used to create a connection
+        to the LXD hypervisor via the pylxd API call.
+
+        :return: pylxd object
+        """
+        try:
+            return client.Client()
+        except Exception as ex:
+            LOG.exception(_LE('Connection to LXD failed: %s') % ex)
+
     def get_session(self, host=None):
         """Returns a connection to the LXD hypervisor
 


More information about the lxc-devel mailing list