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

instance template change to instances as group of hosts. bootstrap.min.css and js updated. some info added.

This commit is contained in:
catborise 2018-06-28 16:55:36 +03:00
parent a933ffb00f
commit 20e8b876e4
8 changed files with 88 additions and 29 deletions

View file

@ -37,21 +37,41 @@
</div>
{% else %}
<table class="table table-hover table-striped sortable-theme-bootstrap" data-sortable>
<thead>
<thead >
<tr>
<th>#</th>
<th>Name<br>Description</th>
<th>Host<br>User</th>
<th>Status</th>
<th>VCPU</th>
<th>Memory<br>({% trans "MB" %})</th>
<th data-sortable="false" style="width:205px;">Actions</th>
<th data-sortable="false" style="width:205px;">Actions & Usage</th>
</tr>
</thead>
<tbody class="searchable">
{% for host, inst in all_host_vms.items %}
<!-- copied /-->
<!-- <tr style="font-size:16px;background-color: #5CB75C; color: white" > /-->
<tr class="success" style="font-size:16px">
<td>{{ forloop.counter }}</td>
<td><a href="{% url 'overview' host.0 %}">{{ host.1 }}</a></td>
<td></td>
<td>{% ifequal host.2 1 %}<span class="label label-success">{% trans "Active" %}
</span>{% endifequal %}
{% ifequal host.2 2 %}<span class="label label-danger">{% trans "Not Active" %}
</span>{% endifequal %}
{% ifequal host.2 3 %}<span class="label label-danger">{% trans "Connection Failed" %}
</span>{% endifequal %}
</td>
<td style="text-align:center;">{{ host.3 }}</td>
<td style="text-align:right;">{{ host.4|filesizeformat }}</td>
<td style="text-align:left;">Mem Usage: {{ host.5 }}%</td>
</tr>
<!-- copied /-->
{% for vm, info in inst.items %}
<tr>
<td><a href="{% url 'instance' host.0 vm %}">{{ vm }}</a><br><small><em>{{ info.title }}</em></small></td>
<td></td>
<td>{{ forloop.counter }} &emsp; <a href="{% url 'instance' host.0 vm %}">{{ vm }}</a><br><small><em>{{ info.title }}</em></small></td>
<td><a href="{% url 'overview' host.0 %}">{{ host.1 }}</a><br><small><em>{% if info.userinstances.count > 0 %}{{ info.userinstances.first_user.user.username }}{% if info.userinstances.count > 1 %} (+{{ info.userinstances.count|add:"-1" }}){% endif %}{% endif %}</em></small></td>
<td>{% ifequal info.status 1 %}
<span class="text-success">{% trans "Active" %}</span>
@ -63,8 +83,8 @@
<span class="text-warning">{% trans "Suspend" %}</span>
{% endifequal %}
</td>
<td>{{ info.vcpu }}</td>
<td>{{ info.memory }}</td>
<td style="text-align:center;">{{ info.vcpu }}</td>
<td style="text-align:right;">{{ info.memory |filesizeformat }}</td>
<td><form action="" method="post" role="form">{% csrf_token %}
<input type="hidden" name="name" value="{{ vm }}"/>
<input type="hidden" name="compute_id" value="{{ host.0 }}"/>

View file

@ -68,11 +68,22 @@ def instances(request):
i.delete()
try:
check_uuid = Instance.objects.get(compute_id=comp.id, name=vm)
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
all_host_vms[comp.id, comp.name][vm]['userinstances'] = get_userinstances_info(check_uuid)
all_host_vms[comp_info["id"],
comp_info["name"],
comp_info["status"],
comp_info["cpu"],
comp_info["mem_size"],
comp_info["mem_perc"]][vm]['is_template'] = check_uuid.is_template
all_host_vms[comp_info["id"],
comp_info["name"],
comp_info["status"],
comp_info["cpu"],
comp_info["mem_size"],
comp_info["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()
@ -90,14 +101,27 @@ def instances(request):
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):
status = connection_manager.host_is_up(comp.type, comp.hostname)
if status:
try:
conn = wvmHostDetails(comp, comp.login, comp.password, comp.type)
host_instances = conn.get_host_instances()
if host_instances:
all_host_vms[comp.id, comp.name] = host_instances
for vm, info in host_instances.items():
refresh_instance_database(comp, vm, info)
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:

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

7
static/js/bootstrap.min.js_332 Executable file

File diff suppressed because one or more lines are too long

View file

@ -454,11 +454,13 @@ class wvmConnect(object):
netdevice.append(interface)
return netdevice
def get_host_instances(self):
def get_host_instances(self, raw_mem_size=False):
vname = {}
def get_info(doc):
mem = util.get_xpath(doc, "/domain/currentMemory")
mem = int(mem) / 1024
if raw_mem_size:
mem = int(mem) * (1024*1024)
cur_vcpu = util.get_xpath(doc, "/domain/vcpu/@current")
if cur_vcpu:
vcpu = cur_vcpu

View file

@ -59,12 +59,12 @@ class wvmHostDetails(wvmConnect):
Function return host server information: hostname, cpu, memory, ...
"""
info = []
info.append(self.wvm.getHostname())
info.append(self.wvm.getInfo()[0])
info.append(self.wvm.getInfo()[1] * 1048576)
info.append(self.wvm.getInfo()[2])
info.append(get_xml_path(self.wvm.getSysinfo(0), func=cpu_version))
info.append(self.wvm.getURI())
info.append(self.wvm.getHostname()) # hostname
info.append(self.wvm.getInfo()[0]) # architecture
info.append(self.wvm.getInfo()[1] * 1048576) # memory
info.append(self.wvm.getInfo()[2]) # cpu core count
info.append(get_xml_path(self.wvm.getSysinfo(0), func=cpu_version)) # cpu version
info.append(self.wvm.getURI()) #uri
return info
def hypervisor_type(self):