Merge pull request #47 from bekema/main
Prevent exceptions when a node is offline
This commit is contained in:
		
						commit
						7bc5966cd6
					
				
							
								
								
									
										11
									
								
								vdiclient.py
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								vdiclient.py
									
									
									
									
									
								
							@ -164,15 +164,22 @@ def setmainlayout():
 | 
				
			|||||||
	if G.totp:
 | 
						if G.totp:
 | 
				
			||||||
		layout.append([sg.Text("OTP Key", size =(12*G.scaling, 1), font=["Helvetica", 12]), sg.InputText(key='-totp-', font=["Helvetica", 12])])
 | 
							layout.append([sg.Text("OTP Key", size =(12*G.scaling, 1), font=["Helvetica", 12]), sg.InputText(key='-totp-', font=["Helvetica", 12])])
 | 
				
			||||||
	if G.kiosk:
 | 
						if G.kiosk:
 | 
				
			||||||
		layout.append([sg.Button("Log In", font=["Helvetica", 14])])
 | 
							layout.append([sg.Button("Log In", font=["Helvetica", 14], bind_return_key=True)])
 | 
				
			||||||
	else:
 | 
						else:
 | 
				
			||||||
		layout.append([sg.Button("Log In", font=["Helvetica", 14]), sg.Button("Cancel", font=["Helvetica", 14])])
 | 
							layout.append([sg.Button("Log In", font=["Helvetica", 14], bind_return_key=True), sg.Button("Cancel", font=["Helvetica", 14])])
 | 
				
			||||||
	return layout
 | 
						return layout
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def getvms(listonly = False):
 | 
					def getvms(listonly = False):
 | 
				
			||||||
	vms = []
 | 
						vms = []
 | 
				
			||||||
	try:
 | 
						try:
 | 
				
			||||||
 | 
							nodes = []
 | 
				
			||||||
 | 
							for node in G.proxmox.cluster.resources.get(type='node'):
 | 
				
			||||||
 | 
								if node['status'] == 'online':
 | 
				
			||||||
 | 
									nodes.append(node['node'])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		for vm in G.proxmox.cluster.resources.get(type='vm'):
 | 
							for vm in G.proxmox.cluster.resources.get(type='vm'):
 | 
				
			||||||
 | 
								if vm['node'] not in nodes:
 | 
				
			||||||
 | 
									continue
 | 
				
			||||||
			if 'template' in vm and vm['template']:
 | 
								if 'template' in vm and vm['template']:
 | 
				
			||||||
				continue
 | 
									continue
 | 
				
			||||||
			if G.guest_type == 'both' or G.guest_type == vm['type']:
 | 
								if G.guest_type == 'both' or G.guest_type == vm['type']:
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user