More bugfixes
This commit is contained in:
parent
3827261cc9
commit
75efefada3
|
@ -99,6 +99,7 @@ class VMInstance:
|
|||
except ValueError:
|
||||
pass
|
||||
ansiiprint.echo('Successfully terminated VM', '{}:'.format(self.domuuid), 'o')
|
||||
self.dom = None
|
||||
self.instop = False
|
||||
|
||||
# Stop the VM forcibly
|
||||
|
@ -251,11 +252,11 @@ class VMInstance:
|
|||
return 0
|
||||
|
||||
# VM should be stopped
|
||||
if running == libvirt.VIR_DOMAIN_RUNNING and self.state == "stop" and self.hypervisor == self.thishypervisor.name:
|
||||
if running == libvirt.VIR_DOMAIN_RUNNING and self.state == "stop" and self.hypervisor == self.thishypervisor.name and self.dom != None:
|
||||
self.stop_vm()
|
||||
|
||||
# VM should be shut down
|
||||
elif running == libvirt.VIR_DOMAIN_RUNNING and self.state == "shutdown" and self.hypervisor == self.thishypervisor.name:
|
||||
elif running == libvirt.VIR_DOMAIN_RUNNING and self.state == "shutdown" and self.hypervisor == self.thishypervisor.name and self.dom != None:
|
||||
self.shutdown_vm()
|
||||
|
||||
# VM should be migrated to this hypervisor
|
||||
|
@ -263,11 +264,11 @@ class VMInstance:
|
|||
self.receive_migrate()
|
||||
|
||||
# VM should be migrated away from this hypervisor
|
||||
elif running == libvirt.VIR_DOMAIN_RUNNING and self.state == "migrate" and self.hypervisor != self.thishypervisor.name:
|
||||
elif running == libvirt.VIR_DOMAIN_RUNNING and self.state == "migrate" and self.hypervisor != self.thishypervisor.name and self.dom != None:
|
||||
self.migrate_vm()
|
||||
|
||||
# VM should be running but not on this hypervisor
|
||||
elif running == libvirt.VIR_DOMAIN_RUNNING and self.state != "migrate" and self.hypervisor != self.thishypervisor.name:
|
||||
elif running == libvirt.VIR_DOMAIN_RUNNING and self.state != "migrate" and self.hypervisor != self.thishypervisor.name and self.dom != None:
|
||||
self.terminate_vm()
|
||||
|
||||
# VM is already running and should be
|
||||
|
|
16
pvc.py
16
pvc.py
|
@ -867,7 +867,8 @@ def _vm_list(hypervisor):
|
|||
# Open a Zookeeper connection
|
||||
zk = pvcf.startZKConnection(zk_host)
|
||||
|
||||
vm_list = zk.get_children('/domains')
|
||||
vm_list_raw = zk.get_children('/domains')
|
||||
vm_list = []
|
||||
vm_list_output = []
|
||||
|
||||
vm_hypervisor = {}
|
||||
|
@ -878,13 +879,18 @@ def _vm_list(hypervisor):
|
|||
vm_memory = {}
|
||||
vm_vcpu = {}
|
||||
|
||||
# Gather information for printing
|
||||
for vm in vm_list:
|
||||
# If we're limited, remove other nodes' VMs
|
||||
for vm in vm_list_raw:
|
||||
# Check hypervisor to avoid unneeded ZK calls
|
||||
vm_hypervisor[vm] = zk.get('/domains/{}/hypervisor'.format(vm))[0].decode('ascii')
|
||||
if hypervisor != None and vm_hypervisor[vm] != hypervisor:
|
||||
continue
|
||||
if hypervisor != None:
|
||||
if vm_hypervisor[vm] == hypervisor:
|
||||
vm_list.append(vm)
|
||||
else:
|
||||
vm_list.append(vm)
|
||||
|
||||
# Gather information for printing
|
||||
for vm in vm_list:
|
||||
vm_state[vm] = zk.get('/domains/{}/state'.format(vm))[0].decode('ascii')
|
||||
vm_lasthypervisor = zk.get('/domains/{}/lasthypervisor'.format(vm))[0].decode('ascii')
|
||||
if vm_lasthypervisor != '':
|
||||
|
|
Loading…
Reference in New Issue