mirror of
https://github.com/retspen/webvirtcloud
synced 2025-07-31 12:41:08 +00:00
lint with black python. convert f style strings to old one. some small fixes
This commit is contained in:
parent
c20c353a40
commit
508e3609be
54 changed files with 2123 additions and 1824 deletions
|
|
@ -5,8 +5,14 @@ from computes.models import Compute
|
|||
from django.contrib import messages
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
from libvirt import (VIR_SECRET_USAGE_TYPE_CEPH, VIR_SECRET_USAGE_TYPE_ISCSI, VIR_SECRET_USAGE_TYPE_NONE,
|
||||
VIR_SECRET_USAGE_TYPE_TLS, VIR_SECRET_USAGE_TYPE_VOLUME, libvirtError)
|
||||
from libvirt import (
|
||||
VIR_SECRET_USAGE_TYPE_CEPH,
|
||||
VIR_SECRET_USAGE_TYPE_ISCSI,
|
||||
VIR_SECRET_USAGE_TYPE_NONE,
|
||||
VIR_SECRET_USAGE_TYPE_TLS,
|
||||
VIR_SECRET_USAGE_TYPE_VOLUME,
|
||||
libvirtError,
|
||||
)
|
||||
from vrtManager.secrets import wvmSecrets
|
||||
|
||||
|
||||
|
|
@ -36,36 +42,38 @@ def secrets(request, compute_id):
|
|||
secrt = conn.get_secret(uuid)
|
||||
try:
|
||||
secrt_value = conn.get_secret_value(uuid)
|
||||
except libvirtError as lib_err:
|
||||
except libvirtError:
|
||||
secrt_value = None
|
||||
secrets_all.append({
|
||||
'usage': secrt.usageID(),
|
||||
'uuid': secrt.UUIDString(),
|
||||
'usageType': secret_usage_types[secrt.usageType()],
|
||||
'value': secrt_value
|
||||
})
|
||||
if request.method == 'POST':
|
||||
if 'create' in request.POST:
|
||||
secrets_all.append(
|
||||
{
|
||||
"usage": secrt.usageID(),
|
||||
"uuid": secrt.UUIDString(),
|
||||
"usageType": secret_usage_types[secrt.usageType()],
|
||||
"value": secrt_value,
|
||||
}
|
||||
)
|
||||
if request.method == "POST":
|
||||
if "create" in request.POST:
|
||||
form = AddSecret(request.POST)
|
||||
if form.is_valid():
|
||||
data = form.cleaned_data
|
||||
conn.create_secret(
|
||||
data['ephemeral'],
|
||||
data['private'],
|
||||
data['usage_type'],
|
||||
data['data'],
|
||||
data["ephemeral"],
|
||||
data["private"],
|
||||
data["usage_type"],
|
||||
data["data"],
|
||||
)
|
||||
return HttpResponseRedirect(request.get_full_path())
|
||||
else:
|
||||
for msg_err in form.errors.values():
|
||||
messages.error(request, msg_err.as_text())
|
||||
if 'delete' in request.POST:
|
||||
uuid = request.POST.get('uuid', '')
|
||||
if "delete" in request.POST:
|
||||
uuid = request.POST.get("uuid", "")
|
||||
conn.delete_secret(uuid)
|
||||
return HttpResponseRedirect(request.get_full_path())
|
||||
if 'set_value' in request.POST:
|
||||
uuid = request.POST.get('uuid', '')
|
||||
value = request.POST.get('value', '')
|
||||
if "set_value" in request.POST:
|
||||
uuid = request.POST.get("uuid", "")
|
||||
value = request.POST.get("value", "")
|
||||
try:
|
||||
conn.set_secret_value(uuid, value)
|
||||
except Exception as err:
|
||||
|
|
@ -74,4 +82,4 @@ def secrets(request, compute_id):
|
|||
except libvirtError as err:
|
||||
messages.error(request, err)
|
||||
|
||||
return render(request, 'secrets.html', locals())
|
||||
return render(request, "secrets.html", locals())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue