mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-25 15:45:23 +00:00
Merge pull request #401 from catborise/master
Add guest info(hostname,os,version,kernel) tab. indendation fixes
This commit is contained in:
commit
0a8beacf29
13 changed files with 1540 additions and 1460 deletions
|
@ -54,7 +54,14 @@
|
|||
{{ ipv4 }} |
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
<a class="text-secondary" href="{% url 'instances:instance' instance.id %}" title="{% trans 'Refresh instance info' %}"><span class="fa fa-refresh"></span></a>
|
||||
{% if instance.guest_agent_ready %}
|
||||
<a class="text-secondary" title="{% trans 'Show Instance OS details' %}" onclick="get_osinfo()">
|
||||
<span class="fa fa-info-circle"></span>
|
||||
</a>
|
||||
{% endif %}
|
||||
<a class="text-secondary" href="{% url 'instances:instance' instance.id %}" title="{% trans 'Refresh instance info' %}">
|
||||
<span class="fa fa-refresh"></span>
|
||||
</a>
|
||||
</div>
|
||||
{% if user_quota_msg %}
|
||||
<div class="alert alert-warning fade show">
|
||||
|
@ -71,13 +78,13 @@
|
|||
<ul class="nav nav-pills" id="navbtn" aria-label="Instance actions">
|
||||
<li class="nav-item">
|
||||
<a href="#power" class="nav-link action-button active" aria-controls="power" role="tab" data-toggle="tab">
|
||||
<i id="action-block" class="fa fa-power-off fa-2x" aria-hidden="true"></i>
|
||||
<span id="action-block" class="fa fa-power-off fa-2x" aria-hidden="true"></span>
|
||||
{% trans "Power" %}
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="#access" class="nav-link action-button" aria-controls="access" role="tab" data-toggle="tab">
|
||||
<i id="action-block" class="fa fa-lock" aria-hidden="true"></i>
|
||||
<span id="action-block" class="fa fa-lock" aria-hidden="true"></span>
|
||||
{% trans "Access" %}
|
||||
</a>
|
||||
</li>
|
||||
|
@ -684,7 +691,7 @@
|
|||
}
|
||||
});
|
||||
}
|
||||
if (~$.inArray(hash, ['#boot_opt', "#disks", '#network', '#clone', '#xmledit', '#vncsettings', '#migrate', '#options', '#users'])) {
|
||||
if (~$.inArray(hash, ['#osinfo', '#boot_opt', "#disks", '#network', '#clone', '#xmledit', '#vncsettings', '#migrate', '#options', '#users'])) {
|
||||
var btnsect = $('#navbtn>li>a');
|
||||
$(btnsect).each(function () {
|
||||
if ($(this).attr('href') === '#settings') {
|
||||
|
@ -715,4 +722,22 @@
|
|||
});
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
function get_osinfo() {
|
||||
$('#navbtn a[href="#settings"]').tab('show');
|
||||
$('#settings a[href="#osinfo"]').tab('show');
|
||||
|
||||
$.getJSON('{% url 'instances:osinfo' instance.id %}', function (data) {
|
||||
$.each(data, function() {
|
||||
$('#oshostname').text(data['host-name']);
|
||||
$('#osname').text(data.id);
|
||||
$('#osprettyname').text(data['pretty-name']);
|
||||
$('#oskernelrelease').text(data['kernel-release']);
|
||||
$('#oskernelversion').text(data['kernel-version']);
|
||||
$('#osversion').text(data.version);
|
||||
$('#ostimezone').text(data.zone + " / " + data.offset);
|
||||
})
|
||||
});
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
{% load i18n %}
|
||||
<div role="tabpanel" class="tab-pane" id="access" aria-label="Instance access options">
|
||||
<div role="tabpanel">
|
||||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li class="nav-item">
|
||||
|
@ -163,7 +162,6 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% block script %}
|
||||
<script>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
{% load i18n %}
|
||||
<div role="tabpanel" class="tab-pane" id="undefine">
|
||||
<div role="tabpanel">
|
||||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-tabs" role="tablist" aria-label="Instance destroy menu">
|
||||
<li class="nav-item">
|
||||
|
@ -25,5 +24,4 @@
|
|||
<div class="clearfix"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
20
instances/templates/instances/info_tab.html
Normal file
20
instances/templates/instances/info_tab.html
Normal file
|
@ -0,0 +1,20 @@
|
|||
{% load i18n %}
|
||||
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="osinfo">
|
||||
<h3 class="page-header">{% trans "Guest Info" %}</h3>
|
||||
<dl class="mx-3 row">
|
||||
<dt class="col-3">{% trans "Hostname" %}</dt>
|
||||
<dd class="col-9" id="oshostname"></dd>
|
||||
<dt class="col-3">{% trans "OS Name" %}</dt>
|
||||
<dd class="col-9" id="osname"></dd>
|
||||
<dt class="col-3">{% trans "OS Pretty-Name" %}</dt>
|
||||
<dd class="col-9" id="osprettyname"></dd>
|
||||
<dt class="col-3">{% trans "Version" %}</dt>
|
||||
<dd class="col-9" id="osversion"></dd>
|
||||
<dt class="col-3">{% trans "Kernel Release" %}</dt>
|
||||
<dd class="col-9" id="oskernelrelease"></dd>
|
||||
<dt class="col-3">{% trans "Kernel Version" %}</dt>
|
||||
<dd class="col-9" id="oskernelversion"></dd>
|
||||
<dt class="col-3">{% trans "Timezone / Offset" %}</dt>
|
||||
<dd class="col-9" id="ostimezone"></dd>
|
||||
</dl>
|
||||
</div>
|
|
@ -1,6 +1,5 @@
|
|||
{% load i18n %}
|
||||
<div role="tabpanel" class="tab-pane active" id="power">
|
||||
<div role="tabpanel">
|
||||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-tabs" role="tablist" aria-label="Instance power actions">
|
||||
{% if instance.status == 1 %}
|
||||
|
@ -127,5 +126,4 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
{% load i18n %}
|
||||
<div role="tabpanel" class="tab-pane" id="resize">
|
||||
<div role="tabpanel">
|
||||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-tabs" role="tablist" aria-label="Instance resize options">
|
||||
<li class="nav-item">
|
||||
|
@ -160,5 +159,4 @@
|
|||
<div class="clearfix"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -2,11 +2,18 @@
|
|||
{% load bootstrap4 %}
|
||||
{% load icons %}
|
||||
<div role="tabpanel" class="tab-pane" id="settings">
|
||||
<div role="tabpanel">
|
||||
|
||||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-tabs" role="tablist" aria-label="Instance settings">
|
||||
{% if request.user.is_superuser %}
|
||||
<li class="nav-item ">
|
||||
{% if instance.guest_agent_ready %}
|
||||
<li class="nav-item">
|
||||
<a class="px-1 nav-link text-secondary" href="#osinfo" aria-controls="os-info" role="tab" data-toggle="tab" onclick="get_osinfo()">
|
||||
<span class="fa fa-info-circle"></span>
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-secondary active" href="#boot_opt" aria-controls="boot" role="tab" data-toggle="tab">
|
||||
{% trans "Boot" %}
|
||||
</a>
|
||||
|
@ -68,6 +75,7 @@
|
|||
<!-- Tab panes -->
|
||||
<div class="tab-content">
|
||||
{% if request.user.is_superuser %}
|
||||
{% include 'instances/info_tab.html' %}
|
||||
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="boot_opt">
|
||||
<p class="font-weight-bold">{% trans 'Autostart' %}</p>
|
||||
<div class="form-group row">
|
||||
|
@ -259,7 +267,7 @@
|
|||
<strong>IO Mode:</strong> {{ disk.io }} <br/>
|
||||
<strong>Discard:</strong> {{ disk.discard }} <br/>
|
||||
<strong>Detect Zeroes:</strong> {{ disk.detect_zeroes }}">
|
||||
<i class="fa fa-info"></i>
|
||||
<span class="fa fa-info"></span>
|
||||
</button>
|
||||
{{ disk.dev }}
|
||||
</td>
|
||||
|
@ -513,7 +521,7 @@
|
|||
<button type="submit" class="btn btn-sm btn-primary"
|
||||
name="set_qos" data-toggle="modal"
|
||||
title="{% trans "Edit QoS" %}" onclick="return confirm('{% trans "Are you sure?" %}')">
|
||||
<i class="fa fa-save"></i>
|
||||
<span class="fa fa-save"></span>
|
||||
</button>
|
||||
</form>
|
||||
<form action="{% url 'instances:unset_qos' instance.id %}" method="post" role="form" aria-label="Instance QoS configuration form">
|
||||
|
@ -670,8 +678,8 @@
|
|||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if request.user.is_superuser or request.user.is_staff or userinstance.is_vnc %}
|
||||
{% endif %}
|
||||
{% if request.user.is_superuser or request.user.is_staff or userinstance.is_vnc %}
|
||||
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="vncsettings">
|
||||
<form method="post" action="{% url 'instances:update_console' instance.id %}">
|
||||
{% csrf_token %}
|
||||
|
@ -691,7 +699,7 @@
|
|||
</form>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if perms.instances.clone_instances %}
|
||||
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="clone">
|
||||
<p class="font-weight-bold">{% trans "Create a clone" %}</p>
|
||||
|
@ -905,5 +913,4 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
{% load i18n %}
|
||||
{% load icons %}
|
||||
<div role="tabpanel" class="tab-pane" id="snapshots">
|
||||
<div role="tabpanel">
|
||||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-tabs" role="tablist" aria-label="Instance snapshot menu">
|
||||
<li class="nav-item">
|
||||
|
@ -79,5 +78,4 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
{% load i18n %}
|
||||
<div role="tabpanel" class="tab-pane" id="graphics">
|
||||
<div role="tabpanel">
|
||||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-tabs" role="tablist" aria-label="Instance graphs and logs menu">
|
||||
<li class="nav-item">
|
||||
|
@ -95,7 +94,6 @@
|
|||
<div class="clearfix"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function update_logs_table(vname) {
|
||||
|
|
|
@ -20,6 +20,7 @@ urlpatterns = [
|
|||
path('<int:pk>/migrate/', views.migrate, name='migrate'),
|
||||
path('<int:pk>/status/', views.status, name='status'),
|
||||
path('<int:pk>/stats/', views.stats, name='stats'),
|
||||
path('<int:pk>/osinfo/', views.osinfo, name='osinfo'),
|
||||
path('<int:pk>/rootpasswd/', views.set_root_pass, name='rootpasswd'),
|
||||
path('<int:pk>/add_public_key/', views.add_public_key, name='add_public_key'),
|
||||
path('<int:pk>/resizevm_cpu/', views.resizevm_cpu, name='resizevm_cpu'),
|
||||
|
|
|
@ -161,6 +161,11 @@ def stats(request, pk):
|
|||
}
|
||||
)
|
||||
|
||||
def osinfo(request, pk):
|
||||
instance = get_instance(request.user, pk)
|
||||
results = instance.proxy.osinfo()
|
||||
|
||||
return JsonResponse(results)
|
||||
|
||||
def guess_mac_address(request, vname):
|
||||
data = {"vname": vname}
|
||||
|
|
|
@ -296,12 +296,12 @@
|
|||
<button type="submit" class="btn btn-sm btn-primary"
|
||||
name="modify_fixed_address"
|
||||
title="{% trans "Edit entry" %}" onclick="return confirm('{% trans "Are you sure?" %}')">
|
||||
<i class="fa fa-save"></i>
|
||||
<span class="fa fa-save"></span>
|
||||
</button>
|
||||
<button type="submit" class="btn btn-sm btn-danger"
|
||||
name="delete_fixed_address"
|
||||
title="{% trans "Delete entry" %}" onclick="return confirm('{% trans "Are you sure?" %}')">
|
||||
<i class="fa fa-trash"></i>
|
||||
<span class="fa fa-trash"></span>
|
||||
</button>
|
||||
</td>
|
||||
</form>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import json
|
||||
import os.path
|
||||
import time
|
||||
|
||||
|
@ -20,6 +21,10 @@ try:
|
|||
VIR_MIGRATE_POSTCOPY,
|
||||
)
|
||||
from libvirt import VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT
|
||||
from libvirt_qemu import (
|
||||
qemuAgentCommand,
|
||||
VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT
|
||||
)
|
||||
except:
|
||||
from libvirt import libvirtError, VIR_DOMAIN_XML_SECURE, VIR_MIGRATE_LIVE
|
||||
|
||||
|
@ -160,6 +165,35 @@ class wvmInstance(wvmConnect):
|
|||
self._ip_cache = None
|
||||
self.instance = self.get_instance(vname)
|
||||
|
||||
def osinfo(self):
|
||||
info_results = qemuAgentCommand(
|
||||
self.instance,
|
||||
'{"execute":"guest-get-osinfo"}',
|
||||
VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT, 0
|
||||
)
|
||||
|
||||
timezone_results = qemuAgentCommand(
|
||||
self.instance,
|
||||
'{"execute":"guest-get-timezone"}',
|
||||
VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT, 0
|
||||
)
|
||||
|
||||
hostname_results = qemuAgentCommand(
|
||||
self.instance,
|
||||
'{"execute":"guest-get-host-name"}',
|
||||
VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT, 0
|
||||
)
|
||||
|
||||
info_results = json.loads(info_results).get('return')
|
||||
|
||||
timezone_results = json.loads(timezone_results).get('return')
|
||||
hostname_results = json.loads(hostname_results).get('return')
|
||||
|
||||
info_results.update(timezone_results)
|
||||
info_results.update(hostname_results)
|
||||
|
||||
return info_results
|
||||
|
||||
def start(self):
|
||||
self.instance.create()
|
||||
|
||||
|
|
Loading…
Reference in a new issue