本文整理汇总了Python中vrtManager.hostdetails.wvmHostDetails函数的典型用法代码示例。如果您正苦于以下问题:Python wvmHostDetails函数的具体用法?Python wvmHostDetails怎么用?Python wvmHostDetails使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wvmHostDetails函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: overview
def overview(request, host_id):
"""
Overview page.
"""
if not request.user.is_authenticated():
return HttpResponseRedirect('/login')
errors = []
time_refresh = TIME_JS_REFRESH
compute = Compute.objects.get(id=host_id)
try:
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.hypervisor_type()
mem_usage = conn.get_memory_usage()
conn.close()
except libvirtError as err:
errors.append(err)
return render_to_response('hostdetail.html', locals(), context_instance=RequestContext(request))
示例2: compute_graph
def compute_graph(request, compute_id):
"""
:param request:
:return:
"""
points = 5
datasets = {}
cookies = {}
compute = get_object_or_404(Compute, pk=compute_id)
curent_time = time.strftime("%H:%M:%S")
try:
conn = wvmHostDetails(compute.hostname,
compute.login,
compute.password,
compute.type)
cpu_usage = conn.get_cpu_usage()
mem_usage = conn.get_memory_usage()
conn.close()
except libvirtError:
cpu_usage = 0
mem_usage = 0
try:
cookies['cpu'] = request.COOKIES['cpu']
cookies['mem'] = request.COOKIES['mem']
cookies['timer'] = request.COOKIES['timer']
except KeyError:
cookies['cpu'] = None
cookies['mem'] = None
if not cookies['cpu'] or not cookies['mem']:
datasets['cpu'] = [0] * points
datasets['mem'] = [0] * points
datasets['timer'] = [0] * points
else:
datasets['cpu'] = eval(cookies['cpu'])
datasets['mem'] = eval(cookies['mem'])
datasets['timer'] = eval(cookies['timer'])
datasets['timer'].append(curent_time)
datasets['cpu'].append(int(cpu_usage['usage']))
datasets['mem'].append(int(mem_usage['usage']) / 1048576)
if len(datasets['timer']) > points:
datasets['timer'].pop(0)
if len(datasets['cpu']) > points:
datasets['cpu'].pop(0)
if len(datasets['mem']) > points:
datasets['mem'].pop(0)
data = json.dumps({'cpudata': datasets['cpu'], 'memdata': datasets['mem'], 'timeline': datasets['timer']})
response = HttpResponse()
response['Content-Type'] = "text/javascript"
response.cookies['cpu'] = datasets['cpu']
response.cookies['timer'] = datasets['timer']
response.cookies['mem'] = datasets['mem']
response.write(data)
return response
示例3: infrastructure
def infrastructure(request):
"""
Infrastructure page.
"""
if not request.user.is_authenticated():
return HttpResponseRedirect(reverse('login'))
if not request.user.is_staff:
raise PermissionDenied
compute = Compute.objects.filter()
hosts_vms = {}
for host in compute:
status = connection_manager.host_is_up(host.type, host.hostname)
if status:
try:
conn = wvmHostDetails(host, host.login, host.password,
host.type, host.hypervisor)
host_info = conn.get_node_info()
host_mem = conn.get_memory_usage()
hosts_vms[host.id, host.name, status, host_info[3], host_info[2],
host_mem['percent']] = conn.get_host_instances()
conn.close()
except libvirtError:
hosts_vms[host.id, host.name, status, 0, 0, 0] = None
else:
hosts_vms[host.id, host.name, 2, 0, 0, 0] = None
return render_to_response('infrastructure.html', locals(), context_instance=RequestContext(request))
示例4: overview
def overview(request, compute_id):
"""
:param request:
: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)
hostname, host_arch, host_memory, logical_cpu, model_cpu, uri_conn = conn.get_node_info()
hypervisor = conn.hypervisor_type()
mem_usage = conn.get_memory_usage()
conn.close()
except libvirtError as lib_err:
error_messages.append(lib_err)
return render(request, 'overview.html', locals())
示例5: memusage
def memusage(request, host_id):
"""
Return Memory Usage in % and numeric
"""
if not request.user.is_authenticated():
return HttpResponseRedirect('/login')
datasets = []
compute = Compute.objects.get(id=host_id)
try:
conn = wvmHostDetails(compute.hostname,
compute.login,
compute.password,
compute.type)
mem_usage = conn.get_memory_usage()
conn.close()
except libvirtError:
mem_usage = 0
try:
cookies = request._cookies['memory_usage']
except KeyError:
cookies = None
if not cookies:
datasets.append(0)
else:
datasets = eval(cookies)
if len(datasets) > 10:
while datasets:
del datasets[0]
if len(datasets) == 10:
break
if len(datasets) <= 9:
datasets.append(int(mem_usage['usage']) / 1048576)
if len(datasets) == 10:
datasets.append(int(mem_usage['usage']) / 1048576)
del datasets[0]
memory = {
'labels': [""] * 10,
'datasets': [
{
"fillColor": "rgba(249,134,33,0.5)",
"strokeColor": "rgba(249,134,33,1)",
"pointColor": "rgba(249,134,33,1)",
"pointStrokeColor": "#fff",
"data": datasets
}
]
}
data = simplejson.dumps(memory)
response = HttpResponse()
response['Content-Type'] = "text/javascript"
response.cookies['memory_usage'] = datasets
response.write(data)
return response
示例6: infrastructure
def infrastructure(request):
"""
Infrastructure page.
"""
if not request.user.is_authenticated():
return HttpResponseRedirect('/login')
compute = Compute.objects.filter()
hosts_vms = {}
for host in compute:
try:
socket_host = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
socket_host.settimeout(1)
if host.type == CONN_SSH:
if ':' in host.hostname:
LIBVIRT_HOST, PORT = (host.hostname).split(":")
PORT = int(PORT)
else:
PORT = SSH_PORT
LIBVIRT_HOST = host.hostname
socket_host.connect((LIBVIRT_HOST, PORT))
if host.type == CONN_TCP:
socket_host.connect((host.hostname, TCP_PORT))
if host.type == CONN_TLS:
socket_host.connect((host.hostname, TLS_PORT))
socket_host.close()
status = 1
except Exception:
status = 2
if status == 1:
try:
conn = wvmHostDetails(host, host.login, host.password, host.type)
host_info = conn.get_node_info()
host_mem = conn.get_memory_usage()
hosts_vms[host.id, host.name, status, host_info[3], host_info[2],
host_mem['percent']] = conn.get_host_instances()
conn.close()
except libvirtError:
hosts_vms[host.id, host.name, 3, 0, 0, 0] = None
else:
hosts_vms[host.id, host.name, status, 0, 0, 0] = None
return render_to_response('infrastructure.html', locals(), context_instance=RequestContext(request))
示例7: overview
def overview(request, host_id):
"""
Overview page.
"""
errors = []
time_refresh = TIME_JS_REFRESH
compute = Compute.objects.get(id=host_id)
try:
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.hypervisor_type()
mem_usage = conn.get_memory_usage()
conn.close()
except libvirtError as err:
errors.append(err)
return render(None, 'hostdetail.html', locals(), request)
示例8: infrastructure
def infrastructure(request):
"""
Infrastructure page.
"""
compute = Compute.objects.filter()
hosts_vms = {}
for host in compute:
if connection_manager.host_is_up(host.hostname, host.login, host.password, host.type):
try:
conn = wvmHostDetails(host, host.login, host.password, host.type)
host_info = conn.get_node_info()
host_mem = conn.get_memory_usage()
hosts_vms[host.id, host.name, 1, host_info[3], host_info[2],
host_mem['percent']] = conn.get_host_instances()
conn.close()
except libvirtError:
hosts_vms[host.id, host.name, 3, 0, 0, 0] = None
else:
hosts_vms[host.id, host.name, 2, 0, 0, 0] = None
return render(None, 'infrastructure.html', locals(), request)
示例9: instances
def instances(request):
"""
:param request:
:return:
"""
error_messages = []
all_host_vms = {}
all_user_vms = {}
computes = Compute.objects.all()
if not request.user.is_superuser:
user_instances = UserInstance.objects.filter(user_id=request.user.id)
for usr_inst in user_instances:
if connection_manager.host_is_up(usr_inst.instance.compute.type,
usr_inst.instance.compute.hostname):
conn = wvmHostDetails(usr_inst.instance.compute,
usr_inst.instance.compute.login,
usr_inst.instance.compute.password,
usr_inst.instance.compute.type)
all_user_vms[usr_inst] = conn.get_user_instances(usr_inst.instance.name)
all_user_vms[usr_inst].update({'compute_id': usr_inst.instance.compute.id})
else:
for comp in computes:
if connection_manager.host_is_up(comp.type, comp.hostname):
try:
conn = wvmHostDetails(comp, comp.login, comp.password, comp.type)
if conn.get_host_instances():
all_host_vms[comp.id, comp.name] = conn.get_host_instances()
for vm, info in conn.get_host_instances().items():
try:
check_uuid = Instance.objects.get(compute_id=comp.id, name=vm)
if check_uuid.uuid != info['uuid']:
check_uuid.save()
all_host_vms[comp.id, comp.name][vm]['is_template'] = check_uuid.is_template
except Instance.DoesNotExist:
check_uuid = Instance(compute_id=comp.id, name=vm, uuid=info['uuid'])
check_uuid.save()
conn.close()
except libvirtError as lib_err:
error_messages.append(lib_err)
if request.method == 'POST':
name = request.POST.get('name', '')
compute_id = request.POST.get('compute_id', '')
instance = Instance.objects.get(compute_id=compute_id, name=name)
try:
conn = wvmInstances(instance.compute.hostname,
instance.compute.login,
instance.compute.password,
instance.compute.type)
if 'poweron' in request.POST:
msg = _("Power On")
addlogmsg(request.user.username, instance.name, msg)
conn.start(name)
return HttpResponseRedirect(request.get_full_path())
if 'poweroff' in request.POST:
msg = _("Power Off")
addlogmsg(request.user.username, instance.name, msg)
conn.shutdown(name)
return HttpResponseRedirect(request.get_full_path())
if 'powercycle' in request.POST:
msg = _("Power Cycle")
conn.force_shutdown(name)
conn.start(name)
addlogmsg(request.user.username, instance.name, msg)
return HttpResponseRedirect(request.get_full_path())
if 'getvvfile' in request.POST:
msg = _("Send console.vv file")
addlogmsg(request.user.username, instance.name, msg)
response = HttpResponse(content='', content_type='application/x-virt-viewer', status=200, reason=None, charset='utf-8')
response.writelines('[virt-viewer]\n')
response.writelines('type=' + conn.graphics_type(name) + '\n')
response.writelines('host=' + conn.graphics_listen(name) + '\n')
response.writelines('port=' + conn.graphics_port(name) + '\n')
response.writelines('title=' + conn.domain_name(name) + '\n')
response.writelines('password=' + conn.graphics_passwd(name) + '\n')
response.writelines('enable-usbredir=1\n')
response.writelines('disable-effects=all\n')
response.writelines('secure-attention=ctrl+alt+ins\n')
response.writelines('release-cursor=ctrl+alt\n')
response.writelines('fullscreen=1\n')
response.writelines('delete-this-file=1\n')
response['Content-Disposition'] = 'attachment; filename="console.vv"'
return response
if request.user.is_superuser:
if 'suspend' in request.POST:
msg = _("Suspend")
addlogmsg(request.user.username, instance.name, msg)
conn.suspend(name)
return HttpResponseRedirect(request.get_full_path())
if 'resume' in request.POST:
msg = _("Resume")
addlogmsg(request.user.username, instance.name, msg)
#.........这里部分代码省略.........
示例10: hostusage
def hostusage(request, host_id):
"""
Return Memory and CPU Usage
"""
if not request.user.is_authenticated():
return HttpResponseRedirect('/login')
points = 5
datasets = {}
cookies = {}
compute = Compute.objects.get(id=host_id)
curent_time = time.strftime("%H:%M:%S")
try:
conn = wvmHostDetails(compute.hostname,
compute.login,
compute.password,
compute.type)
cpu_usage = conn.get_cpu_usage()
mem_usage = conn.get_memory_usage()
conn.close()
except libvirtError:
cpu_usage = 0
mem_usage = 0
try:
cookies['cpu'] = request._cookies['cpu']
cookies['mem'] = request._cookies['mem']
cookies['timer'] = request._cookies['timer']
except KeyError:
cookies['cpu'] = None
cookies['mem'] = None
if not cookies['cpu'] and not cookies['mem']:
datasets['cpu'] = [0]
datasets['mem'] = [0]
datasets['timer'] = [curent_time]
else:
datasets['cpu'] = eval(cookies['cpu'])
datasets['mem'] = eval(cookies['mem'])
datasets['timer'] = eval(cookies['timer'])
datasets['timer'].append(curent_time)
datasets['cpu'].append(int(cpu_usage['usage']))
datasets['mem'].append(int(mem_usage['usage']) / 1048576)
if len(datasets['timer']) > points:
datasets['timer'].pop(0)
if len(datasets['cpu']) > points:
datasets['cpu'].pop(0)
if len(datasets['mem']) > points:
datasets['mem'].pop(0)
cpu = {
'labels': datasets['timer'],
'datasets': [
{
"fillColor": "rgba(241,72,70,0.5)",
"strokeColor": "rgba(241,72,70,1)",
"pointColor": "rgba(241,72,70,1)",
"pointStrokeColor": "#fff",
"data": datasets['cpu']
}
]
}
memory = {
'labels': datasets['timer'],
'datasets': [
{
"fillColor": "rgba(249,134,33,0.5)",
"strokeColor": "rgba(249,134,33,1)",
"pointColor": "rgba(249,134,33,1)",
"pointStrokeColor": "#fff",
"data": datasets['mem']
}
]
}
data = json.dumps({'cpu': cpu, 'memory': memory})
response = HttpResponse()
response['Content-Type'] = "text/javascript"
response.cookies['cpu'] = datasets['cpu']
response.cookies['timer'] = datasets['timer']
response.cookies['mem'] = datasets['mem']
response.write(data)
return response
示例11: hostusage
def hostusage(request, host_id):
"""
Return Memory and CPU Usage
"""
if not request.user.is_authenticated():
return HttpResponseRedirect('/login')
datasets = {}
cookies = {}
compute = Compute.objects.get(id=host_id)
try:
conn = wvmHostDetails(compute.hostname,
compute.login,
compute.password,
compute.type)
cpu_usage = conn.get_cpu_usage()
mem_usage = conn.get_memory_usage()
conn.close()
except libvirtError:
cpu_usage = 0
try:
cookies['cpu'] = request._cookies['cpu']
cookies['mem'] = request._cookies['mem']
except KeyError:
cookies['cpu'] = None
cookies['mem'] = None
if not cookies['cpu'] and not cookies['mem']:
datasets['cpu'] = [0]
datasets['mem'] = [0]
else:
datasets['cpu'] = eval(cookies['cpu'])
datasets['mem'] = eval(cookies['mem'])
if len(datasets['cpu']) > 10:
while datasets['cpu']:
del datasets['cpu'][0]
if len(datasets['cpu']) == 10:
break
if len(datasets['mem']) > 10:
while datasets['mem']:
del datasets['mem'][0]
if len(datasets['mem']) == 10:
break
if len(datasets['cpu']) <= 9:
datasets['cpu'].append(int(cpu_usage['usage']))
if len(datasets['cpu']) == 10:
datasets['cpu'].append(int(cpu_usage['usage']))
del datasets['cpu'][0]
if len(datasets['mem']) <= 9:
datasets['mem'].append(int(mem_usage['usage']) / 1048576)
if len(datasets['mem']) == 10:
datasets['mem'].append(int(mem_usage['usage']) / 1048576)
del datasets['mem'][0]
# Some fix division by 0 Chart.js
if len(datasets['cpu']) == 10:
if sum(datasets['cpu']) == 0:
datasets['cpu'][9] += 0.1
if sum(datasets['cpu']) / 10 == datasets['cpu'][0]:
datasets['cpu'][9] += 0.1
if len(datasets['mem']) == 10:
if sum(datasets['mem']) == 0:
datasets['mem'][9] += 0.1
if sum(datasets['mem']) / 10 == datasets['mem'][0]:
datasets['mem'][9] += 0.1
cpu = {
'labels': [""] * 10,
'datasets': [
{
"fillColor": "rgba(241,72,70,0.5)",
"strokeColor": "rgba(241,72,70,1)",
"pointColor": "rgba(241,72,70,1)",
"pointStrokeColor": "#fff",
"data": datasets['cpu']
}
]
}
memory = {
'labels': [""] * 10,
'datasets': [
{
"fillColor": "rgba(249,134,33,0.5)",
"strokeColor": "rgba(249,134,33,1)",
"pointColor": "rgba(249,134,33,1)",
"pointStrokeColor": "#fff",
"data": datasets['mem']
}
]
}
data = json.dumps({'cpu': cpu, 'memory': memory})
#.........这里部分代码省略.........
示例12: instances
def instances(request):
"""
:param request:
:return:
"""
if not request.user.is_authenticated():
return HttpResponseRedirect(reverse('index'))
error_messages = []
all_host_vms = {}
all_user_vms = {}
computes = Compute.objects.all()
if not request.user.is_superuser:
user_instances = UserInstance.objects.filter(user_id=request.user.id)
for usr_inst in user_instances:
if connection_manager.host_is_up(usr_inst.instance.compute.type,
usr_inst.instance.compute.hostname):
conn = wvmHostDetails(usr_inst.instance.compute,
usr_inst.instance.compute.login,
usr_inst.instance.compute.password,
usr_inst.instance.compute.type)
all_user_vms[usr_inst] = conn.get_user_instances(usr_inst.instance.name)
all_user_vms[usr_inst].update({'compute_id': usr_inst.instance.compute.id})
else:
for comp in computes:
if connection_manager.host_is_up(comp.type, comp.hostname):
try:
conn = wvmHostDetails(comp, comp.login, comp.password, comp.type)
if conn.get_host_instances():
all_host_vms[comp.id, comp.name] = conn.get_host_instances()
for vm, info in conn.get_host_instances().items():
try:
check_uuid = Instance.objects.get(compute_id=comp.id, name=vm)
if check_uuid.uuid != info['uuid']:
check_uuid.save()
except Instance.DoesNotExist:
check_uuid = Instance(compute_id=comp.id, name=vm, uuid=info['uuid'])
check_uuid.save()
conn.close()
except libvirtError as lib_err:
error_messages.append(lib_err)
if request.method == 'POST':
name = request.POST.get('name', '')
compute_id = request.POST.get('compute_id', '')
instance = Instance.objects.get(compute_id=compute_id, name=name)
try:
conn = wvmInstances(instance.compute.hostname,
instance.compute.login,
instance.compute.password,
instance.compute.type)
if 'poweron' in request.POST:
msg = _("Power On")
addlogmsg(request.user.username, instance.name, msg)
conn.start(name)
return HttpResponseRedirect(request.get_full_path())
if 'poweroff' in request.POST:
msg = _("Power Off")
addlogmsg(request.user.username, instance.name, msg)
conn.shutdown(name)
return HttpResponseRedirect(request.get_full_path())
if 'powercycle' in request.POST:
msg = _("Power Cycle")
conn.force_shutdown(name)
conn.start(name)
addlogmsg(request.user.username, instance.name, msg)
return HttpResponseRedirect(request.get_full_path())
if request.user.is_superuser:
if 'suspend' in request.POST:
msg = _("Suspend")
addlogmsg(request.user.username, instance.name, msg)
conn.suspend(name)
return HttpResponseRedirect(request.get_full_path())
if 'resume' in request.POST:
msg = _("Resume")
addlogmsg(request.user.username, instance.name, msg)
conn.resume(name)
return HttpResponseRedirect(request.get_full_path())
except libvirtError as lib_err:
error_messages.append(lib_err)
addlogmsg(request.user.username, instance.name, lib_err.message)
return render(request, 'instances.html', locals())
示例13: cpuusage
def cpuusage(request, host_id):
"""
Return CPU Usage in %
"""
if not request.user.is_authenticated():
return HttpResponseRedirect('/login')
datasets = []
compute = Compute.objects.get(id=host_id)
try:
conn = wvmHostDetails(compute.hostname,
compute.login,
compute.password,
compute.type)
cpu_usage = conn.get_cpu_usage()
conn.close()
except libvirtError:
cpu_usage = 0
try:
cookies = request._cookies['cpu_usage']
except KeyError:
cookies = None
if not cookies:
datasets.append(0)
else:
datasets = eval(cookies)
if len(datasets) > 10:
while datasets:
del datasets[0]
if len(datasets) == 10:
break
if len(datasets) <= 9:
datasets.append(int(cpu_usage['usage']))
if len(datasets) == 10:
datasets.append(int(cpu_usage['usage']))
del datasets[0]
# Some fix division by 0 Chart.js
if len(datasets) == 10:
if sum(datasets) == 0:
datasets[9] += 0.1
if sum(datasets) / 10 == datasets[0]:
datasets[9] += 0.1
cpu = {
'labels': [""] * 10,
'datasets': [
{
"fillColor": "rgba(241,72,70,0.5)",
"strokeColor": "rgba(241,72,70,1)",
"pointColor": "rgba(241,72,70,1)",
"pointStrokeColor": "#fff",
"data": datasets
}
]
}
data = json.dumps(cpu)
response = HttpResponse()
response['Content-Type'] = "text/javascript"
response.cookies['cpu_usage'] = datasets
response.write(data)
return response
示例14: instances
def instances(request):
"""
:param request:
:return:
"""
error_messages = []
all_host_vms = {}
all_user_vms = {}
computes = Compute.objects.all().order_by("name")
def get_userinstances_info(instance):
info = {}
uis = UserInstance.objects.filter(instance=instance)
info['count'] = uis.count()
if info['count'] > 0:
info['first_user'] = uis[0]
else:
info['first_user'] = None
return info
def refresh_instance_database(comp, vm, info):
instances = Instance.objects.filter(name=vm)
if instances.count() > 1:
for i in instances:
user_instances_count = UserInstance.objects.filter(instance=i).count()
if user_instances_count == 0:
addlogmsg(request.user.username, i.name, _("Deleting due to multiple records."))
i.delete()
try:
check_uuid = Instance.objects.get(compute_id=comp["id"], name=vm)
if check_uuid.uuid != info['uuid']:
check_uuid.save()
all_host_vms[comp["id"],
comp["name"],
comp["status"],
comp["cpu"],
comp["mem_size"],
comp["mem_perc"]][vm]['is_template'] = check_uuid.is_template
all_host_vms[comp["id"],
comp["name"],
comp["status"],
comp["cpu"],
comp["mem_size"],
comp["mem_perc"]][vm]['userinstances'] = get_userinstances_info(check_uuid)
except Instance.DoesNotExist:
check_uuid = Instance(compute_id=comp["id"], name=vm, uuid=info['uuid'])
check_uuid.save()
if not request.user.is_superuser:
user_instances = UserInstance.objects.filter(user_id=request.user.id)
for usr_inst in user_instances:
if connection_manager.host_is_up(usr_inst.instance.compute.type,
usr_inst.instance.compute.hostname):
conn = wvmHostDetails(usr_inst.instance.compute,
usr_inst.instance.compute.login,
usr_inst.instance.compute.password,
usr_inst.instance.compute.type)
all_user_vms[usr_inst] = conn.get_user_instances(usr_inst.instance.name)
all_user_vms[usr_inst].update({'compute_id': usr_inst.instance.compute.id})
else:
for comp in computes:
status = connection_manager.host_is_up(comp.type, comp.hostname)
if status:
try:
conn = wvmHostDetails(comp, comp.login, comp.password, comp.type)
comp_node_info = conn.get_node_info()
comp_mem = conn.get_memory_usage()
comp_instances = conn.get_host_instances(True)
if comp_instances:
comp_info= {
"id": comp.id,
"name": comp.name,
"status": status,
"cpu": comp_node_info[3],
"mem_size": comp_node_info[2],
"mem_perc": comp_mem['percent']
}
all_host_vms[comp_info["id"], comp_info["name"], comp_info["status"], comp_info["cpu"],
comp_info["mem_size"], comp_info["mem_perc"]] = comp_instances
for vm, info in comp_instances.items():
refresh_instance_database(comp_info, vm, info)
conn.close()
except libvirtError as lib_err:
error_messages.append(lib_err)
if request.method == 'POST':
name = request.POST.get('name', '')
compute_id = request.POST.get('compute_id', '')
instance = Instance.objects.get(compute_id=compute_id, name=name)
try:
conn = wvmInstances(instance.compute.hostname,
instance.compute.login,
instance.compute.password,
instance.compute.type)
if 'poweron' in request.POST:
#.........这里部分代码省略.........