diff --git a/instances/templates/instance.html b/instances/templates/instance.html
index ffa492c..2cbd079 100644
--- a/instances/templates/instance.html
+++ b/instances/templates/instance.html
@@ -1035,7 +1035,7 @@
@@ -1053,7 +1053,25 @@
+
+
+
{% if computes_count != 1 %}
diff --git a/instances/views.py b/instances/views.py
index 100a17a..6daa554 100644
--- a/instances/views.py
+++ b/instances/views.py
@@ -230,7 +230,7 @@ def instance(request, compute_id, vname):
else:
return network_source_pack[0], 'net'
- def migrate_instance(new_compute, instance, live=False, unsafe=False, xml_del=False, offline=False):
+ def migrate_instance(new_compute, instance, live=False, unsafe=False, xml_del=False, offline=False, autoconverge=False, compress=False, postcopy=False):
status = connection_manager.host_is_up(new_compute.type, new_compute.hostname)
if not status:
return
@@ -238,11 +238,11 @@ def instance(request, compute_id, vname):
return
try:
conn_migrate = wvmInstances(new_compute.hostname,
- new_compute.login,
- new_compute.password,
- new_compute.type)
+ new_compute.login,
+ new_compute.password,
+ new_compute.type)
- conn_migrate.moveto(conn, instance.name, live, unsafe, xml_del, offline)
+ conn_migrate.moveto(conn, instance.name, live, unsafe, xml_del, offline, autoconverge, compress, postcopy)
finally:
conn_migrate.close()
@@ -812,16 +812,24 @@ def instance(request, compute_id, vname):
return HttpResponseRedirect(request.get_full_path() + '#options')
if 'migrate' in request.POST:
+
compute_id = request.POST.get('compute_id', '')
live = request.POST.get('live_migrate', False)
unsafe = request.POST.get('unsafe_migrate', False)
xml_del = request.POST.get('xml_delete', False)
offline = request.POST.get('offline_migrate', False)
+ autoconverge = request.POST.get('autoconverge', False)
+ compress = request.POST.get('compress', False)
+ postcopy = request.POST.get('postcopy', False)
new_compute = Compute.objects.get(id=compute_id)
- migrate_instance(new_compute, instance, live, unsafe, xml_del, offline)
-
- return HttpResponseRedirect(reverse('instance', args=[new_compute.id, vname]))
+ try:
+ migrate_instance(new_compute, instance, live, unsafe, xml_del, offline)
+ return HttpResponseRedirect(reverse('instance', args=[new_compute.id, vname]))
+ except libvirtError as err:
+ messages.error(request, err)
+ addlogmsg(request.user.username, instance.name, err)
+ return HttpResponseRedirect(request.get_full_path() + '#migrate')
if 'change_network' in request.POST:
msg = _("Change network")
@@ -1240,7 +1248,8 @@ def inst_graph(request, compute_id, vname):
def _get_dhcp_mac_address(vname):
- dhcp_file = '/srv/webvirtcloud/dhcpd.conf'
+
+ dhcp_file = settings.BASE_DIR + '/dhcpd.conf'
mac = ''
if os.path.isfile(dhcp_file):
with open(dhcp_file, 'r') as f:
diff --git a/vrtManager/instance.py b/vrtManager/instance.py
index 20d78a2..8a18559 100644
--- a/vrtManager/instance.py
+++ b/vrtManager/instance.py
@@ -2,15 +2,15 @@ import time
import os.path
try:
from libvirt import libvirtError, VIR_DOMAIN_XML_SECURE, VIR_DOMAIN_RUNNING, VIR_DOMAIN_AFFECT_LIVE, \
- VIR_DOMAIN_AFFECT_CONFIG, VIR_DOMAIN_UNDEFINE_NVRAM, VIR_DOMAIN_UNDEFINE_KEEP_NVRAM,\
- VIR_DOMAIN_START_PAUSED
+ VIR_DOMAIN_AFFECT_CONFIG, VIR_DOMAIN_UNDEFINE_NVRAM, VIR_DOMAIN_UNDEFINE_KEEP_NVRAM, VIR_DOMAIN_START_PAUSED
from libvirt import VIR_MIGRATE_LIVE, \
VIR_MIGRATE_UNSAFE, \
VIR_MIGRATE_PERSIST_DEST, \
VIR_MIGRATE_UNDEFINE_SOURCE, \
VIR_MIGRATE_OFFLINE,\
VIR_MIGRATE_COMPRESSED, \
- VIR_MIGRATE_AUTO_CONVERGE
+ VIR_MIGRATE_AUTO_CONVERGE, \
+ VIR_MIGRATE_POSTCOPY
except:
from libvirt import libvirtError, VIR_DOMAIN_XML_SECURE, VIR_MIGRATE_LIVE
@@ -80,20 +80,22 @@ class wvmInstances(wvmConnect):
dom = self.get_instance(name)
dom.resume()
- def moveto(self, conn, name, live, unsafe, undefine, offline, autoconverge=False, compress=False):
+ def moveto(self, conn, name, live, unsafe, undefine, offline, autoconverge=False, compress=False, postcopy=False):
flags = VIR_MIGRATE_PERSIST_DEST
- if live and conn.get_status() == 1:
+ if live and conn.get_status() != 5:
flags |= VIR_MIGRATE_LIVE
if unsafe and conn.get_status() == 1:
flags |= VIR_MIGRATE_UNSAFE
- if undefine:
- flags |= VIR_MIGRATE_UNDEFINE_SOURCE
- if offline:
+ if offline and conn.get_status() == 5:
flags |= VIR_MIGRATE_OFFLINE
if not offline and autoconverge:
flags |= VIR_MIGRATE_AUTO_CONVERGE
- if compress:
+ if not offline and compress and conn.get_status() == 1:
flags |= VIR_MIGRATE_COMPRESSED
+ if not offline and postcopy and conn.get_status() == 1:
+ flags |= VIR_MIGRATE_POSTCOPY
+ if undefine:
+ flags |= VIR_MIGRATE_UNDEFINE_SOURCE
dom = conn.get_instance(name)