mirror of
				https://github.com/ComputerScienceHouse/proxstar.git
				synced 2025-03-09 15:40:09 +00:00 
			
		
		
		
	Use correct node in API call
This commit is contained in:
		
							parent
							
								
									5ca4d710bb
								
							
						
					
					
						commit
						c8331b66d2
					
				
					 2 changed files with 29 additions and 15 deletions
				
			
		|  | @ -335,6 +335,7 @@ def vm_console(vmid): | |||
|     if user.rtp or int(vmid) in user.allowed_vms: | ||||
|         # import pdb; pdb.set_trace() | ||||
|         vm = VM(vmid) | ||||
|         proxmox = connect_proxmox(f'{vm.node}.csh.rit.edu') | ||||
|         vnc_ticket, vnc_port = open_vnc_session(vmid, vm.node, proxmox) | ||||
|         node = f'{vm.node}.csh.rit.edu' | ||||
|         token = add_vnc_target(node, vnc_port) | ||||
|  |  | |||
|  | @ -6,22 +6,35 @@ from proxstar.db import get_ignored_pools | |||
| from proxstar.ldapdb import is_user | ||||
| 
 | ||||
| 
 | ||||
| def connect_proxmox(): | ||||
| def connect_proxmox(host=None): | ||||
|     if host: | ||||
|         attempted_connection = attempt_proxmox_connection(host) | ||||
|         if attempted_connection: | ||||
|             return attempted_connection | ||||
|         logging.error(f'unable to connect to {host}') | ||||
|         raise | ||||
| 
 | ||||
|     for host in app.config['PROXMOX_HOSTS']: | ||||
|         try: | ||||
|             proxmox = ProxmoxAPI( | ||||
|                 host, | ||||
|                 user=app.config['PROXMOX_USER'], | ||||
|                 token_name=app.config['PROXMOX_TOKEN_NAME'], | ||||
|                 token_value=app.config['PROXMOX_TOKEN_VALUE'], | ||||
|                 verify_ssl=False, | ||||
|             ) | ||||
|             proxmox.version.get() | ||||
|             return proxmox | ||||
|         except: | ||||
|             if app.config['PROXMOX_HOSTS'].index(host) == (len(app.config['PROXMOX_HOSTS']) - 1): | ||||
|                 logging.error('unable to connect to any of the given Proxmox servers') | ||||
|                 raise | ||||
|         attempted_connection = attempt_proxmox_connection(host) | ||||
|         if attempted_connection: | ||||
|             return attempted_connection | ||||
|     logging.error('unable to connect to any of the given Proxmox servers') | ||||
|     raise | ||||
| 
 | ||||
| 
 | ||||
| def attempt_proxmox_connection(host): | ||||
|     try: | ||||
|         proxmox = ProxmoxAPI( | ||||
|             host, | ||||
|             user=app.config['PROXMOX_USER'], | ||||
|             token_name=app.config['PROXMOX_TOKEN_NAME'], | ||||
|             token_value=app.config['PROXMOX_TOKEN_VALUE'], | ||||
|             verify_ssl=False, | ||||
|         ) | ||||
|         proxmox.version.get() | ||||
|         return proxmox | ||||
|     except: | ||||
|         return None | ||||
| 
 | ||||
| 
 | ||||
| def get_node_least_mem(proxmox): | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue