[lxc-devel] [pylxd/master] Added example on how to use the migrate API

gabrik on Github lxc-bot at linuxcontainers.org
Mon Jul 9 09:27:51 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 460 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180709/a90270df/attachment.bin>
-------------- next part --------------
From f01c61e4f778fc757b2322fc204c9439df46e7ff Mon Sep 17 00:00:00 2001
From: gabrik <gabriele.baldoni at gmail.com>
Date: Mon, 9 Jul 2018 11:24:13 +0200
Subject: [PATCH] example on migration

---
 doc/source/containers.rst | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/doc/source/containers.rst b/doc/source/containers.rst
index c355302..864855e 100644
--- a/doc/source/containers.rst
+++ b/doc/source/containers.rst
@@ -144,6 +144,25 @@ To get state information such as a network address.
     {'family': 'inet', 'address': '10.251.77.182', 'netmask': '24', 'scope': 'global'}
 
 
+To migrate a container between two servers, first you need to create a client certificate in order to connect to the remote server
+
+    openssl req -newkey rsa:2048 -nodes -keyout lxd.key -out lxd.csr
+    openssl x509 -signkey lxd.key -in lxd.csr -req -days 365 -out lxd.crt
+
+Then you need to connect to both the destination server and the source server,
+the source server has to be reachable by the destination server otherwise the migration will fail due to a websocket error
+
+.. code-block:: python
+
+    from pylxd import Client
+
+    client_source=Client(endpoint='https://192.168.1.104:8443',cert=('lxd.crt','lxd.key'),verify=False)
+    client_destination=Client(endpoint='https://192.168.1.106:8443',cert=('lxd.crt','lxd.key'),verify=False)
+    cont = client_source.containers.get('testm')
+    cont.migrate(client_destination,wait=True)
+
+This will migrate the container from source server to destination server
+
 Container Snapshots
 -------------------
 


More information about the lxc-devel mailing list