Add ability to auto-connect VMID
This commit is contained in:
		
							parent
							
								
									2bac614194
								
							
						
					
					
						commit
						cd83be7680
					
				@ -36,6 +36,8 @@ tls_verify = false
 | 
			
		||||
#token_value = xxx-x-x-x-xxx
 | 
			
		||||
# Password Reset Command Launch. Has to be full executable Command
 | 
			
		||||
#pwresetcmd = start chrome --app=http://pwreset.example.com
 | 
			
		||||
# Automatically connect to a VMID upon authentication
 | 
			
		||||
#auto_vmid = 100
 | 
			
		||||
 | 
			
		||||
[Hosts]
 | 
			
		||||
# Hosts are entered as `IP/FQDN = Port`
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										10
									
								
								vdiclient.py
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								vdiclient.py
									
									
									
									
									
								
							@ -42,6 +42,7 @@ class G:
 | 
			
		||||
	width = None
 | 
			
		||||
	height = None
 | 
			
		||||
	pwresetcmd = None
 | 
			
		||||
	auto_vmid = None
 | 
			
		||||
 | 
			
		||||
def loadconfig(config_location = None):
 | 
			
		||||
	if config_location:
 | 
			
		||||
@ -125,6 +126,8 @@ def loadconfig(config_location = None):
 | 
			
		||||
			G.token_value = config['Authentication']['token_value']
 | 
			
		||||
		if 'pwresetcmd' in config['Authentication']:
 | 
			
		||||
			G.pwresetcmd = config['Authentication']['pwresetcmd']
 | 
			
		||||
		if 'auto_vmid' in config['Authentication']:
 | 
			
		||||
			G.auto_vmid = config['Authentication'].getint('auto_vmid')
 | 
			
		||||
	if not 'Hosts' in config:
 | 
			
		||||
		win_popup_button(f'Unable to read supplied configuration:\nNo `Hosts` section defined!', 'OK')
 | 
			
		||||
		return False
 | 
			
		||||
@ -617,6 +620,13 @@ def main():
 | 
			
		||||
					return 1
 | 
			
		||||
				break
 | 
			
		||||
			else:
 | 
			
		||||
				if G.auto_vmid:
 | 
			
		||||
					vms = getvms()
 | 
			
		||||
					for row in vms:
 | 
			
		||||
						if row['vmid'] == G.auto_vmid:
 | 
			
		||||
							vmaction(row['node'], row['vmid'], row['type'], action='connect')
 | 
			
		||||
							return 0
 | 
			
		||||
					win_popup_button(f'No VDI instance with ID {G.auto_vmid} found!', 'OK')
 | 
			
		||||
				vmstat = showvms()
 | 
			
		||||
				if not vmstat:
 | 
			
		||||
					G.proxmox = None
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user