12 Commits

Author SHA1 Message Date
jpattWPC
2bac614194 Add password reset command 2023-10-13 13:42:33 -05:00
jpattWPC
3762af5d8c Bump Release 2023-10-10 09:49:20 -05:00
joshpatten
ed2b8220f1 Fully quality env path 2023-10-07 15:36:42 -05:00
jpattWPC
4a4f8df5f6 Merge pull request #72 from BrickMyPhone/main
Update vdiclient.py
2023-09-30 08:03:41 -05:00
BrickMyPhone
ff44f186c2 Update vdiclient.py
#Fixed Window sizing problem when having more than 5 VMs
2023-09-22 11:31:03 +02:00
joshpatten
e8bdbdf67c Merge pull request #54 from cinderblockgames/main
Fixing link to virt-manager.
2023-09-21 13:26:18 -05:00
joshpatten
c2fe33eda5 Merge branch 'main' into main 2023-09-21 13:26:08 -05:00
joshpatten
fb981b8a51 Merge pull request #63 from hsrzq/main
Change the python3 env path
2023-09-21 13:24:58 -05:00
jpattWPC
b32d38338b Add requests checking 2023-09-21 13:21:10 -05:00
jpattWPC
e848a938df Add window sizing option 2023-09-14 20:35:27 -05:00
TechQI
8dff999823 Change the python3 env path 2023-06-25 10:27:47 +08:00
cinderblockgames
48c1e6f9d3 Fixing link to virt-manager. 2023-03-22 23:44:40 -04:00
4 changed files with 64 additions and 39 deletions

View File

@@ -10,7 +10,7 @@ This project's focus is to create a simple VDI client intended for mass deployme
## Windows Installation ## Windows Installation
You **MUST** install virt-viewer prior to using PVE VDI client, you may download it from the [official Virtual Machine Manager](https://virt-manager.org/download) site. You **MUST** install virt-viewer prior to using PVE VDI client, you may download it from the [official Virtual Machine Manager](https://virt-manager.org/download.html) site.
Please visit the [releases](https://github.com/joshpatten/PVE-VDIClient/releases) section to download a prebuilt MSI package Please visit the [releases](https://github.com/joshpatten/PVE-VDIClient/releases) section to download a prebuilt MSI package

2
dist/vdiclient.json vendored
View File

@@ -1,6 +1,6 @@
{ {
"upgrade_guid" : "46cbad92-353e-4b28-9bee-83950991dad8", "upgrade_guid" : "46cbad92-353e-4b28-9bee-83950991dad8",
"version" : "1.2.01", "version" : "1.2.05",
"product_name" : "VDI Client", "product_name" : "VDI Client",
"manufacturer" : "Josh Patten", "manufacturer" : "Josh Patten",
"name" : "VDI Client", "name" : "VDI Client",

View File

@@ -17,6 +17,9 @@ inidebug = False
guest_type = both guest_type = both
# Show VM option for resetting VM # Show VM option for resetting VM
#show_reset = True #show_reset = True
# Set Window Dimensions. Only use if window isn't sizing properly
#window_width = 800
#window_height = 600
[Authentication] [Authentication]
# This is the authentication backend that will be used to authenticate # This is the authentication backend that will be used to authenticate
@@ -31,6 +34,8 @@ tls_verify = false
#token_name = dvi #token_name = dvi
# API Token Value # API Token Value
#token_value = xxx-x-x-x-xxx #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
[Hosts] [Hosts]
# Hosts are entered as `IP/FQDN = Port` # Hosts are entered as `IP/FQDN = Port`

View File

@@ -1,4 +1,4 @@
#!/usr/bin/python3 #!/usr/bin/env python3
import proxmoxer # pip install proxmoxer import proxmoxer # pip install proxmoxer
import PySimpleGUI as sg # pip install PySimpleGUI import PySimpleGUI as sg # pip install PySimpleGUI
gui = 'TK' gui = 'TK'
@@ -39,6 +39,9 @@ class G:
addl_params = None addl_params = None
theme = 'LightBlue' theme = 'LightBlue'
guest_type = 'both' guest_type = 'both'
width = None
height = None
pwresetcmd = None
def loadconfig(config_location = None): def loadconfig(config_location = None):
if config_location: if config_location:
@@ -100,6 +103,10 @@ def loadconfig(config_location = None):
G.guest_type = config['General']['guest_type'] G.guest_type = config['General']['guest_type']
if 'show_reset' in config['General']: if 'show_reset' in config['General']:
G.show_reset = config['General'].getboolean('show_reset') G.show_reset = config['General'].getboolean('show_reset')
if 'window_width' in config['General']:
G.width = config['General'].getint('window_width')
if 'window_height' in config['General']:
G.height = config['General'].getint('window_height')
if not 'Authentication' in config: if not 'Authentication' in config:
win_popup_button(f'Unable to read supplied configuration:\nNo `Authentication` section defined!', 'OK') win_popup_button(f'Unable to read supplied configuration:\nNo `Authentication` section defined!', 'OK')
return False return False
@@ -111,11 +118,13 @@ def loadconfig(config_location = None):
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']: if 'user' in config['Authentication']:
G.user = config['Authentication']['user'] G.user = config['Authentication']['user']
if 'token_name' in config['Authentication']: if 'token_name' in config['Authentication']:
G.token_name = config['Authentication']['token_name'] G.token_name = config['Authentication']['token_name']
if 'token_value' in config['Authentication']: if 'token_value' in config['Authentication']:
G.token_value = config['Authentication']['token_value'] G.token_value = config['Authentication']['token_value']
if 'pwresetcmd' in config['Authentication']:
G.pwresetcmd = config['Authentication']['pwresetcmd']
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
@@ -174,6 +183,8 @@ def setmainlayout():
layout.append([sg.Button("Log In", font=["Helvetica", 14], bind_return_key=True)]) layout.append([sg.Button("Log In", font=["Helvetica", 14], bind_return_key=True)])
else: else:
layout.append([sg.Button("Log In", font=["Helvetica", 14], bind_return_key=True), sg.Button("Cancel", font=["Helvetica", 14])]) layout.append([sg.Button("Log In", font=["Helvetica", 14], bind_return_key=True), sg.Button("Cancel", font=["Helvetica", 14])])
if G.pwresetcmd:
layout[-1].append(sg.Button('Password Reset', font=["Helvetica", 14]))
return layout return layout
def getvms(listonly = False): def getvms(listonly = False):
@@ -204,6 +215,9 @@ def getvms(listonly = False):
except proxmoxer.core.ResourceException as e: except proxmoxer.core.ResourceException as e:
win_popup_button(f"Unable to display list of VMs:\n {e!r}", 'OK') win_popup_button(f"Unable to display list of VMs:\n {e!r}", 'OK')
return False return False
except requests.exceptions.ConnectionError as e:
print(f"Encountered error when querying proxmox: {e!r}")
return False
def setvmlayout(vms): def setvmlayout(vms):
layout = [] layout = []
@@ -215,7 +229,6 @@ def setvmlayout(vms):
layoutcolumn = [] layoutcolumn = []
for vm in vms: for vm in vms:
if not vm["status"] == "unknown": if not vm["status"] == "unknown":
print(vm)
vmkeyname = f'-VM|{vm["vmid"]}-' vmkeyname = f'-VM|{vm["vmid"]}-'
connkeyname = f'-CONN|{vm["vmid"]}-' connkeyname = f'-CONN|{vm["vmid"]}-'
resetkeyname = f'-RESET|{vm["vmid"]}-' resetkeyname = f'-RESET|{vm["vmid"]}-'
@@ -247,7 +260,7 @@ def setvmlayout(vms):
layoutcolumn.append(tmplayout) layoutcolumn.append(tmplayout)
layoutcolumn.append([sg.HorizontalSeparator()]) layoutcolumn.append([sg.HorizontalSeparator()])
if len(vms) > 5: # We need a scrollbar if len(vms) > 5: # We need a scrollbar
layout.append([sg.Column(layoutcolumn, scrollable = True, size = [450*G.scaling, None] )]) layout.append([sg.Column(layoutcolumn, scrollable = True, size = [None, None] )])
else: else:
for row in layoutcolumn: for row in layoutcolumn:
layout.append(row) layout.append(row)
@@ -475,6 +488,11 @@ def loginwindow():
if event == 'Cancel' or event == sg.WIN_CLOSED: if event == 'Cancel' or event == sg.WIN_CLOSED:
window.close() window.close()
return False return False
elif event == 'Password Reset':
try:
subprocess.check_call(G.pwresetcmd, shell=True)
except Exception as e:
win_popup_button(f'Unable to open password reset command.\n\nError Info:\n{e}', 'OK')
else: else:
if event in ('Log In', '\r', 'special 16777220', 'special 16777221'): if event in ('Log In', '\r', 'special 16777220', 'special 16777221'):
popwin = win_popup("Please wait, authenticating...") popwin = win_popup("Please wait, authenticating...")
@@ -505,45 +523,47 @@ def showvms():
win_popup_button('No desktop instances found, please consult with your system administrator', 'OK') win_popup_button('No desktop instances found, please consult with your system administrator', 'OK')
return False return False
layout = setvmlayout(vms) layout = setvmlayout(vms)
if G.icon: if G.icon:
window = sg.Window(G.title, layout, return_keyboard_events=True, finalize=True, resizable=False, no_titlebar=G.kiosk, icon=G.icon) window = sg.Window(G.title, layout, return_keyboard_events=True, finalize=True, resizable=False, no_titlebar=G.kiosk, size=(G.width, G.height), icon=G.icon)
else: else:
window = sg.Window(G.title, layout, return_keyboard_events=True, finalize=True, resizable=False, no_titlebar=G.kiosk) window = sg.Window(G.title, layout, return_keyboard_events=True, finalize=True, resizable=False, size=(G.width, G.height), no_titlebar=G.kiosk)
timer = datetime.now() timer = datetime.now()
while True: while True:
if (datetime.now() - timer).total_seconds() > 5: if (datetime.now() - timer).total_seconds() > 5:
timer = datetime.now() timer = datetime.now()
newvmlist = getvms(listonly = True) newvmlist = getvms(listonly = True)
if vmlist != newvmlist: if newvmlist:
vmlist = newvmlist.copy() if vmlist != newvmlist:
vms = getvms() vmlist = newvmlist.copy()
layout = setvmlayout(vms) vms = getvms()
window.close() if vms:
if G.icon: layout = setvmlayout(vms)
window = sg.Window(G.title, layout, return_keyboard_events=True, finalize=True, resizable=False, no_titlebar=G.kiosk, icon=G.icon) window.close()
else: if G.icon:
window = sg.Window(G.title, layout, return_keyboard_events=True,finalize=True, resizable=False, no_titlebar=G.kiosk) window = sg.Window(G.title, layout, return_keyboard_events=True, finalize=True, resizable=False, no_titlebar=G.kiosk, size=(G.width, G.height), icon=G.icon)
window.bring_to_front()
else: # Refresh existing vm status
newvms = getvms()
for vm in newvms:
vmkeyname = f'-VM|{vm["vmid"]}-'
connkeyname = f'-CONN|{vm["vmid"]}-'
state = 'stopped'
if vm['status'] == 'running':
if 'lock' in vm:
state = vm['lock']
if state in ('suspending', 'suspended'):
window[connkeyname].update(disabled=True)
if state == 'suspended':
state = 'starting'
else: else:
state = vm['status'] window = sg.Window(G.title, layout, return_keyboard_events=True,finalize=True, resizable=False, no_titlebar=G.kiosk, size=(G.width, G.height))
window[connkeyname].update(disabled=False) window.bring_to_front()
else: else: # Refresh existing vm status
window[connkeyname].update(disabled=False) newvms = getvms()
window[vmkeyname].update(f"State: {state}") if newvms:
for vm in newvms:
vmkeyname = f'-VM|{vm["vmid"]}-'
connkeyname = f'-CONN|{vm["vmid"]}-'
state = 'stopped'
if vm['status'] == 'running':
if 'lock' in vm:
state = vm['lock']
if state in ('suspending', 'suspended'):
window[connkeyname].update(disabled=True)
if state == 'suspended':
state = 'starting'
else:
state = vm['status']
window[connkeyname].update(disabled=False)
else:
window[connkeyname].update(disabled=False)
window[vmkeyname].update(f"State: {state}")
event, values = window.read(timeout = 1000) event, values = window.read(timeout = 1000)
if event in ('Logout', None): if event in ('Logout', None):