mirror of
https://github.com/ComputerScienceHouse/proxstar.git
synced 2025-02-12 13:01:51 +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:
|
if user.rtp or int(vmid) in user.allowed_vms:
|
||||||
# import pdb; pdb.set_trace()
|
# import pdb; pdb.set_trace()
|
||||||
vm = VM(vmid)
|
vm = VM(vmid)
|
||||||
|
proxmox = connect_proxmox(f'{vm.node}.csh.rit.edu')
|
||||||
vnc_ticket, vnc_port = open_vnc_session(vmid, vm.node, proxmox)
|
vnc_ticket, vnc_port = open_vnc_session(vmid, vm.node, proxmox)
|
||||||
node = f'{vm.node}.csh.rit.edu'
|
node = f'{vm.node}.csh.rit.edu'
|
||||||
token = add_vnc_target(node, vnc_port)
|
token = add_vnc_target(node, vnc_port)
|
||||||
|
|
|
@ -6,8 +6,23 @@ from proxstar.db import get_ignored_pools
|
||||||
from proxstar.ldapdb import is_user
|
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']:
|
for host in app.config['PROXMOX_HOSTS']:
|
||||||
|
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:
|
try:
|
||||||
proxmox = ProxmoxAPI(
|
proxmox = ProxmoxAPI(
|
||||||
host,
|
host,
|
||||||
|
@ -19,9 +34,7 @@ def connect_proxmox():
|
||||||
proxmox.version.get()
|
proxmox.version.get()
|
||||||
return proxmox
|
return proxmox
|
||||||
except:
|
except:
|
||||||
if app.config['PROXMOX_HOSTS'].index(host) == (len(app.config['PROXMOX_HOSTS']) - 1):
|
return None
|
||||||
logging.error('unable to connect to any of the given Proxmox servers')
|
|
||||||
raise
|
|
||||||
|
|
||||||
|
|
||||||
def get_node_least_mem(proxmox):
|
def get_node_least_mem(proxmox):
|
||||||
|
|
Loading…
Reference in a new issue