1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-12-23 22:55:23 +00:00

add get_volumes function to view. And Remove unused 'get' artifact.

This commit is contained in:
catborise 2018-11-16 16:04:26 +03:00
parent 5b60dd7f84
commit 91f01d884b

View file

@ -205,12 +205,23 @@ def storage(request, compute_id, pool):
else:
for msg_err in form.errors.values():
error_messages.append(msg_err.as_text())
if request.method == 'GET':
if 'get_volumes' in request.GET:
conn.close()
return HttpResponse(json.dumps(sorted(volumes)))
conn.close()
return render(request, 'storage.html', locals())
@login_required
def get_volumes(request, compute_id, pool):
data = {}
compute = get_object_or_404(Compute, pk=compute_id)
try:
conn = wvmStorage(compute.hostname,
compute.login,
compute.password,
compute.type,
pool)
except libvirtError as liberr:
pass
data['vols'] = sorted(conn.get_volumes())
return HttpResponse(json.dumps(data))