added ability for user to eject and change iso

This commit is contained in:
Jordan Rodgers 2017-12-06 18:59:44 -05:00
parent ba36af7dd5
commit dd98c600e2
5 changed files with 171 additions and 17 deletions

27
app.py
View file

@ -35,6 +35,12 @@ def list_vms():
return render_template('list_vms.html', username='com6056', vms=vms)
@app.route("/isos")
def isos():
isos = get_isos(proxmox, app.config['PROXMOX_ISO_STORAGE'])
return ','.join(isos)
@app.route("/vm/<string:vmid>")
def vm_details(vmid):
if int(vmid) in get_user_allowed_vms(proxmox, user):
@ -42,7 +48,7 @@ def vm_details(vmid):
vm['vmid'] = vmid
vm['config'] = get_vm_config(proxmox, vmid)
vm['disks'] = get_vm_disks(proxmox, vmid, config=vm['config'])
vm['isos'] = get_vm_isos(proxmox, vmid, config=vm['config'])
vm['iso'] = get_vm_iso(proxmox, vmid, config=vm['config'])
vm['interfaces'] = get_vm_interfaces(
proxmox, vm['vmid'], config=vm['config'])
return render_template('vm_details.html', username='com6056', vm=vm)
@ -59,6 +65,25 @@ def vm_power(vmid, action):
return '', 403
@app.route("/vm/<string:vmid>/eject", methods=['POST'])
def iso_eject(vmid):
if int(vmid) in get_user_allowed_vms(proxmox, user):
eject_vm_iso(proxmox, vmid)
return '', 200
else:
return '', 403
@app.route("/vm/<string:vmid>/mount/<string:iso>", methods=['POST'])
def iso_mount(vmid, iso):
if int(vmid) in get_user_allowed_vms(proxmox, user):
iso = "{}:iso/{}".format(app.config['PROXMOX_ISO_STORAGE'], iso)
mount_vm_iso(proxmox, vmid, iso)
return '', 200
else:
return '', 403
@app.route("/vm/<string:vmid>/delete", methods=['POST'])
def delete(vmid):
if int(vmid) in get_user_allowed_vms(proxmox, user):