Add unmigrate facility
This commit is contained in:
parent
e161a543cb
commit
0eccbd902f
|
@ -149,6 +149,15 @@ class VMInstance:
|
||||||
|
|
||||||
dest_conn.close()
|
dest_conn.close()
|
||||||
self.inmigrate = False
|
self.inmigrate = False
|
||||||
|
|
||||||
|
def unmigrate_vm(self):
|
||||||
|
print('>>> %s - Unmigrating VM' % self.domuuid)
|
||||||
|
former_hypervisor = self.zk.get(self.zkey + '/formerhypervisor')
|
||||||
|
transaction = self.zk.transaction()
|
||||||
|
transaction.set_data('/domains/' + domain + '/state', 'migrate'.encode('ascii'))
|
||||||
|
transaction.set_data('/domains/' + domain + '/hypervisor', former_hypervisor.encode('ascii'))
|
||||||
|
transaction.set_data('/domains/' + domain + '/formerhypervisor', ''.encode('ascii'))
|
||||||
|
result = transaction.commit()
|
||||||
|
|
||||||
# Receive the migration from another host (wait until VM is running)
|
# Receive the migration from another host (wait until VM is running)
|
||||||
def receive_migrate(self):
|
def receive_migrate(self):
|
||||||
|
@ -204,6 +213,10 @@ class VMInstance:
|
||||||
elif running == libvirt.VIR_DOMAIN_RUNNING and self.state == "migrate" and self.hypervisor != self.thishypervisor.name and self.inmigrate == False:
|
elif running == libvirt.VIR_DOMAIN_RUNNING and self.state == "migrate" and self.hypervisor != self.thishypervisor.name and self.inmigrate == False:
|
||||||
self.migrate_vm()
|
self.migrate_vm()
|
||||||
|
|
||||||
|
# VM should be unmigrated
|
||||||
|
elif running == libvirt.VIR_DOMAIN_RUNNING and self.state == "unmigrate" and self.hypervisor == self.thishypervisor.name and self.inmigrate == False:
|
||||||
|
self.unmigrate_vm()
|
||||||
|
|
||||||
# VM is already running and should be
|
# VM is already running and should be
|
||||||
elif running == libvirt.VIR_DOMAIN_RUNNING and self.state == "start" and self.hypervisor == self.thishypervisor.name:
|
elif running == libvirt.VIR_DOMAIN_RUNNING and self.state == "start" and self.hypervisor == self.thishypervisor.name:
|
||||||
if not self.domuuid in self.thishypervisor.domain_list:
|
if not self.domuuid in self.thishypervisor.domain_list:
|
||||||
|
|
Loading…
Reference in New Issue