mirror of
https://github.com/retspen/webvirtcloud
synced 2025-07-31 12:41:08 +00:00
Added admin application
- Manage users - Manage groups - Manage logs
This commit is contained in:
parent
38befa4362
commit
27f62dff6c
38 changed files with 933 additions and 742 deletions
|
@ -10,38 +10,37 @@ from computes.forms import ComputeAddTcpForm, ComputeAddSshForm, ComputeEditHost
|
|||
from vrtManager.hostdetails import wvmHostDetails
|
||||
from vrtManager.connection import CONN_SSH, CONN_TCP, CONN_TLS, CONN_SOCKET, connection_manager, wvmConnect
|
||||
from libvirt import libvirtError
|
||||
from admin.decorators import superuser_only
|
||||
|
||||
|
||||
@superuser_only
|
||||
def computes(request):
|
||||
"""
|
||||
:param request:
|
||||
:return:
|
||||
"""
|
||||
|
||||
if not request.user.is_superuser:
|
||||
return HttpResponseRedirect(reverse('index'))
|
||||
|
||||
def get_hosts_status(computes):
|
||||
"""
|
||||
Function return all hosts all vds on host
|
||||
"""
|
||||
compute_data = []
|
||||
for compute in computes:
|
||||
compute_data.append({'id': compute.id,
|
||||
'name': compute.name,
|
||||
'hostname': compute.hostname,
|
||||
'status': connection_manager.host_is_up(compute.type, compute.hostname),
|
||||
'type': compute.type,
|
||||
'login': compute.login,
|
||||
'password': compute.password,
|
||||
'details': compute.details
|
||||
})
|
||||
compute_data.append({
|
||||
'id': compute.id,
|
||||
'name': compute.name,
|
||||
'hostname': compute.hostname,
|
||||
'status': connection_manager.host_is_up(compute.type, compute.hostname),
|
||||
'type': compute.type,
|
||||
'login': compute.login,
|
||||
'password': compute.password,
|
||||
'details': compute.details
|
||||
})
|
||||
return compute_data
|
||||
|
||||
error_messages = []
|
||||
computes = Compute.objects.filter().order_by('name')
|
||||
computes_info = get_hosts_status(computes)
|
||||
|
||||
|
||||
if request.method == 'POST':
|
||||
if 'host_del' in request.POST:
|
||||
compute_id = request.POST.get('host_id', '')
|
||||
|
@ -133,6 +132,7 @@ def computes(request):
|
|||
return render(request, 'computes.html', locals())
|
||||
|
||||
|
||||
@superuser_only
|
||||
def overview(request, compute_id):
|
||||
"""
|
||||
:param request:
|
||||
|
@ -140,17 +140,16 @@ def overview(request, compute_id):
|
|||
:return:
|
||||
"""
|
||||
|
||||
if not request.user.is_superuser:
|
||||
return HttpResponseRedirect(reverse('index'))
|
||||
|
||||
error_messages = []
|
||||
compute = get_object_or_404(Compute, pk=compute_id)
|
||||
|
||||
try:
|
||||
conn = wvmHostDetails(compute.hostname,
|
||||
compute.login,
|
||||
compute.password,
|
||||
compute.type)
|
||||
conn = wvmHostDetails(
|
||||
compute.hostname,
|
||||
compute.login,
|
||||
compute.password,
|
||||
compute.type,
|
||||
)
|
||||
hostname, host_arch, host_memory, logical_cpu, model_cpu, uri_conn = conn.get_node_info()
|
||||
hypervisor = conn.get_hypervisors_domain_types()
|
||||
mem_usage = conn.get_memory_usage()
|
||||
|
@ -172,10 +171,12 @@ def compute_graph(request, compute_id):
|
|||
"""
|
||||
compute = get_object_or_404(Compute, pk=compute_id)
|
||||
try:
|
||||
conn = wvmHostDetails(compute.hostname,
|
||||
compute.login,
|
||||
compute.password,
|
||||
compute.type)
|
||||
conn = wvmHostDetails(
|
||||
compute.hostname,
|
||||
compute.login,
|
||||
compute.password,
|
||||
compute.type,
|
||||
)
|
||||
current_time = timezone.now().strftime("%H:%M:%S")
|
||||
cpu_usage = conn.get_cpu_usage()
|
||||
mem_usage = conn.get_memory_usage()
|
||||
|
@ -184,9 +185,11 @@ def compute_graph(request, compute_id):
|
|||
cpu_usage = {'usage': 0}
|
||||
mem_usage = {'usage': 0}
|
||||
|
||||
data = json.dumps({'cpudata': cpu_usage['usage'],
|
||||
'memdata': mem_usage,
|
||||
'timeline': current_time})
|
||||
data = json.dumps({
|
||||
'cpudata': cpu_usage['usage'],
|
||||
'memdata': mem_usage,
|
||||
'timeline': current_time,
|
||||
})
|
||||
response = HttpResponse()
|
||||
response['Content-Type'] = "text/javascript"
|
||||
response.write(data)
|
||||
|
@ -197,10 +200,12 @@ def get_compute_disk_buses(request, compute_id, arch, machine, disk):
|
|||
data = dict()
|
||||
compute = get_object_or_404(Compute, pk=compute_id)
|
||||
try:
|
||||
conn = wvmConnect(compute.hostname,
|
||||
compute.login,
|
||||
compute.password,
|
||||
compute.type)
|
||||
conn = wvmConnect(
|
||||
compute.hostname,
|
||||
compute.login,
|
||||
compute.password,
|
||||
compute.type,
|
||||
)
|
||||
|
||||
disk_device_types = conn.get_disk_device_types(arch, machine)
|
||||
|
||||
|
@ -223,10 +228,12 @@ def get_compute_machine_types(request, compute_id, arch):
|
|||
data = dict()
|
||||
try:
|
||||
compute = get_object_or_404(Compute, pk=compute_id)
|
||||
conn = wvmConnect(compute.hostname,
|
||||
compute.login,
|
||||
compute.password,
|
||||
compute.type)
|
||||
conn = wvmConnect(
|
||||
compute.hostname,
|
||||
compute.login,
|
||||
compute.password,
|
||||
compute.type,
|
||||
)
|
||||
data['machines'] = conn.get_machine_types(arch)
|
||||
except libvirtError:
|
||||
pass
|
||||
|
@ -238,10 +245,12 @@ def get_compute_video_models(request, compute_id, arch, machine):
|
|||
data = dict()
|
||||
try:
|
||||
compute = get_object_or_404(Compute, pk=compute_id)
|
||||
conn = wvmConnect(compute.hostname,
|
||||
compute.login,
|
||||
compute.password,
|
||||
compute.type)
|
||||
conn = wvmConnect(
|
||||
compute.hostname,
|
||||
compute.login,
|
||||
compute.password,
|
||||
compute.type,
|
||||
)
|
||||
data['videos'] = conn.get_video_models(arch, machine)
|
||||
except libvirtError:
|
||||
pass
|
||||
|
@ -253,10 +262,12 @@ def get_dom_capabilities(request, compute_id, arch, machine):
|
|||
data = dict()
|
||||
try:
|
||||
compute = get_object_or_404(Compute, pk=compute_id)
|
||||
conn = wvmConnect(compute.hostname,
|
||||
compute.login,
|
||||
compute.password,
|
||||
compute.type)
|
||||
conn = wvmConnect(
|
||||
compute.hostname,
|
||||
compute.login,
|
||||
compute.password,
|
||||
compute.type,
|
||||
)
|
||||
data['videos'] = conn.get_disk_device_types(arch, machine)
|
||||
data['bus'] = conn.get_disk_device_types(arch, machine)
|
||||
except libvirtError:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue