mirror of
https://github.com/ComputerScienceHouse/proxstar.git
synced 2025-02-14 22:11:51 +00:00
Open VNC session on the node that the VM belongs
Figured out why I couldn't open a session on anything but 01. It was because I was making the API call on proxmox01-nrh. So that's where the session opened. I hope that by doing this, it will balance the load (what little there is) from VNC sessions.
This commit is contained in:
parent
0b4efa9784
commit
d0af3a9567
2 changed files with 4 additions and 6 deletions
|
@ -288,7 +288,7 @@ def vm_console(vmid):
|
||||||
# import pdb; pdb.set_trace()
|
# import pdb; pdb.set_trace()
|
||||||
vm = VM(vmid)
|
vm = VM(vmid)
|
||||||
vnc_ticket, vnc_port = open_vnc_session(vmid, vm.node, app.config['PROXMOX_USER'], app.config['PROXMOX_PASS'])
|
vnc_ticket, vnc_port = open_vnc_session(vmid, vm.node, app.config['PROXMOX_USER'], app.config['PROXMOX_PASS'])
|
||||||
node = f'proxmox01-nrh.csh.rit.edu'
|
node = f'{vm.node}.csh.rit.edu'
|
||||||
token = add_vnc_target(node, vnc_port)
|
token = add_vnc_target(node, vnc_port)
|
||||||
# return {'host' : node, 'port' : vnc_port, 'token' : token, 'password' : vnc_ticket}, 200
|
# return {'host' : node, 'port' : vnc_port, 'token' : token, 'password' : vnc_ticket}, 200
|
||||||
return {'host' : app.config['VNC_HOST'], 'port' : 8081, 'token' : token, 'password' : vnc_ticket}, 200
|
return {'host' : app.config['VNC_HOST'], 'port' : 8081, 'token' : token, 'password' : vnc_ticket}, 200
|
||||||
|
|
|
@ -68,8 +68,8 @@ def open_vnc_session(vmid, node, proxmox_user, proxmox_pass):
|
||||||
Returns: Ticket to use as the noVNC password, and a port.
|
Returns: Ticket to use as the noVNC password, and a port.
|
||||||
"""
|
"""
|
||||||
# Get Proxmox API ticket and CSRF_Prevention_Token
|
# Get Proxmox API ticket and CSRF_Prevention_Token
|
||||||
# TODO: Use Proxmoxer to get this information?
|
# TODO (willnilges): Use Proxmoxer to get this information
|
||||||
# TODO: Report errors!?
|
# TODO (willnilges): Report errors
|
||||||
data = {"username": proxmox_user, "password": proxmox_pass}
|
data = {"username": proxmox_user, "password": proxmox_pass}
|
||||||
response_data = requests.post(
|
response_data = requests.post(
|
||||||
f"https://{node}.csh.rit.edu:8006/" + "api2/json/access/ticket",
|
f"https://{node}.csh.rit.edu:8006/" + "api2/json/access/ticket",
|
||||||
|
@ -82,11 +82,9 @@ def open_vnc_session(vmid, node, proxmox_user, proxmox_pass):
|
||||||
)
|
)
|
||||||
csrf_prevention_token = response_data['CSRFPreventionToken']
|
csrf_prevention_token = response_data['CSRFPreventionToken']
|
||||||
ticket = response_data['ticket']
|
ticket = response_data['ticket']
|
||||||
|
|
||||||
proxy_params = {"node": node, "vmid": str(vmid), "websocket": '1', "generate-password": '0'}
|
proxy_params = {"node": node, "vmid": str(vmid), "websocket": '1', "generate-password": '0'}
|
||||||
|
|
||||||
vncproxy_response_data = requests.post(
|
vncproxy_response_data = requests.post(
|
||||||
"https://proxmox01-nrh.csh.rit.edu:8006" + f"/api2/json/nodes/{node}/qemu/{vmid}/vncproxy",
|
f"https://{node}.csh.rit.edu:8006/api2/json/nodes/{node}/qemu/{vmid}/vncproxy",
|
||||||
verify=False,
|
verify=False,
|
||||||
timeout=5,
|
timeout=5,
|
||||||
params=proxy_params,
|
params=proxy_params,
|
||||||
|
|
Loading…
Reference in a new issue