VmRowInTable dbus events moved to VmManagerWindow
Since we need to do some updates affecting all vms or the Window itself, this is a better place for handling this.
This commit is contained in:
		
							parent
							
								
									5440384142
								
							
						
					
					
						commit
						027d106507
					
				| @ -131,16 +131,6 @@ class VmRowInTable(object): | |||||||
| 
 | 
 | ||||||
|         self.table = table |         self.table = table | ||||||
| 
 | 
 | ||||||
|         #Connect dbus events |  | ||||||
|         bus = SessionBus() |  | ||||||
|         self.dbus = bus.get("org.qubes.DomainManager1" , "/org/qubes/DomainManager1/domains/" + str(vm.qid)) |  | ||||||
|         self.dbus.PropertiesChanged.connect(self.OnPropertiesChanged) |  | ||||||
| 
 |  | ||||||
|     def OnPropertiesChanged(self, dbus, properties, dump): |  | ||||||
|         for key in properties: |  | ||||||
|             if key == 'state': |  | ||||||
|                 self.update() |  | ||||||
| 
 |  | ||||||
|     def update(self, update_size_on_disk=False): |     def update(self, update_size_on_disk=False): | ||||||
|         """ |         """ | ||||||
|         Update info in a single VM row |         Update info in a single VM row | ||||||
| @ -382,10 +372,16 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): | |||||||
|         self.update_size_on_disk = False |         self.update_size_on_disk = False | ||||||
|         self.shutdown_monitor = {} |         self.shutdown_monitor = {} | ||||||
| 
 | 
 | ||||||
|  |         # Connect dbus events | ||||||
|         bus = SessionBus() |         bus = SessionBus() | ||||||
|         manager = bus.get("org.qubes.DomainManager1") |         manager = bus.get("org.qubes.DomainManager1") | ||||||
|         manager.DomainAdded.connect(self.OnDomainAdded) |         manager.DomainAdded.connect(self.OnDomainAdded) | ||||||
|         manager.DomainRemoved.connect(self.OnDomainRemoved) |         manager.DomainRemoved.connect(self.OnDomainRemoved) | ||||||
|  |         manager.Failed.connect(self.OnFailed) | ||||||
|  |         manager.Halted.connect(self.OnHalted) | ||||||
|  |         manager.Halting.connect(self.OnHalting) | ||||||
|  |         manager.Starting.connect(self.OnStarting) | ||||||
|  |         manager.Started.connect(self.OnStarted) | ||||||
| 
 | 
 | ||||||
|     def OnDomainAdded(self, manager, domain): |     def OnDomainAdded(self, manager, domain): | ||||||
|         #needs to clear cache |         #needs to clear cache | ||||||
| @ -423,6 +419,40 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): | |||||||
|         self.table.removeRow(row_index) |         self.table.removeRow(row_index) | ||||||
|         del self.vms_in_table[qid] |         del self.vms_in_table[qid] | ||||||
| 
 | 
 | ||||||
|  |     def OnFailed(self, manager, domain): | ||||||
|  |         qid = int(domain.split('/')[-1]) | ||||||
|  |         self.vms_in_table[qid].update() | ||||||
|  | 
 | ||||||
|  |     def OnHalted(self, manager, domain): | ||||||
|  |         qid = int(domain.split('/')[-1]) | ||||||
|  |         self.vms_in_table[qid].update() | ||||||
|  | 
 | ||||||
|  |         # Check if is TemplatVM and update related AppVMs | ||||||
|  |         starting_vm = self.vms_in_table[qid] | ||||||
|  |         if starting_vm.vm.klass == 'TemplateVM': | ||||||
|  |             for vm in starting_vm.vm.appvms: | ||||||
|  |                 if vm.klass == 'AppVM': | ||||||
|  |                     self.vms_in_table[vm.qid].update() | ||||||
|  | 
 | ||||||
|  |     def OnHalting(self, manager, domain): | ||||||
|  |         qid = int(domain.split('/')[-1]) | ||||||
|  |         self.vms_in_table[qid].update() | ||||||
|  | 
 | ||||||
|  |     def OnStarted(self, manager, domain): | ||||||
|  |         qid = int(domain.split('/')[-1]) | ||||||
|  |         self.vms_in_table[qid].update() | ||||||
|  | 
 | ||||||
|  |     def OnStarting(self, manager, domain): | ||||||
|  |         qid = int(domain.split('/')[-1]) | ||||||
|  |         self.vms_in_table[qid].update() | ||||||
|  | 
 | ||||||
|  |         # Check if is TemplatVM and update related AppVMs | ||||||
|  |         starting_vm = self.vms_in_table[qid] | ||||||
|  |         if starting_vm.vm.klass == 'TemplateVM': | ||||||
|  |             for vm in starting_vm.vm.appvms: | ||||||
|  |                 if vm.klass == 'AppVM': | ||||||
|  |                     self.vms_in_table[vm.qid].update() | ||||||
|  | 
 | ||||||
|     def load_manager_settings(self): |     def load_manager_settings(self): | ||||||
|         # visible columns |         # visible columns | ||||||
|         self.visible_columns_count = 0 |         self.visible_columns_count = 0 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 donoban
						donoban