Print message indenting fixes
This commit is contained in:
parent
6a1b282bfd
commit
fe52d3815c
|
@ -82,7 +82,7 @@ class NodeInstance(threading.Thread):
|
||||||
libvirt_name = "qemu:///system"
|
libvirt_name = "qemu:///system"
|
||||||
conn = libvirt.open(libvirt_name)
|
conn = libvirt.open(libvirt_name)
|
||||||
if conn == None:
|
if conn == None:
|
||||||
print('Failed to open connection to %s' % libvirt_name)
|
print('>>> Failed to open connection to %s' % libvirt_name)
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
# Gather data about hypervisor
|
# Gather data about hypervisor
|
||||||
|
|
|
@ -18,7 +18,7 @@ class VMInstance:
|
||||||
libvirt_name = "qemu:///system"
|
libvirt_name = "qemu:///system"
|
||||||
conn = libvirt.open(libvirt_name)
|
conn = libvirt.open(libvirt_name)
|
||||||
if conn == None:
|
if conn == None:
|
||||||
print('Failed to open local libvirt connection.')
|
print('>>> Failed to open local libvirt connection.')
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -50,11 +50,11 @@ class VMInstance:
|
||||||
|
|
||||||
# Start up the VM
|
# Start up the VM
|
||||||
def start_vm(self, conn, xmlconfig):
|
def start_vm(self, conn, xmlconfig):
|
||||||
print("Starting VM %s" % self.domuuid)
|
print(">>> Starting VM %s" % self.domuuid)
|
||||||
try:
|
try:
|
||||||
dom = conn.createXML(xmlconfig, 0)
|
dom = conn.createXML(xmlconfig, 0)
|
||||||
except libvirt.libvirtError as e:
|
except libvirt.libvirtError as e:
|
||||||
print('Failed to create domain %s' % self.domuuid)
|
print('>>> Failed to create domain %s' % self.domuuid)
|
||||||
self.zk.set(self.zkey + '/state', 'stop'.encode('ascii'))
|
self.zk.set(self.zkey + '/state', 'stop'.encode('ascii'))
|
||||||
|
|
||||||
if not self.domuuid in self.thishypervisor.domain_list:
|
if not self.domuuid in self.thishypervisor.domain_list:
|
||||||
|
@ -64,7 +64,7 @@ class VMInstance:
|
||||||
|
|
||||||
# Stop the VM forcibly
|
# Stop the VM forcibly
|
||||||
def stop_vm(self):
|
def stop_vm(self):
|
||||||
print("Forcibly stopping VM %s" % self.domuuid)
|
print(">>> Forcibly stopping VM %s" % self.domuuid)
|
||||||
self.dom.destroy()
|
self.dom.destroy()
|
||||||
if self.domuuid in self.thishypervisor.domain_list:
|
if self.domuuid in self.thishypervisor.domain_list:
|
||||||
try:
|
try:
|
||||||
|
@ -76,7 +76,7 @@ class VMInstance:
|
||||||
|
|
||||||
# Shutdown the VM gracefully
|
# Shutdown the VM gracefully
|
||||||
def shutdown_vm(self):
|
def shutdown_vm(self):
|
||||||
print("Stopping VM %s" % self.domuuid)
|
print(">>> Stopping VM %s" % self.domuuid)
|
||||||
self.dom.shutdown()
|
self.dom.shutdown()
|
||||||
while self.dom.state()[0] == libvirt.VIR_DOMAIN_RUNNING:
|
while self.dom.state()[0] == libvirt.VIR_DOMAIN_RUNNING:
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
@ -91,7 +91,6 @@ class VMInstance:
|
||||||
|
|
||||||
# Migrate the VM to a target host
|
# Migrate the VM to a target host
|
||||||
def migrate_vm(self):
|
def migrate_vm(self):
|
||||||
print(self.zkey)
|
|
||||||
self.zk.set(self.zkey + '/state', 'migrate'.encode('ascii'))
|
self.zk.set(self.zkey + '/state', 'migrate'.encode('ascii'))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -99,7 +98,7 @@ class VMInstance:
|
||||||
if dest_conn == None:
|
if dest_conn == None:
|
||||||
raise
|
raise
|
||||||
except:
|
except:
|
||||||
print('Failed to open connection to qemu+ssh://%s/system' % target)
|
print('>>> Failed to open connection to qemu+ssh://%s/system' % target)
|
||||||
self.zk.set(self.zkey + '/state', 'start'.encode('ascii'))
|
self.zk.set(self.zkey + '/state', 'start'.encode('ascii'))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -107,9 +106,9 @@ class VMInstance:
|
||||||
target_dom = self.dom.migrate(dest_conn, libvirt.VIR_MIGRATE_LIVE, None, None, 0)
|
target_dom = self.dom.migrate(dest_conn, libvirt.VIR_MIGRATE_LIVE, None, None, 0)
|
||||||
if target_dom == None:
|
if target_dom == None:
|
||||||
raise
|
raise
|
||||||
print('Migrated successfully')
|
print('>>> Migrated successfully')
|
||||||
except:
|
except:
|
||||||
print('Could not migrate to the new domain; forcing away uncleanly')
|
print('>>> Could not migrate to the new domain; forcing away uncleanly')
|
||||||
self.stop_vm()
|
self.stop_vm()
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
self.zk.set(self.zkey + '/state', 'start'.encode('ascii'))
|
self.zk.set(self.zkey + '/state', 'start'.encode('ascii'))
|
||||||
|
@ -143,7 +142,7 @@ class VMInstance:
|
||||||
libvirt_name = "qemu:///system"
|
libvirt_name = "qemu:///system"
|
||||||
conn = libvirt.open(libvirt_name)
|
conn = libvirt.open(libvirt_name)
|
||||||
if conn == None:
|
if conn == None:
|
||||||
print('Failed to open local libvirt connection.')
|
print('>>> Failed to open local libvirt connection.')
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
# Check the current state of the VM
|
# Check the current state of the VM
|
||||||
|
|
Loading…
Reference in New Issue