Some fixes
This commit is contained in:
parent
0e897faf21
commit
d9a5895c4e
|
@ -78,7 +78,7 @@ class VMInstance:
|
|||
# Receive the migration from another host (wait until VM is running)
|
||||
def receive_migrate(self):
|
||||
while True:
|
||||
if self.dom.state() != libvirt.VIR_DOMAIN_RUNNING:
|
||||
if self.dom == None or self.dom.state() != libvirt.VIR_DOMAIN_RUNNING:
|
||||
continue
|
||||
else:
|
||||
self.zk.set(self.zkey + '/status', b'start')
|
||||
|
|
36
pvc.py
36
pvc.py
|
@ -16,17 +16,27 @@ def define_domain(domxmlfile):
|
|||
print('Adding domain %s to database' % domuuid)
|
||||
|
||||
zk = kazoo.client.KazooClient(hosts='127.0.0.1:2181')
|
||||
try:
|
||||
zk.start()
|
||||
transaction = zk.transaction()
|
||||
transaction.create('/domains/%s' % domuuid, "".encode('ascii'))
|
||||
transaction.create('/domains/%s/state' % domuuid, "stop".encode('ascii'))
|
||||
transaction.create('/domains/%s/hypervisor' % domuuid, socket.gethostname().encode('ascii'))
|
||||
transaction.create('/domains/%s/xml' % domuuid, data.encode('ascii'))
|
||||
results = transaction.commit()
|
||||
zk.stop()
|
||||
zk.close()
|
||||
except:
|
||||
print('Failed to connect to local Zookeeper instance')
|
||||
zk.start()
|
||||
transaction = zk.transaction()
|
||||
transaction.create('/domains/%s' % domuuid, "".encode('ascii'))
|
||||
transaction.create('/domains/%s/state' % domuuid, "stop".encode('ascii'))
|
||||
transaction.create('/domains/%s/hypervisor' % domuuid, socket.gethostname().encode('ascii'))
|
||||
transaction.create('/domains/%s/xml' % domuuid, data.encode('ascii'))
|
||||
results = transaction.commit()
|
||||
zk.stop()
|
||||
zk.close()
|
||||
|
||||
define_domain('/var/home/joshua/debian9.xml')
|
||||
def migrate_domain(domuuid, target):
|
||||
zk = kazoo.client.KazooClient(hosts='127.0.0.1:2181')
|
||||
zk.start()
|
||||
transaction = zk.transaction()
|
||||
# transaction.set_data('/domains/%s/state' % domuuid, 'migrate'.encode('ascii'))
|
||||
transaction.set_data('/domains/%s/hypervisor' % domuuid, target.encode('ascii'))
|
||||
results = transaction.commit()
|
||||
zk.stop()
|
||||
zk.close()
|
||||
|
||||
|
||||
#define_domain('/var/home/joshua/debian9.xml')
|
||||
migrate_domain('b1dc4e21-544f-47aa-9bb7-8af0bc443b78', 'test1.i.bonilan.net')
|
||||
#migrate_domain('b1dc4e21-544f-47aa-9bb7-8af0bc443b78', 'test2.i.bonilan.net')
|
||||
|
|
Loading…
Reference in New Issue