Handle restarts nicer; fix bug in failedreason write

This commit is contained in:
Joshua Boniface 2018-07-20 01:02:18 -04:00
parent 3732ecbbf3
commit 73fcf10250
1 changed files with 4 additions and 8 deletions

View File

@ -126,7 +126,7 @@ class VMInstance:
except libvirt.libvirtError as e:
ansiiprint.echo('Failed to create VM', '{}:'.format(self.domuuid), 'e')
zkhandler.writedata(self.zk_conn, { '/domains/{}/state'.format(self.domuuid): 'failed' })
zkhandler.writedata(self.zk_conn, { '/domains/{}/failedreason'.format(self.domuuid): e })
zkhandler.writedata(self.zk_conn, { '/domains/{}/failedreason'.format(self.domuuid): str(e) })
self.dom = None
lv_conn.close()
@ -145,13 +145,9 @@ class VMInstance:
self.inrestart = False
return
try:
self.shutdown_vm()
self.start_vm()
self.addDomainToList()
ansiiprint.echo('Successfully restarted VM', '{}:'.format(self.domuuid), 'o')
except libvirt.libvirtError as e:
ansiiprint.echo('Failed to restart VM', '{}:'.format(self.domuuid), 'e')
zkhandler.writedata(self.zk_conn, { '/domains/{}/state'.format(self.domuuid): 'start' })
lv_conn.close()