Some fixes

This commit is contained in:
Joshua Boniface 2018-06-02 14:32:59 -04:00
parent 0e897faf21
commit d9a5895c4e
2 changed files with 24 additions and 14 deletions

View File

@ -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')

18
pvc.py
View File

@ -16,7 +16,6 @@ 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'))
@ -26,7 +25,18 @@ def define_domain(domxmlfile):
results = transaction.commit()
zk.stop()
zk.close()
except:
print('Failed to connect to local Zookeeper instance')
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')