commit
4e251c31cb
@ -17,6 +17,12 @@ auth_backend = pve
|
|||||||
auth_totp = false
|
auth_totp = false
|
||||||
# If disabled, TLS certificate will not be checked
|
# If disabled, TLS certificate will not be checked
|
||||||
tls_verify = false
|
tls_verify = false
|
||||||
|
# User name
|
||||||
|
#user = user
|
||||||
|
# API Token Name
|
||||||
|
#token_name = dvi
|
||||||
|
#API Token Value
|
||||||
|
#token_value = xxx-x-x-x-xxx
|
||||||
|
|
||||||
[Hosts]
|
[Hosts]
|
||||||
# Hosts are entered as `IP/FQDN = Port`
|
# Hosts are entered as `IP/FQDN = Port`
|
||||||
|
24
vdiclient.py
24
vdiclient.py
@ -19,6 +19,9 @@ class G:
|
|||||||
#########
|
#########
|
||||||
title = 'VDI Login'
|
title = 'VDI Login'
|
||||||
backend = 'pve'
|
backend = 'pve'
|
||||||
|
user = ""
|
||||||
|
token_name = None
|
||||||
|
token_value = None
|
||||||
totp = False
|
totp = False
|
||||||
imagefile = None
|
imagefile = None
|
||||||
kiosk = False
|
kiosk = False
|
||||||
@ -85,6 +88,12 @@ def loadconfig(config_location = None):
|
|||||||
G.totp = config['Authentication'].getboolean('auth_totp')
|
G.totp = config['Authentication'].getboolean('auth_totp')
|
||||||
if 'tls_verify' in config['Authentication']:
|
if 'tls_verify' in config['Authentication']:
|
||||||
G.verify_ssl = config['Authentication'].getboolean('tls_verify')
|
G.verify_ssl = config['Authentication'].getboolean('tls_verify')
|
||||||
|
if 'user' in config['Authentication']:
|
||||||
|
G.user = config['Authentication']['user']
|
||||||
|
if 'token_name' in config['Authentication']:
|
||||||
|
G.token_name = config['Authentication']['token_name']
|
||||||
|
if 'token_value' in config['Authentication']:
|
||||||
|
G.token_value = config['Authentication']['token_value']
|
||||||
if not 'Hosts' in config:
|
if not 'Hosts' in config:
|
||||||
win_popup_button(f'Unable to read supplied configuration:\nNo `Hosts` section defined!', 'OK')
|
win_popup_button(f'Unable to read supplied configuration:\nNo `Hosts` section defined!', 'OK')
|
||||||
return False
|
return False
|
||||||
@ -123,7 +132,7 @@ def setmainlayout():
|
|||||||
layout.append([sg.Image(G.imagefile), sg.Text(G.title, size =(18, 1), justification='c', font=["Helvetica", 18])])
|
layout.append([sg.Image(G.imagefile), sg.Text(G.title, size =(18, 1), justification='c', font=["Helvetica", 18])])
|
||||||
else:
|
else:
|
||||||
layout.append([sg.Text(G.title, size =(30, 1), justification='c', font=["Helvetica", 18])])
|
layout.append([sg.Text(G.title, size =(30, 1), justification='c', font=["Helvetica", 18])])
|
||||||
layout.append([sg.Text("Username", size =(12, 1), font=["Helvetica", 12]), sg.InputText(key='-username-', font=["Helvetica", 12])])
|
layout.append([sg.Text("Username", size =(12, 1), font=["Helvetica", 12]), sg.InputText(default_text=G.user,key='-username-', font=["Helvetica", 12])])
|
||||||
layout.append([sg.Text("Password", size =(12, 1),font=["Helvetica", 12]), sg.InputText(key='-password-', password_char='*', font=["Helvetica", 12])])
|
layout.append([sg.Text("Password", size =(12, 1),font=["Helvetica", 12]), sg.InputText(key='-password-', password_char='*', font=["Helvetica", 12])])
|
||||||
|
|
||||||
if G.totp:
|
if G.totp:
|
||||||
@ -148,9 +157,10 @@ def setvmlayout(vms):
|
|||||||
layout.append([sg.Text(G.title, size =(30, 1), justification='c', font=["Helvetica", 18])])
|
layout.append([sg.Text(G.title, size =(30, 1), justification='c', font=["Helvetica", 18])])
|
||||||
layout.append([sg.Text('Please select a desktop instance to connect to', size =(40, 1), justification='c', font=["Helvetica", 10])])
|
layout.append([sg.Text('Please select a desktop instance to connect to', size =(40, 1), justification='c', font=["Helvetica", 10])])
|
||||||
for vm in vms:
|
for vm in vms:
|
||||||
connkeyname = f'-CONN|{vm["vmid"]}-'
|
if not vm["status"] == "unknown":
|
||||||
layout.append([sg.Text(vm['name'], font=["Helvetica", 14]), sg.Button('Connect', font=["Helvetica", 14], key=connkeyname)])
|
connkeyname = f'-CONN|{vm["vmid"]}-'
|
||||||
layout.append([sg.HorizontalSeparator()])
|
layout.append([sg.Text(vm['name'], font=["Helvetica", 14]), sg.Button('Connect', font=["Helvetica", 14], key=connkeyname)])
|
||||||
|
layout.append([sg.HorizontalSeparator()])
|
||||||
layout.append([sg.Button('Logout', font=["Helvetica", 14])])
|
layout.append([sg.Button('Logout', font=["Helvetica", 14])])
|
||||||
return layout
|
return layout
|
||||||
|
|
||||||
@ -210,7 +220,7 @@ def vmaction(vmnode, vmid, vmtype):
|
|||||||
confignode.write(inifile)
|
confignode.write(inifile)
|
||||||
inifile.seek(0)
|
inifile.seek(0)
|
||||||
inistring = inifile.read()
|
inistring = inifile.read()
|
||||||
pcmd = [G.cmd]
|
pcmd = [G.vvcmd]
|
||||||
if G.kiosk:
|
if G.kiosk:
|
||||||
pcmd.append('--kiosk')
|
pcmd.append('--kiosk')
|
||||||
pcmd.append('--kiosk-quit')
|
pcmd.append('--kiosk-quit')
|
||||||
@ -264,7 +274,9 @@ def pveauth(username, passwd, totp):
|
|||||||
authenticated = False
|
authenticated = False
|
||||||
if not connected and not authenticated:
|
if not connected and not authenticated:
|
||||||
try:
|
try:
|
||||||
if totp:
|
if G.token_name and G.token_value:
|
||||||
|
G.proxmox = proxmoxer.ProxmoxAPI(host, user=f'{username}@{G.backend}',token_name=G.token_name,token_value=G.token_value, verify_ssl=G.verify_ssl, port=port)
|
||||||
|
elif totp:
|
||||||
G.proxmox = proxmoxer.ProxmoxAPI(host, user=f'{username}@{G.backend}', otp=totp, password=passwd, verify_ssl=G.verify_ssl, port=port)
|
G.proxmox = proxmoxer.ProxmoxAPI(host, user=f'{username}@{G.backend}', otp=totp, password=passwd, verify_ssl=G.verify_ssl, port=port)
|
||||||
else:
|
else:
|
||||||
G.proxmox = proxmoxer.ProxmoxAPI(host, user=f'{username}@{G.backend}', password=passwd, verify_ssl=G.verify_ssl, port=port)
|
G.proxmox = proxmoxer.ProxmoxAPI(host, user=f'{username}@{G.backend}', password=passwd, verify_ssl=G.verify_ssl, port=port)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user