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

Merge pull request #401 from catborise/master

Add guest info(hostname,os,version,kernel) tab. indendation fixes
This commit is contained in:
catborise 2020-12-18 10:05:22 +03:00 committed by GitHub
commit 0a8beacf29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 1540 additions and 1460 deletions

View file

@ -54,7 +54,14 @@
{{ ipv4 }} | {{ ipv4 }} |
{% endfor %} {% endfor %}
{% 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> </div>
{% if user_quota_msg %} {% if user_quota_msg %}
<div class="alert alert-warning fade show"> <div class="alert alert-warning fade show">
@ -71,13 +78,13 @@
<ul class="nav nav-pills" id="navbtn" aria-label="Instance actions"> <ul class="nav nav-pills" id="navbtn" aria-label="Instance actions">
<li class="nav-item"> <li class="nav-item">
<a href="#power" class="nav-link action-button active" aria-controls="power" role="tab" data-toggle="tab"> <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" %} {% trans "Power" %}
</a> </a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a href="#access" class="nav-link action-button" aria-controls="access" role="tab" data-toggle="tab"> <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" %} {% trans "Access" %}
</a> </a>
</li> </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'); var btnsect = $('#navbtn>li>a');
$(btnsect).each(function () { $(btnsect).each(function () {
if ($(this).attr('href') === '#settings') { if ($(this).attr('href') === '#settings') {
@ -715,4 +722,22 @@
}); });
} }
</script> </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 %} {% endblock %}

View file

@ -1,168 +1,166 @@
{% load i18n %} {% load i18n %}
<div role="tabpanel" class="tab-pane" id="access" aria-label="Instance access options"> <div role="tabpanel" class="tab-pane" id="access" aria-label="Instance access options">
<div role="tabpanel"> <!-- Nav tabs -->
<!-- Nav tabs --> <ul class="nav nav-tabs" role="tablist">
<ul class="nav nav-tabs" role="tablist"> <li class="nav-item">
<li class="nav-item"> <a class="nav-link text-secondary active" href="#vnconsole" aria-controls="vnconsole" role="tab"
<a class="nav-link text-secondary active" href="#vnconsole" aria-controls="vnconsole" role="tab" data-toggle="tab">
data-toggle="tab"> {% trans "Console" %}
{% trans "Console" %} </a>
</a> </li>
</li> {% if app_settings.SHOW_ACCESS_ROOT_PASSWORD == 'True' %}
{% if app_settings.SHOW_ACCESS_ROOT_PASSWORD == 'True' %} <li class="nav-item">
<li class="nav-item"> <a class="nav-link text-secondary" href="#rootpasswd" aria-controls="rootpasswd" role="tab"
<a class="nav-link text-secondary" href="#rootpasswd" aria-controls="rootpasswd" role="tab" data-toggle="tab">
data-toggle="tab"> {% trans "Root Password" %}
{% trans "Root Password" %} </a>
</a> </li>
</li> {% endif %}
{% endif %} {% if app_settings.SHOW_ACCESS_SSH_KEYS == 'True' %}
{% if app_settings.SHOW_ACCESS_SSH_KEYS == 'True' %} <li class="nav-item">
<li class="nav-item"> <a class="nav-link text-secondary" href="#sshkeys" aria-controls="sshkeys" role="tab" data-toggle="tab">
<a class="nav-link text-secondary" href="#sshkeys" aria-controls="sshkeys" role="tab" data-toggle="tab"> {% trans "SSH Keys" %}
{% trans "SSH Keys" %} </a>
</a> </li>
</li> {% endif %}
{% endif %} {% if instance.status == 1 %}
{% if instance.status == 1 %} <li class="nav-item">
<li class="nav-item"> <a class="nav-link text-secondary" href="#vdiconsole" aria-controls="vdiconsole" role="tab"
<a class="nav-link text-secondary" href="#vdiconsole" aria-controls="vdiconsole" role="tab" data-toggle="tab">
data-toggle="tab"> {% trans "VDI" %}
{% trans "VDI" %} </a>
</a> </li>
</li> {% endif %}
{% endif %} </ul>
</ul> <!-- Tab panes -->
<!-- Tab panes --> <div class="tab-content">
<div class="tab-content"> <div role="tabpanel" class="tab-pane tab-pane-bordered active" id="vnconsole">
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="vnconsole"> <p>{% blocktrans with type=instance.console_type|upper %} This action opens a new window with a {{ type }} connection to the console of the instance.{% endblocktrans %}
<p>{% blocktrans with type=instance.console_type|upper %} This action opens a new window with a {{ type }} connection to the console of the instance.{% endblocktrans %} </p>
</p> {% if instance.console_type == 'vnc' %}
{% if instance.console_type == 'vnc' %} <div class="ml-3 form-row">
<div class="ml-3 form-row"> <div class="custom-control custom-switch">
<div class="custom-control custom-switch"> <input class="custom-control-input" type="checkbox" name="scale"
<input class="custom-control-input" type="checkbox" name="scale" {% if app_settings.CONSOLE_SCALE == 'True' %} checked {% endif %}
{% if app_settings.CONSOLE_SCALE == 'True' %} checked {% endif %} id="scale">
id="scale"> <label class="custom-control-label font-weight-bold" for="scale">{% trans "Scale" %}</label>
<label class="custom-control-label font-weight-bold" for="scale">{% trans "Scale" %}</label>
</div>
</div>
<div class="ml-3 form-row">
<div class="custom-control custom-switch">
<input class="custom-control-input" type="checkbox" name="view_only"
{% if app_settings.CONSOLE_VIEW_ONLY == 'True' %} checked {% endif %}
id="view_only">
<label class="custom-control-label font-weight-bold" for="view_only">{% trans "View Only" %}</label>
</div>
</div>
<div class="ml-3 form-row">
<div class="custom-control custom-switch">
<input class="custom-control-input" type="checkbox" name="resize_session"
{% if app_settings.CONSOLE_RESIZE_SESSION == 'True' %} checked {% endif %}
id="resize_session">
<label class="custom-control-label font-weight-bold" for="resize_session">{% trans "Resize Session" %}</label>
</div>
</div>
<div class="ml-3 form-row">
<div class="custom-control custom-switch">
<input class="custom-control-input" type="checkbox" name="clip_viewport"
{% if app_settings.CONSOLE_CLIP_VIEWPORT == 'True' %} checked {% endif %}
id="clip_viewport">
<label class="custom-control-label font-weight-bold" for="clip_viewport">{% trans "View Clipboard" %}</label>
</div>
</div>
{% endif %}
{% if instance.status == 1 %}
<!-- Split button -->
<div class="btn-group float-right">
<button type="button" id="consoleBtnGroup" class="btn btn-lg btn-success"
onclick="open_console('lite')">{% trans 'Console' %}</button>
<button type="button" class="btn btn-success dropdown-toggle dropdown-toggle-split"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="sr-only">{% trans 'Toggle Dropdown' %}</span>
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#"
title="{% trans "Console port" %}: {{ instance.console_port }}"
onclick="open_console('lite')">{% trans "Console" %} - {% trans "Lite" %}</a>
<a class="dropdown-item" href="#"
title="{% trans "Console port" %}: {{ instance.console_port }}"
onclick="open_console('full')">{% trans "Console" %} - {% trans "Full" %}</a>
</div> </div>
</div> </div>
{% else %} <div class="ml-3 form-row">
<button class="btn btn-lg btn-success float-right disabled">{% trans "Console" %}</button> <div class="custom-control custom-switch">
{% endif %} <input class="custom-control-input" type="checkbox" name="view_only"
<div class="clearfix"></div> {% if app_settings.CONSOLE_VIEW_ONLY == 'True' %} checked {% endif %}
</div> id="view_only">
{% if app_settings.SHOW_ACCESS_ROOT_PASSWORD == 'True' %} <label class="custom-control-label font-weight-bold" for="view_only">{% trans "View Only" %}</label>
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="rootpasswd">
<p>{% trans "You need shut down your instance and enter a new root password." %}</p>
<form action="{% url 'instances:rootpasswd' instance.id %}" class="form-inline" method="post"
role="form" aria-label="Add root password to instance form">
{% csrf_token %}
<div class="form-group row">
<div class="col-sm-12">
<input type="text" class="form-control-lg" name="passwd"
placeholder="{% trans "Enter Password" %}" maxlength="24">
</div>
</div> </div>
{% if instance.status == 5 %} </div>
<input type="submit" class="btn btn-lg btn-success float-right" name="rootpasswd" <div class="ml-3 form-row">
value="{% trans "Reset Root Password" %}"> <div class="custom-control custom-switch">
{% else %} <input class="custom-control-input" type="checkbox" name="resize_session"
<button {% if app_settings.CONSOLE_RESIZE_SESSION == 'True' %} checked {% endif %}
class="btn btn-lg btn-success float-right disabled">{% trans "Reset Root Password" %}</button> id="resize_session">
{% endif %} <label class="custom-control-label font-weight-bold" for="resize_session">{% trans "Resize Session" %}</label>
</form>
<div class="clearfix"></div>
</div>
{% endif %}
{% if app_settings.SHOW_ACCESS_SSH_KEYS == 'True' %}
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="sshkeys">
<p>{% trans "You need shut down your instance and choose your public key." %}</p>
<form action="{% url 'instances:add_public_key' instance.id %}" class="form-inline" method="post"
role="form" aria-label="Add public key to instance form">
{% csrf_token %}
<div class="form-group row">
<div class="col-sm-12">
<select name="sshkeyid" class="form-control-lg keyselect">
{% if publickeys %}
{% for key in publickeys %}
<option value="{{ key.id }}">{{ key.keyname }}</option>
{% endfor %}
{% else %}
<option value="None">{% trans "None" %}</option>
{% endif %}
</select>
</div>
</div> </div>
{% if instance.status == 5 %} </div>
<input type="submit" class="btn btn-lg btn-success float-right" name="addpublickey" <div class="ml-3 form-row">
value="{% trans "Add Public Key" %}"> <div class="custom-control custom-switch">
{% else %} <input class="custom-control-input" type="checkbox" name="clip_viewport"
<button class="btn btn-lg btn-success float-right disabled">{% trans "Add Public Key" %}</button> {% if app_settings.CONSOLE_CLIP_VIEWPORT == 'True' %} checked {% endif %}
{% endif %} id="clip_viewport">
</form> <label class="custom-control-label font-weight-bold" for="clip_viewport">{% trans "View Clipboard" %}</label>
<div class="clearfix"></div> </div>
</div> </div>
{% endif %} {% endif %}
{% if instance.status == 1 %} {% if instance.status == 1 %}
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="vdiconsole"> <!-- Split button -->
<p>{% trans "This action opens a remote viewer with a connection to the console of the instance." %}</p> <div class="btn-group float-right">
<div class="input-group"> <button type="button" id="consoleBtnGroup" class="btn btn-lg btn-success"
<input type="text" class="input-lg disabled form-control" disabled id="vdi_url_input" /> onclick="open_console('lite')">{% trans 'Console' %}</button>
<span class="input-group-append"> <button type="button" class="btn btn-success dropdown-toggle dropdown-toggle-split"
<a href="#" class="btn btn-success" id="vdi_url">{% trans "VDI" %}</a> data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
</span> <span class="sr-only">{% trans 'Toggle Dropdown' %}</span>
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#"
title="{% trans "Console port" %}: {{ instance.console_port }}"
onclick="open_console('lite')">{% trans "Console" %} - {% trans "Lite" %}</a>
<a class="dropdown-item" href="#"
title="{% trans "Console port" %}: {{ instance.console_port }}"
onclick="open_console('full')">{% trans "Console" %} - {% trans "Full" %}</a>
</div> </div>
<p>{% trans "To download console.vv file for virt-viewer." %}</p>
<a href="{% url 'instances:getvvfile' instance.id %}" class="btn btn-lg btn-success float-right">{% trans "Get console.vv" %}</a>
<div class="clearfix"></div>
</div> </div>
{% else %}
<button class="btn btn-lg btn-success float-right disabled">{% trans "Console" %}</button>
{% endif %} {% endif %}
<div class="clearfix"></div>
</div> </div>
{% if app_settings.SHOW_ACCESS_ROOT_PASSWORD == 'True' %}
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="rootpasswd">
<p>{% trans "You need shut down your instance and enter a new root password." %}</p>
<form action="{% url 'instances:rootpasswd' instance.id %}" class="form-inline" method="post"
role="form" aria-label="Add root password to instance form">
{% csrf_token %}
<div class="form-group row">
<div class="col-sm-12">
<input type="text" class="form-control-lg" name="passwd"
placeholder="{% trans "Enter Password" %}" maxlength="24">
</div>
</div>
{% if instance.status == 5 %}
<input type="submit" class="btn btn-lg btn-success float-right" name="rootpasswd"
value="{% trans "Reset Root Password" %}">
{% else %}
<button
class="btn btn-lg btn-success float-right disabled">{% trans "Reset Root Password" %}</button>
{% endif %}
</form>
<div class="clearfix"></div>
</div>
{% endif %}
{% if app_settings.SHOW_ACCESS_SSH_KEYS == 'True' %}
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="sshkeys">
<p>{% trans "You need shut down your instance and choose your public key." %}</p>
<form action="{% url 'instances:add_public_key' instance.id %}" class="form-inline" method="post"
role="form" aria-label="Add public key to instance form">
{% csrf_token %}
<div class="form-group row">
<div class="col-sm-12">
<select name="sshkeyid" class="form-control-lg keyselect">
{% if publickeys %}
{% for key in publickeys %}
<option value="{{ key.id }}">{{ key.keyname }}</option>
{% endfor %}
{% else %}
<option value="None">{% trans "None" %}</option>
{% endif %}
</select>
</div>
</div>
{% if instance.status == 5 %}
<input type="submit" class="btn btn-lg btn-success float-right" name="addpublickey"
value="{% trans "Add Public Key" %}">
{% else %}
<button class="btn btn-lg btn-success float-right disabled">{% trans "Add Public Key" %}</button>
{% endif %}
</form>
<div class="clearfix"></div>
</div>
{% endif %}
{% if instance.status == 1 %}
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="vdiconsole">
<p>{% trans "This action opens a remote viewer with a connection to the console of the instance." %}</p>
<div class="input-group">
<input type="text" class="input-lg disabled form-control" disabled id="vdi_url_input" />
<span class="input-group-append">
<a href="#" class="btn btn-success" id="vdi_url">{% trans "VDI" %}</a>
</span>
</div>
<p>{% trans "To download console.vv file for virt-viewer." %}</p>
<a href="{% url 'instances:getvvfile' instance.id %}" class="btn btn-lg btn-success float-right">{% trans "Get console.vv" %}</a>
<div class="clearfix"></div>
</div>
{% endif %}
</div> </div>
</div> </div>
{% block script %} {% block script %}

View file

@ -1,29 +1,27 @@
{% load i18n %} {% load i18n %}
<div role="tabpanel" class="tab-pane" id="undefine"> <div role="tabpanel" class="tab-pane" id="undefine">
<div role="tabpanel"> <!-- Nav tabs -->
<!-- Nav tabs --> <ul class="nav nav-tabs" role="tablist" aria-label="Instance destroy menu">
<ul class="nav nav-tabs" role="tablist" aria-label="Instance destroy menu"> <li class="nav-item">
<li class="nav-item"> <a class="nav-link active" href="#destroy" aria-controls="destroy" role="tab" data-toggle="tab">
<a class="nav-link active" href="#destroy" aria-controls="destroy" role="tab" data-toggle="tab"> {% trans "Destroy Instance" %}
{% trans "Destroy Instance" %} </a>
</a> </li>
</li> </ul>
</ul> <!-- Tab panes -->
<!-- Tab panes --> <div class="tab-content">
<div class="tab-content"> <div role="tabpanel" class="tab-pane tab-pane-bordered active" id="destroy">
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="destroy"> <p>{% trans 'This action starts remove instance process' %}</p>
<p>{% trans 'This action starts remove instance process' %}</p> {% if request.user.is_superuser or userinstance.is_delete %}
{% if request.user.is_superuser or userinstance.is_delete %} {% if instance.status == 3 %}
{% if instance.status == 3 %} <a class="btn btn-lg btn-success disabled float-right">{% trans "Destroy" %}</a>
<a class="btn btn-lg btn-success disabled float-right">{% trans "Destroy" %}</a>
{% else %}
<a href="{% url 'instances:destroy' instance.id %}" class="btn btn-lg btn-success float-right">{% trans "Destroy" %}</a>
{% endif %}
{% else %} {% else %}
<button class="btn btn-lg btn-success disabled float-right" name="delete">{% trans "Destroy" %}</button> <a href="{% url 'instances:destroy' instance.id %}" class="btn btn-lg btn-success float-right">{% trans "Destroy" %}</a>
{% endif %} {% endif %}
<div class="clearfix"></div> {% else %}
</div> <button class="btn btn-lg btn-success disabled float-right" name="delete">{% trans "Destroy" %}</button>
{% endif %}
<div class="clearfix"></div>
</div> </div>
</div> </div>
</div> </div>

View 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>

View file

@ -1,131 +1,129 @@
{% load i18n %} {% load i18n %}
<div role="tabpanel" class="tab-pane active" id="power"> <div role="tabpanel" class="tab-pane active" id="power">
<div role="tabpanel"> <!-- Nav tabs -->
<!-- Nav tabs --> <ul class="nav nav-tabs" role="tablist" aria-label="Instance power actions">
<ul class="nav nav-tabs" role="tablist" aria-label="Instance power actions"> {% if instance.status == 1 %}
{% if instance.status == 1 %} <li class="nav-item">
<a class="nav-link text-secondary active" href="#poweroff" aria-controls="poweroff" role="tab" data-toggle="tab">
{% trans "Power Off" %}
</a>
</li>
<li class="nav-item">
<a class="nav-link text-secondary" href="#powercycle" aria-controls="powercycle" role="tab" data-toggle="tab">
{% trans "Power Cycle" %}
</a>
</li>
<li class="nav-item">
<a class="nav-link text-secondary" href="#powerforce" aria-controls="powerforce" role="tab" data-toggle="tab">
{% trans "Force Off" %}
</a>
</li>
{% if request.user.is_superuser %}
<li class="nav-item"> <li class="nav-item">
<a class="nav-link text-secondary active" href="#poweroff" aria-controls="poweroff" role="tab" data-toggle="tab"> <a class="nav-link text-secondary" href="#suspend" aria-controls="suspend" role="tab" data-toggle="tab">
{% trans "Power Off" %} {% trans "Suspend" %}
</a>
</li>
<li class="nav-item">
<a class="nav-link text-secondary" href="#powercycle" aria-controls="powercycle" role="tab" data-toggle="tab">
{% trans "Power Cycle" %}
</a>
</li>
<li class="nav-item">
<a class="nav-link text-secondary" href="#powerforce" aria-controls="powerforce" role="tab" data-toggle="tab">
{% trans "Force Off" %}
</a>
</li>
{% if request.user.is_superuser %}
<li class="nav-item">
<a class="nav-link text-secondary" href="#suspend" aria-controls="suspend" role="tab" data-toggle="tab">
{% trans "Suspend" %}
</a>
</li>
{% endif %}
{% endif %}
{% if instance.status == 3 %}
{% if request.user.is_superuser %}
<li class="nav-item">
<a class="nav-link text-secondary" href="#resume" aria-controls="resume" role="tab" data-toggle="tab">
{% trans "Resume" %}
</a>
</li>
<li class="nav-item">
<a class="nav-link text-secondary" href="#powerforce" aria-controls="powerforce" role="tab" data-toggle="tab">
{% trans "Force Off" %}
</a>
</li>
{% endif %}
{% endif %}
{% if instance.status == 5 %}
<li class="nav-item">
<a class="nav-link text-secondary active" href="#boot" aria-controls="boot" role="tab" data-toggle="tab">
{% trans "Power On" %}
</a> </a>
</li> </li>
{% endif %} {% endif %}
</ul> {% endif %}
<!-- Tab panes --> {% if instance.status == 3 %}
<div class="tab-content"> {% if request.user.is_superuser %}
{% if instance.status == 1 %} <li class="nav-item">
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="poweroff"> <a class="nav-link text-secondary" href="#resume" aria-controls="resume" role="tab" data-toggle="tab">
<p>{% trans "This action sends an ACPI shutdown signal to the instance." %}</p> {% trans "Resume" %}
<form action="{% url 'instances:poweroff' instance.id %}" method="post" role="form" aria-label0="Power off instance form"> </a>
{% csrf_token %} </li>
<input type="submit" name="poweroff" class="btn btn-lg btn-success float-right" value="{% trans "Power Off" %}"> <li class="nav-item">
<a class="nav-link text-secondary" href="#powerforce" aria-controls="powerforce" role="tab" data-toggle="tab">
{% trans "Force Off" %}
</a>
</li>
{% endif %}
{% endif %}
{% if instance.status == 5 %}
<li class="nav-item">
<a class="nav-link text-secondary active" href="#boot" aria-controls="boot" role="tab" data-toggle="tab">
{% trans "Power On" %}
</a>
</li>
{% endif %}
</ul>
<!-- Tab panes -->
<div class="tab-content">
{% if instance.status == 1 %}
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="poweroff">
<p>{% trans "This action sends an ACPI shutdown signal to the instance." %}</p>
<form action="{% url 'instances:poweroff' instance.id %}" method="post" role="form" aria-label0="Power off instance form">
{% csrf_token %}
<input type="submit" name="poweroff" class="btn btn-lg btn-success float-right" value="{% trans "Power Off" %}">
<div class="clearfix"></div>
</form>
</div>
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="powercycle">
<p>{% trans "This action forcibly powers off and start the instance and may cause data corruption." %}</p>
<form action="{% url 'instances:powercycle' instance.id %}" method="post" role="form" aria-label="Power cycle instance form">{% csrf_token %}
<input type="submit" name="powercycle" class="btn btn-lg btn-success float-right" value="{% trans "Power Cycle" %}">
<div class="clearfix"></div>
</form>
</div>
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="powerforce">
<p>{% trans "This action forcibly powers off the instance and may cause data corruption." %}</p>
<form action="{% url 'instances:force_off' instance.id %}" method="post" role="form" aria-label="Force to shotdown instance form">
{% csrf_token %}
<input type="submit" name="powerforce" class="btn btn-lg btn-success float-right" value="{% trans "Force Off" %}">
<div class="clearfix"></div>
</form>
</div>
{% if request.user.is_superuser %}
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="suspend">
<p>{% trans "This action suspends the instance." %}</p>
<form action="{% url 'instances:suspend' instance.id %}" method="post" role="form" aria-label="Suspend instance form">{% csrf_token %}
<input type="submit" name="suspend" class="btn btn-lg btn-success float-right" value="{% trans "Suspend" %}">
<div class="clearfix"></div> <div class="clearfix"></div>
</form> </form>
</div> </div>
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="powercycle"> {% endif %}
<p>{% trans "This action forcibly powers off and start the instance and may cause data corruption." %}</p> {% endif %}
<form action="{% url 'instances:powercycle' instance.id %}" method="post" role="form" aria-label="Power cycle instance form">{% csrf_token %} {% if instance.status == 3 %}
<input type="submit" name="powercycle" class="btn btn-lg btn-success float-right" value="{% trans "Power Cycle" %}"> {% if request.user.is_superuser %}
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="resume">
<p>{% trans "This action restore the instance after suspend." %}</p>
<form action="{% url 'instances:resume' instance.id %}" method="post" role="form" aria-label="Resume instance from suspension form">{% csrf_token %}
<input type="submit" name="resume" class="btn btn-lg btn-success float-right" value="{% trans "Resume" %}">
<div class="clearfix"></div> <div class="clearfix"></div>
</form> </form>
</div> </div>
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="powerforce"> <div role="tabpanel" class="tab-pane tab-pane-bordered" id="powerforce">
<p>{% trans "This action forcibly powers off the instance and may cause data corruption." %}</p> <p>{% trans "This action forcibly powers off the instance and may cause data corruption." %}</p>
<form action="{% url 'instances:force_off' instance.id %}" method="post" role="form" aria-label="Force to shotdown instance form"> <form action="{% url 'instances:force_off' instance.id %}" method="post" role="form" aria-label="Force to shutdown form">{% csrf_token %}
{% csrf_token %}
<input type="submit" name="powerforce" class="btn btn-lg btn-success float-right" value="{% trans "Force Off" %}"> <input type="submit" name="powerforce" class="btn btn-lg btn-success float-right" value="{% trans "Force Off" %}">
<div class="clearfix"></div> <div class="clearfix"></div>
</form> </form>
</div> </div>
{% if request.user.is_superuser %} {% else %}
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="suspend"> <div role="tabpanel" class="tab-pane tab-pane-bordered active" id="resume">
<p>{% trans "This action suspends the instance." %}</p> <p>{% trans "Administrator blocked your instance." %}</p>
<form action="{% url 'instances:suspend' instance.id %}" method="post" role="form" aria-label="Suspend instance form">{% csrf_token %} <form action="{% url 'instances:resume' instance.id %}" method="post" role="form" aria-label="Resume instance form">{% csrf_token %}
<input type="submit" name="suspend" class="btn btn-lg btn-success float-right" value="{% trans "Suspend" %}"> <button class="btn btn-lg btn-success disabled float-right">{% trans "Resume" %}</button>
<div class="clearfix"></div>
</form>
</div>
{% endif %}
{% endif %}
{% if instance.status == 3 %}
{% if request.user.is_superuser %}
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="resume">
<p>{% trans "This action restore the instance after suspend." %}</p>
<form action="{% url 'instances:resume' instance.id %}" method="post" role="form" aria-label="Resume instance from suspension form">{% csrf_token %}
<input type="submit" name="resume" class="btn btn-lg btn-success float-right" value="{% trans "Resume" %}">
<div class="clearfix"></div>
</form>
</div>
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="powerforce">
<p>{% trans "This action forcibly powers off the instance and may cause data corruption." %}</p>
<form action="{% url 'instances:force_off' instance.id %}" method="post" role="form" aria-label="Force to shutdown form">{% csrf_token %}
<input type="submit" name="powerforce" class="btn btn-lg btn-success float-right" value="{% trans "Force Off" %}">
<div class="clearfix"></div>
</form>
</div>
{% else %}
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="resume">
<p>{% trans "Administrator blocked your instance." %}</p>
<form action="{% url 'instances:resume' instance.id %}" method="post" role="form" aria-label="Resume instance form">{% csrf_token %}
<button class="btn btn-lg btn-success disabled float-right">{% trans "Resume" %}</button>
<div class="clearfix"></div>
</form>
</div>
{% endif %}
{% endif %}
{% if instance.status == 5 %}
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="boot">
<p>{% trans "Click on Power On button to start this instance." %}</p>
<form action="{% url 'instances:poweron' instance.id %}" method="post" role="form" aria-label="Start instance form">
{% csrf_token %}
{% if instance.is_template %}
<p>{% trans "Template instance cannot be started." %}</p>
<input type="submit" name="poweron" class="btn btn-lg btn-success float-right disabled" value="{% trans "Power On" %}">
{% else %}
<input type="submit" name="poweron" class="btn btn-lg btn-success float-right" value="{% trans "Power On" %}">
{% endif %}
<div class="clearfix"></div> <div class="clearfix"></div>
</form> </form>
</div> </div>
{% endif %} {% endif %}
</div> {% endif %}
{% if instance.status == 5 %}
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="boot">
<p>{% trans "Click on Power On button to start this instance." %}</p>
<form action="{% url 'instances:poweron' instance.id %}" method="post" role="form" aria-label="Start instance form">
{% csrf_token %}
{% if instance.is_template %}
<p>{% trans "Template instance cannot be started." %}</p>
<input type="submit" name="poweron" class="btn btn-lg btn-success float-right disabled" value="{% trans "Power On" %}">
{% else %}
<input type="submit" name="poweron" class="btn btn-lg btn-success float-right" value="{% trans "Power On" %}">
{% endif %}
<div class="clearfix"></div>
</form>
</div>
{% endif %}
</div> </div>
</div> </div>

View file

@ -1,164 +1,162 @@
{% load i18n %} {% load i18n %}
<div role="tabpanel" class="tab-pane" id="resize"> <div role="tabpanel" class="tab-pane" id="resize">
<div role="tabpanel"> <!-- Nav tabs -->
<!-- Nav tabs --> <ul class="nav nav-tabs" role="tablist" aria-label="Instance resize options">
<ul class="nav nav-tabs" role="tablist" aria-label="Instance resize options"> <li class="nav-item">
<li class="nav-item"> <a class="nav-link text-secondary active" href="#resizevm_cpu" aria-controls="resizevm_cpu" role="tab" data-toggle="tab">
<a class="nav-link text-secondary active" href="#resizevm_cpu" aria-controls="resizevm_cpu" role="tab" data-toggle="tab"> {% trans "CPU" %}
{% trans "CPU" %} </a>
</a> </li>
</li> <li class="nav-item">
<li class="nav-item"> <a class="nav-link text-secondary" href="#resizevm_mem" aria-controls="resizevm_mem" role="tab" data-toggle="tab">
<a class="nav-link text-secondary" href="#resizevm_mem" aria-controls="resizevm_mem" role="tab" data-toggle="tab"> {% trans "Memory" %}
{% trans "Memory" %} </a>
</a> </li>
</li> <li class="nav-item">
<li class="nav-item"> <a class="nav-link text-secondary" href="#resizevm_disk" aria-controls="resizevm_disk" role="tab" data-toggle="tab">
<a class="nav-link text-secondary" href="#resizevm_disk" aria-controls="resizevm_disk" role="tab" data-toggle="tab"> {% trans "Disk" %}
{% trans "Disk" %} </a>
</a> </li>
</li> </li>
</li> </ul>
</ul> <!-- Tab panes -->
<!-- Tab panes --> <div class="tab-content">
<div class="tab-content"> <div role="tabpanel" class="tab-pane tab-pane-bordered active" id="resizevm_cpu">
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="resizevm_cpu"> {% if request.user.is_superuser or request.user.is_staff or userinstance.is_change %}
{% if request.user.is_superuser or request.user.is_staff or userinstance.is_change %} {% if instance.status == 5 or not instance.vcpus %}
{% if instance.status == 5 or not instance.vcpus %} <form action="{% url 'instances:resizevm_cpu' instance.id %}" method="post" role="form" aria-label="Resize instance cpu form">{% csrf_token %}
<form action="{% url 'instances:resizevm_cpu' instance.id %}" method="post" role="form" aria-label="Resize instance cpu form">{% csrf_token %} <p class="font-weight-bold">{% trans "Logical host CPUs" %} : {{ vcpu_host }}</p>
<p class="font-weight-bold">{% trans "Logical host CPUs" %} : {{ vcpu_host }}</p> <div class="form-group row">
<div class="form-group row"> <label class="col-sm-4 col-form-label"> {% trans "Current Allocation" %}</label>
<label class="col-sm-4 col-form-label"> {% trans "Current Allocation" %}</label> <div class="col-sm-4">
<div class="col-sm-4"> <select name="cur_vcpu" class="custom-select">
<select name="cur_vcpu" class="custom-select"> {% for cpu in instance.vcpu_range %}
{% for cpu in instance.vcpu_range %} {% if instance.cur_vcpu %}
{% if instance.cur_vcpu %} <option value="{{ cpu }}" {% if cpu == instance.cur_vcpu %}selected{% endif %}>{{ cpu }}</option>
<option value="{{ cpu }}" {% if cpu == instance.cur_vcpu %}selected{% endif %}>{{ cpu }}</option>
{% else %}
<option value="{{ cpu }}" {% if cpu == instance.vcpu %}selected{% endif %}>{{ cpu }}</option>
{% endif %}
{% endfor %}
</select>
</div>
</div>
<div class="form-group row">
<label class="col-sm-4 col-form-label">{% trans "Maximum Allocation" %}</label>
<div class="col-sm-4">
<select name="vcpu" class="custom-select">
{% for cpu in instance.vcpu_range %}
<option value="{{ cpu }}" {% if cpu == instance.vcpu %}selected{% endif %}>{{ cpu }}</option>
{% endfor %}
</select>
</div>
</div>
{% if instance.status == 5 %}
<button type="submit" class="btn btn-lg btn-success float-right" name="resizevm_cpu">{% trans "Resize" %}</button>
{% else %}
<button class="btn btn-lg btn-success float-right disabled">{% trans "Resize" %}</button>
{% endif %}
</form>
<div class="clearfix"></div>
{% else %}
<p class="font-weight-bold">{% trans "Logical Instance Active/Maximum CPUs" %} : {{ instance.cur_vcpu }} / {{ instance.vcpu }} </p>
<div class="col-sm-3"></div>
<div class="col-sm-6">
{% for id, vcpu in instance.vcpus.items %}
<form action="{% url 'instances:set_vcpu' instance.id %}" method="post" role="form" aria-label="Resize instance cpu form">{% csrf_token %}
<div class="col-sm-3">
<input name="id" value="{{ id }}" hidden/>
{% if vcpu.enabled == 'yes' and vcpu.hotpluggable == "yes" %}
<button type="submit" class="btn btn-block btn-success" value="False" name="set_vcpu" title="{% trans "Disable" %}">{{ id }}</button>
{% elif vcpu.enabled == 'yes' and vcpu.hotpluggable == "no" %}
<button type="button" class="btn btn btn-block btn-info" title="{% trans "Constant" %}">{{ id }}</button>
{% else %} {% else %}
<button type="submit" class="btn btn btn-block btn-secondary" value="True" name="set_vcpu" title="{% trans "Enable" %}">{{ id }}</button> <option value="{{ cpu }}" {% if cpu == instance.vcpu %}selected{% endif %}>{{ cpu }}</option>
{% endif %} {% endif %}
</div> {% endfor %}
</form> </select>
{% endfor %}
</div> </div>
<div class="col-sm-3"></div> </div>
<div class="form-group row">
<label class="col-sm-4 col-form-label">{% trans "Maximum Allocation" %}</label>
<div class="col-sm-4">
<select name="vcpu" class="custom-select">
{% for cpu in instance.vcpu_range %}
<option value="{{ cpu }}" {% if cpu == instance.vcpu %}selected{% endif %}>{{ cpu }}</option>
{% endfor %}
</select>
</div>
</div>
{% if instance.status == 5 %}
<button type="submit" class="btn btn-lg btn-success float-right" name="resizevm_cpu">{% trans "Resize" %}</button>
{% else %}
<button class="btn btn-lg btn-success float-right disabled">{% trans "Resize" %}</button>
{% endif %} {% endif %}
{% else %} </form>
{% trans "You don't have permission for resizing instance" %}
<button class="btn btn-lg btn-success float-right disabled">{% trans "Resize" %}</button>
{% endif %}
<div class="clearfix"></div> <div class="clearfix"></div>
</div>
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="resizevm_mem">
{% if request.user.is_superuser or request.user.is_staff or userinstance.is_change %}
<form action="{% url 'instances:resize_memory' instance.id %}" method="post" role="form" aria-label="Resize instance memory form">
{% csrf_token %}
<p class="font-weight-bold">{% trans "Total host memory" %}: {{ memory_host|filesizeformat }}</p>
<div class="form-group row">
<label class="col-sm-4 col-form-label">{% trans "Current Allocation" %} ({% trans "MB" %})</label>
<div class="col-sm-4 js-custom__container">
<select name="cur_memory" class="custom-select js-custom__toggle">
{% for mem in memory_range %}
<option value="{{ mem }}" {% if mem == instance.cur_memory %}selected{% endif %}>{{ mem }}</option>
{% endfor %}
</select>
<input type="text" name="cur_memory_custom" class="custom-select js-custom__toggle" style="display: none" />
<small><input type="checkbox" class="js-custom__checkbox" /> {% trans "Custom value" %}</small>
</div>
</div>
<div class="form-group row">
<label class="col-sm-4 col-form-label">
{% trans "Maximum Allocation" %} ({% trans "MB" %})
</label>
<div class="col-sm-4 js-custom__container">
<select name="memory" class="form-control js-custom__toggle">
{% for mem in memory_range %}
<option value="{{ mem }}"
{% if mem == instance.memory %}selected{% endif %}>{{ mem }}</option>
{% endfor %}
</select>
<input type="text" name="memory_custom" class="form-control js-custom__toggle" style="display: none" />
<small><input type="checkbox" class="js-custom__checkbox" /> {% trans "Custom value" %}</small>
</div>
</div>
<button type="submit" class="btn btn-lg btn-success float-right" name="resizevm_mem">{% trans "Resize" %}</button>
</form>
{% else %} {% else %}
{% trans "You don't have permission for resizing instance" %} <p class="font-weight-bold">{% trans "Logical Instance Active/Maximum CPUs" %} : {{ instance.cur_vcpu }} / {{ instance.vcpu }} </p>
<button class="btn btn-lg btn-success float-right disabled">{% trans "Resize" %}</button> <div class="col-sm-3"></div>
{% endif %} <div class="col-sm-6">
<div class="clearfix"></div> {% for id, vcpu in instance.vcpus.items %}
</div> <form action="{% url 'instances:set_vcpu' instance.id %}" method="post" role="form" aria-label="Resize instance cpu form">{% csrf_token %}
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="resizevm_disk"> <div class="col-sm-3">
{% if request.user.is_superuser or request.user.is_staff or userinstance.is_change %} <input name="id" value="{{ id }}" hidden/>
<form action="{% url 'instances:resize_disk' instance.id %}" method="post" role="form" aria-label="Resize instance disk form"> {% if vcpu.enabled == 'yes' and vcpu.hotpluggable == "yes" %}
{% csrf_token %} <button type="submit" class="btn btn-block btn-success" value="False" name="set_vcpu" title="{% trans "Disable" %}">{{ id }}</button>
<p class="font-weight-bold">{% trans "Disk allocation (GB)" %}:</p> {% elif vcpu.enabled == 'yes' and vcpu.hotpluggable == "no" %}
{% for disk in instance.disks %} <button type="button" class="btn btn btn-block btn-info" title="{% trans "Constant" %}">{{ id }}</button>
<div class="form-group row"> {% else %}
<label class="col-sm-4 col-form-label">{% trans "Current Allocation" %} ({{ disk.dev }})</label> <button type="submit" class="btn btn btn-block btn-secondary" value="True" name="set_vcpu" title="{% trans "Enable" %}">{{ id }}</button>
{% if disk.storage is None %} {% endif %}
<div class="col-sm-4 js-custom__container">
<div class="alert alert-danger">
{% trans "Error getting disk info" %}
</div>
</div> </div>
{% else %} </form>
<div class="col-sm-4 js-custom__container">
<input type="number" name="disk_size_{{ disk.dev }}" class="form-control" value="{% widthratio disk.size 1073741824 1 %}" />
</div>
{% endif %}
</div>
{% endfor %} {% endfor %}
{% if instance.status == 5 %} </div>
<button type="submit" class="btn btn-lg btn-success float-right" name="resizevm_disk">{% trans "Resize" %}</button> <div class="col-sm-3"></div>
{% else %}
<button class="btn btn-lg btn-success float-right disabled">{% trans "Resize" %}</button>
{% endif %}
</form>
{% else %}
{% trans "You don't have permission for resizing instance" %}
<button class="btn btn-lg btn-success float-right disabled">{% trans "Resize" %}</button>
{% endif %} {% endif %}
<div class="clearfix"></div> {% else %}
</div> {% trans "You don't have permission for resizing instance" %}
<button class="btn btn-lg btn-success float-right disabled">{% trans "Resize" %}</button>
{% endif %}
<div class="clearfix"></div>
</div>
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="resizevm_mem">
{% if request.user.is_superuser or request.user.is_staff or userinstance.is_change %}
<form action="{% url 'instances:resize_memory' instance.id %}" method="post" role="form" aria-label="Resize instance memory form">
{% csrf_token %}
<p class="font-weight-bold">{% trans "Total host memory" %}: {{ memory_host|filesizeformat }}</p>
<div class="form-group row">
<label class="col-sm-4 col-form-label">{% trans "Current Allocation" %} ({% trans "MB" %})</label>
<div class="col-sm-4 js-custom__container">
<select name="cur_memory" class="custom-select js-custom__toggle">
{% for mem in memory_range %}
<option value="{{ mem }}" {% if mem == instance.cur_memory %}selected{% endif %}>{{ mem }}</option>
{% endfor %}
</select>
<input type="text" name="cur_memory_custom" class="custom-select js-custom__toggle" style="display: none" />
<small><input type="checkbox" class="js-custom__checkbox" /> {% trans "Custom value" %}</small>
</div>
</div>
<div class="form-group row">
<label class="col-sm-4 col-form-label">
{% trans "Maximum Allocation" %} ({% trans "MB" %})
</label>
<div class="col-sm-4 js-custom__container">
<select name="memory" class="form-control js-custom__toggle">
{% for mem in memory_range %}
<option value="{{ mem }}"
{% if mem == instance.memory %}selected{% endif %}>{{ mem }}</option>
{% endfor %}
</select>
<input type="text" name="memory_custom" class="form-control js-custom__toggle" style="display: none" />
<small><input type="checkbox" class="js-custom__checkbox" /> {% trans "Custom value" %}</small>
</div>
</div>
<button type="submit" class="btn btn-lg btn-success float-right" name="resizevm_mem">{% trans "Resize" %}</button>
</form>
{% else %}
{% trans "You don't have permission for resizing instance" %}
<button class="btn btn-lg btn-success float-right disabled">{% trans "Resize" %}</button>
{% endif %}
<div class="clearfix"></div>
</div>
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="resizevm_disk">
{% if request.user.is_superuser or request.user.is_staff or userinstance.is_change %}
<form action="{% url 'instances:resize_disk' instance.id %}" method="post" role="form" aria-label="Resize instance disk form">
{% csrf_token %}
<p class="font-weight-bold">{% trans "Disk allocation (GB)" %}:</p>
{% for disk in instance.disks %}
<div class="form-group row">
<label class="col-sm-4 col-form-label">{% trans "Current Allocation" %} ({{ disk.dev }})</label>
{% if disk.storage is None %}
<div class="col-sm-4 js-custom__container">
<div class="alert alert-danger">
{% trans "Error getting disk info" %}
</div>
</div>
{% else %}
<div class="col-sm-4 js-custom__container">
<input type="number" name="disk_size_{{ disk.dev }}" class="form-control" value="{% widthratio disk.size 1073741824 1 %}" />
</div>
{% endif %}
</div>
{% endfor %}
{% if instance.status == 5 %}
<button type="submit" class="btn btn-lg btn-success float-right" name="resizevm_disk">{% trans "Resize" %}</button>
{% else %}
<button class="btn btn-lg btn-success float-right disabled">{% trans "Resize" %}</button>
{% endif %}
</form>
{% else %}
{% trans "You don't have permission for resizing instance" %}
<button class="btn btn-lg btn-success float-right disabled">{% trans "Resize" %}</button>
{% endif %}
<div class="clearfix"></div>
</div> </div>
</div> </div>
</div> </div>

File diff suppressed because it is too large Load diff

View file

@ -1,83 +1,81 @@
{% load i18n %} {% load i18n %}
{% load icons %} {% load icons %}
<div role="tabpanel" class="tab-pane" id="snapshots"> <div role="tabpanel" class="tab-pane" id="snapshots">
<div role="tabpanel"> <!-- Nav tabs -->
<!-- Nav tabs --> <ul class="nav nav-tabs" role="tablist" aria-label="Instance snapshot menu">
<ul class="nav nav-tabs" role="tablist" aria-label="Instance snapshot menu"> <li class="nav-item">
<li class="nav-item"> <a class="nav-link text-secondary active" href="#takesnapshot" aria-controls="takesnapshot" role="tab" data-toggle="tab">
<a class="nav-link text-secondary active" href="#takesnapshot" aria-controls="takesnapshot" role="tab" data-toggle="tab"> {% trans "Take Snapshot" %}
{% trans "Take Snapshot" %} </a>
</a> </li>
</li> <li class="nav-item">
<li class="nav-item"> <a class="nav-link text-secondary" href="#managesnapshot" aria-controls="managesnapshot" role="tab" data-toggle="tab">
<a class="nav-link text-secondary" href="#managesnapshot" aria-controls="managesnapshot" role="tab" data-toggle="tab"> {% trans "Manage Snapshots" %}
{% trans "Manage Snapshots" %} </a>
</a> </li>
</li> </ul>
</ul> <!-- Tab panes -->
<!-- Tab panes --> <div class="tab-content">
<div class="tab-content"> <div role="tabpanel" class="tab-pane tab-pane-bordered active" id="takesnapshot">
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="takesnapshot"> <p>{% trans "This may take more than an hour, depending on how much content is on your instance and how large the disk is. It could cause web server timeout.." %}</p>
<p>{% trans "This may take more than an hour, depending on how much content is on your instance and how large the disk is. It could cause web server timeout.." %}</p> <form action="{% url 'instances:snapshot' instance.id %}" class="form-inline" method="post" role="form" aria-label="Create snapshot form">
<form action="{% url 'instances:snapshot' instance.id %}" class="form-inline" method="post" role="form" aria-label="Create snapshot form"> {% csrf_token %}
{% csrf_token %} <div class="form-group row">
<div class="form-group row"> <div class="col-sm-12">
<div class="col-sm-12"> <input type="text" class="form-control form-control-lg" name="name" placeholder="{% trans "Enter Snapshot Name" %}" maxlength="14">
<input type="text" class="form-control form-control-lg" name="name" placeholder="{% trans "Enter Snapshot Name" %}" maxlength="14">
</div>
</div> </div>
<input type="submit" class="btn btn-lg btn-success float-right" name="snapshot" value="{% trans "Take Snapshot" %}" onclick="showPleaseWaitDialog();"> </div>
</form> <input type="submit" class="btn btn-lg btn-success float-right" name="snapshot" value="{% trans "Take Snapshot" %}" onclick="showPleaseWaitDialog();">
<div class="clearfix"></div> </form>
</div> <div class="clearfix"></div>
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="managesnapshot"> </div>
{% if instance.snapshots %} <div role="tabpanel" class="tab-pane tab-pane-bordered" id="managesnapshot">
<p>{% trans "Choose a snapshot for restore/delete" %}</p> {% if instance.snapshots %}
<div class="table-responsive"> <p>{% trans "Choose a snapshot for restore/delete" %}</p>
<table class="table"> <div class="table-responsive">
<thead> <table class="table">
<th scope="col">{% trans "Name" %}</th> <thead>
<th scope="col">{% trans "Date" %}</th> <th scope="col">{% trans "Name" %}</th>
<th scope="colgroup" colspan="2">{% trans "Action" %}</th> <th scope="col">{% trans "Date" %}</th>
</thead> <th scope="colgroup" colspan="2">{% trans "Action" %}</th>
<tbody> </thead>
{% for snap in instance.snapshots %} <tbody>
<tr> {% for snap in instance.snapshots %}
<td><strong>{{ snap.name }}</strong></td> <tr>
<td>{{ snap.date|date:"M d H:i:s" }}</td> <td><strong>{{ snap.name }}</strong></td>
<td style="width:30px;"> <td>{{ snap.date|date:"M d H:i:s" }}</td>
<form action="{% url 'instances:revert_snapshot' instance.id %}" method="post" role="form" aria-label="Restore snapshot form"> <td style="width:30px;">
{% csrf_token %} <form action="{% url 'instances:revert_snapshot' instance.id %}" method="post" role="form" aria-label="Restore snapshot form">
<input type="hidden" name="name" value="{{ snap.name }}"> {% csrf_token %}
{% if instance.status == 5 %} <input type="hidden" name="name" value="{{ snap.name }}">
<button type="submit" class="btn btn-sm btn-secondary" name="revert_snapshot" title="{% trans 'Revert to this Snapshot' %}" onclick="return confirm('Are you sure?')"> {% if instance.status == 5 %}
<span class="fa fa-download"></span> <button type="submit" class="btn btn-sm btn-secondary" name="revert_snapshot" title="{% trans 'Revert to this Snapshot' %}" onclick="return confirm('Are you sure?')">
</button> <span class="fa fa-download"></span>
{% else %}
<button type="button" class="btn btn-sm btn-secondary disabled"
title="{% trans "To restore snapshots you need Power Off the instance." %}">
<span class="fa fa-download"></span>
</button>
{% endif %}
</form>
</td>
<td style="width:30px;">
<form action="{% url 'instances:delete_snapshot' instance.id %}" method="post" role="form" aria-label="Delete snapshot form">{% csrf_token %}
<input type="hidden" name="name" value="{{ snap.name }}">
<button type="submit" class="btn btn-sm btn-danger" title="{% trans 'Delete Snapshot' %}" onclick="return confirm('{% trans "Are you sure?" %}')">
{% icon 'trash' %}
</button> </button>
</form> {% else %}
</td> <button type="button" class="btn btn-sm btn-secondary disabled"
</tr> title="{% trans "To restore snapshots you need Power Off the instance." %}">
{% endfor %} <span class="fa fa-download"></span>
</tbody> </button>
</table> {% endif %}
</div> </form>
{% else %} </td>
<p>{% trans "You do not have any snapshots" %}</p> <td style="width:30px;">
{% endif %} <form action="{% url 'instances:delete_snapshot' instance.id %}" method="post" role="form" aria-label="Delete snapshot form">{% csrf_token %}
</div> <input type="hidden" name="name" value="{{ snap.name }}">
<button type="submit" class="btn btn-sm btn-danger" title="{% trans 'Delete Snapshot' %}" onclick="return confirm('{% trans "Are you sure?" %}')">
{% icon 'trash' %}
</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<p>{% trans "You do not have any snapshots" %}</p>
{% endif %}
</div> </div>
</div> </div>
</div> </div>

View file

@ -1,99 +1,97 @@
{% load i18n %} {% load i18n %}
<div role="tabpanel" class="tab-pane" id="graphics"> <div role="tabpanel" class="tab-pane" id="graphics">
<div role="tabpanel"> <!-- Nav tabs -->
<!-- Nav tabs --> <ul class="nav nav-tabs" role="tablist" aria-label="Instance graphs and logs menu">
<ul class="nav nav-tabs" role="tablist" aria-label="Instance graphs and logs menu"> <li class="nav-item">
<li class="nav-item"> <a class="nav-link text-secondary active" href="#graphs" id="graphtab" aria-controls="graphs" role="tab" data-toggle="tab" aria-controls="graphs" aria-selected="true">
<a class="nav-link text-secondary active" href="#graphs" id="graphtab" aria-controls="graphs" role="tab" data-toggle="tab" aria-controls="graphs" aria-selected="true"> {% trans "Real Time" %}
{% trans "Real Time" %} </a>
</a> </li>
</li> <li class="nav-item">
<li class="nav-item"> <a class="nav-link text-secondary" href="#logs" id="logtab" aria-controls="logs" role="tab" data-toggle="tab" aria-controls="logs" onclick='update_logs_table("{{ instance.name }}");'>
<a class="nav-link text-secondary" href="#logs" id="logtab" aria-controls="logs" role="tab" data-toggle="tab" aria-controls="logs" onclick='update_logs_table("{{ instance.name }}");'> {% trans "Logs" %}
{% trans "Logs" %} </a>
</a> </li>
</li> </ul>
</ul> <!-- Tab panes -->
<!-- Tab panes --> <div class="tab-content">
<div class="tab-content"> <div role="tabpanel" class="tab-pane tab-pane-bordered active" id="graphs">
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="graphs"> <div class="mb-1 card border-success">
<div class="mb-1 card border-success"> <div class="card-header">
<div class="card-header"> <h5 class="card-title"><i class="fa fa-long-arrow-right"></i>
<h5 class="card-title"><i class="fa fa-long-arrow-right"></i> {% trans "CPU Usage" %}</h5>
{% trans "CPU Usage" %}</h5> </div>
</div> <div class="card-body">
<div class="card-body"> <div class="flot-chart">
<div class="flot-chart"> <div class="flot-chart-content" id="flot-moving-line-chart">
<div class="flot-chart-content" id="flot-moving-line-chart"> <canvas id="cpuChart" width="735" height="160"></canvas>
<canvas id="cpuChart" width="735" height="160"></canvas>
</div>
</div> </div>
</div> </div>
</div> </div>
<div class="mb-1 card border-danger">
<div class="card-header">
<h5 class="card-title"><i class="fa fa-long-arrow-right"></i>
{% trans "Memory Usage" %}</h5>
</div>
<div class="card-body">
<div class="flot-chart">
<div class="flot-chart-content" id="flot-moving-line-chart">
<canvas id="memChart" width="735" height="160"></canvas>
</div>
</div>
</div>
</div>
{% for net in instance.networks %}
<div class="mb-1 card border-info">
<div class="card-header">
<h5 class="card-title"><i class="fa fa-long-arrow-right"></i>
{% trans "Bandwidth Device" %}: eth{{ forloop.counter0 }}</h5>
</div>
<div class="card-body">
<div class="flot-chart">
<div class="flot-chart-content" id="flot-moving-line-chart">
<canvas id="netEth{{ forloop.counter0 }}Chart" width="735" height="160"></canvas>
</div>
</div>
</div>
</div>
{% endfor %}
{% for disk in instance.disks %}
<div class="mb-1 card border-warning">
<div class="card-header">
<h5 class="card-title"><i class="fa fa-long-arrow-right"></i>
{% trans "Disk I/O device" %}: {{ disk.dev }}</h5>
</div>
<div class="card-body">
<div class="flot-chart">
<div class="flot-chart-content" id="flot-moving-line-chart">
<canvas id="blk{{ disk.dev }}Chart" width="735" height="160"></canvas>
</div>
</div>
</div>
</div>
{% endfor %}
<div class="clearfix"></div>
</div> </div>
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="logs"> <div class="mb-1 card border-danger">
<div class="table-responsive"> <div class="card-header">
<table class="table table-striped sortable-theme-bootstrap" id="logs_table" data-sortable> <h5 class="card-title"><i class="fa fa-long-arrow-right"></i>
<thead> {% trans "Memory Usage" %}</h5>
<tr> </div>
<th scope="col">{% trans "Date" %}</th> <div class="card-body">
<th scope="col">{% trans "User" %}</th> <div class="flot-chart">
<th scope="col">{% trans "Message" %}</th> <div class="flot-chart-content" id="flot-moving-line-chart">
</tr> <canvas id="memChart" width="735" height="160"></canvas>
</thead> </div>
<tbody class="searchable"> </div>
<tr>
<td colspan="3"><i>{% trans 'None' %}...</i></td>
</tr>
</tbody>
</table>
</div> </div>
<div class="clearfix"></div>
</div> </div>
{% for net in instance.networks %}
<div class="mb-1 card border-info">
<div class="card-header">
<h5 class="card-title"><i class="fa fa-long-arrow-right"></i>
{% trans "Bandwidth Device" %}: eth{{ forloop.counter0 }}</h5>
</div>
<div class="card-body">
<div class="flot-chart">
<div class="flot-chart-content" id="flot-moving-line-chart">
<canvas id="netEth{{ forloop.counter0 }}Chart" width="735" height="160"></canvas>
</div>
</div>
</div>
</div>
{% endfor %}
{% for disk in instance.disks %}
<div class="mb-1 card border-warning">
<div class="card-header">
<h5 class="card-title"><i class="fa fa-long-arrow-right"></i>
{% trans "Disk I/O device" %}: {{ disk.dev }}</h5>
</div>
<div class="card-body">
<div class="flot-chart">
<div class="flot-chart-content" id="flot-moving-line-chart">
<canvas id="blk{{ disk.dev }}Chart" width="735" height="160"></canvas>
</div>
</div>
</div>
</div>
{% endfor %}
<div class="clearfix"></div>
</div>
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="logs">
<div class="table-responsive">
<table class="table table-striped sortable-theme-bootstrap" id="logs_table" data-sortable>
<thead>
<tr>
<th scope="col">{% trans "Date" %}</th>
<th scope="col">{% trans "User" %}</th>
<th scope="col">{% trans "Message" %}</th>
</tr>
</thead>
<tbody class="searchable">
<tr>
<td colspan="3"><i>{% trans 'None' %}...</i></td>
</tr>
</tbody>
</table>
</div>
<div class="clearfix"></div>
</div> </div>
</div> </div>
</div> </div>

View file

@ -20,6 +20,7 @@ urlpatterns = [
path('<int:pk>/migrate/', views.migrate, name='migrate'), path('<int:pk>/migrate/', views.migrate, name='migrate'),
path('<int:pk>/status/', views.status, name='status'), path('<int:pk>/status/', views.status, name='status'),
path('<int:pk>/stats/', views.stats, name='stats'), 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>/rootpasswd/', views.set_root_pass, name='rootpasswd'),
path('<int:pk>/add_public_key/', views.add_public_key, name='add_public_key'), 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'), path('<int:pk>/resizevm_cpu/', views.resizevm_cpu, name='resizevm_cpu'),

View file

@ -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): def guess_mac_address(request, vname):
data = {"vname": vname} data = {"vname": vname}

View file

@ -296,12 +296,12 @@
<button type="submit" class="btn btn-sm btn-primary" <button type="submit" class="btn btn-sm btn-primary"
name="modify_fixed_address" name="modify_fixed_address"
title="{% trans "Edit entry" %}" onclick="return confirm('{% trans "Are you sure?" %}')"> 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>
<button type="submit" class="btn btn-sm btn-danger" <button type="submit" class="btn btn-sm btn-danger"
name="delete_fixed_address" name="delete_fixed_address"
title="{% trans "Delete entry" %}" onclick="return confirm('{% trans "Are you sure?" %}')"> title="{% trans "Delete entry" %}" onclick="return confirm('{% trans "Are you sure?" %}')">
<i class="fa fa-trash"></i> <span class="fa fa-trash"></span>
</button> </button>
</td> </td>
</form> </form>

View file

@ -1,3 +1,4 @@
import json
import os.path import os.path
import time import time
@ -20,6 +21,10 @@ try:
VIR_MIGRATE_POSTCOPY, VIR_MIGRATE_POSTCOPY,
) )
from libvirt import VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT from libvirt import VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT
from libvirt_qemu import (
qemuAgentCommand,
VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT
)
except: except:
from libvirt import libvirtError, VIR_DOMAIN_XML_SECURE, VIR_MIGRATE_LIVE from libvirt import libvirtError, VIR_DOMAIN_XML_SECURE, VIR_MIGRATE_LIVE
@ -160,6 +165,35 @@ class wvmInstance(wvmConnect):
self._ip_cache = None self._ip_cache = None
self.instance = self.get_instance(vname) 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): def start(self):
self.instance.create() self.instance.create()