Handle restarts nicer; fix bug in failedreason write
This commit is contained in:
parent
3732ecbbf3
commit
73fcf10250
|
@ -126,7 +126,7 @@ class VMInstance:
|
||||||
except libvirt.libvirtError as e:
|
except libvirt.libvirtError as e:
|
||||||
ansiiprint.echo('Failed to create VM', '{}:'.format(self.domuuid), '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/{}/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
|
self.dom = None
|
||||||
|
|
||||||
lv_conn.close()
|
lv_conn.close()
|
||||||
|
@ -145,13 +145,9 @@ class VMInstance:
|
||||||
self.inrestart = False
|
self.inrestart = False
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
self.shutdown_vm()
|
||||||
self.shutdown_vm()
|
self.start_vm()
|
||||||
self.start_vm()
|
self.addDomainToList()
|
||||||
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' })
|
zkhandler.writedata(self.zk_conn, { '/domains/{}/state'.format(self.domuuid): 'start' })
|
||||||
lv_conn.close()
|
lv_conn.close()
|
||||||
|
|
Loading…
Reference in New Issue