|
|
@@ -2,6 +2,16 @@
|
|
|
{% block head %}
|
|
|
{{ super() }}
|
|
|
<style type="text/css">
|
|
|
+ @media (min-width: 768px) {
|
|
|
+ .form-horizontal .control-label {
|
|
|
+ text-align: left;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ label>span {
|
|
|
+ color: deepskyblue;
|
|
|
+ }
|
|
|
+
|
|
|
.table {
|
|
|
font-size: 12px;
|
|
|
border-width: 1px;
|
|
|
@@ -176,6 +186,22 @@
|
|
|
$('#new_password').val('');
|
|
|
$('#new_password').attr({type: "password"});
|
|
|
});
|
|
|
+
|
|
|
+ $('#allocate_bandwidth_modal').on('show.bs.modal', function (me) {
|
|
|
+ $('#bandwidth_unit').on('changed.bs.select', function (me) {
|
|
|
+ render_bandwidth_slider($("#bandwidth"), 'update', $('#bandwidth_unit').val())
|
|
|
+ });
|
|
|
+
|
|
|
+ render_bandwidth_slider($("#bandwidth"), 'create', 'm');
|
|
|
+ });
|
|
|
+
|
|
|
+ $('#batch_allocate_bandwidth_modal').on('show.bs.modal', function (me) {
|
|
|
+ $('#batch_bandwidth_unit').on('changed.bs.select', function (me) {
|
|
|
+ render_bandwidth_slider($("#batch_bandwidth"), 'update', $('#batch_bandwidth_unit').val())
|
|
|
+ });
|
|
|
+
|
|
|
+ render_bandwidth_slider($("#batch_bandwidth"), 'create', 'm');
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
function refresh() {
|
|
|
@@ -376,6 +402,20 @@
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ function allocate_bandwidth(uuids, bandwidth, bandwidth_unit) {
|
|
|
+ $.ajax({
|
|
|
+ url : '/api/guests/_allocate_bandwidth/' + uuids.join(',') + '/' + bandwidth + '/' + bandwidth_unit,
|
|
|
+ type : 'PUT',
|
|
|
+ contentType: "application/json; charset=utf-8",
|
|
|
+ error : function() {
|
|
|
+ alter_danger('实例分配带宽指令发送失败!');
|
|
|
+ },
|
|
|
+ success : function() {
|
|
|
+ alter_success('实例分配带宽指令发送成功!');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
function remove(uuids) {
|
|
|
$.ajax({
|
|
|
url : '/api/guests/' + uuids.join(','),
|
|
|
@@ -467,6 +507,12 @@
|
|
|
$('#resume_modal').modal('hide');
|
|
|
}
|
|
|
|
|
|
+ function allocate_bandwidth_at(me) {
|
|
|
+ var uuid = $('#instance_uuid').val();
|
|
|
+ allocate_bandwidth([uuid], $('#bandwidth').val(), $('#bandwidth_unit').val());
|
|
|
+ $('#allocate_bandwidth_modal').modal('hide');
|
|
|
+ }
|
|
|
+
|
|
|
function delete_at(me) {
|
|
|
var uuid = $('#instance_uuid').val();
|
|
|
remove([uuid]);
|
|
|
@@ -578,6 +624,14 @@
|
|
|
$('#batch_resume_modal').modal('hide');
|
|
|
}
|
|
|
|
|
|
+ function batch_allocate_bandwidth() {
|
|
|
+ var uuids = get_checked_uuids();
|
|
|
+ if (uuids) {
|
|
|
+ allocate_bandwidth(uuids, $('#batch_bandwidth').val(), $('#batch_bandwidth_unit').val());
|
|
|
+ }
|
|
|
+ $('#batch_allocate_bandwidth_modal').modal('hide');
|
|
|
+ }
|
|
|
+
|
|
|
function batch_delete() {
|
|
|
var uuids = get_checked_uuids();
|
|
|
if (uuids) {
|
|
|
@@ -676,10 +730,10 @@
|
|
|
<td>
|
|
|
CPU : {{ item.cpu }} 核<br />
|
|
|
内存 : {{ item.memory }} GB<br />
|
|
|
- 带宽 :
|
|
|
+ 带宽 :
|
|
|
{% if item.bandwidth == 0 %}
|
|
|
- <span style="font-size: 16px;">
|
|
|
- ∞
|
|
|
+ <span style="font-size: 16px;" title="无限带宽">
|
|
|
+ ∞
|
|
|
</span>
|
|
|
{% elif item.bandwidth > 0 and item.bandwidth < 1000**2 %}
|
|
|
{{ item.bandwidth // 1000 }}
|
|
|
@@ -774,6 +828,14 @@
|
|
|
<a href="/guest/vnc/{{ item.uuid }}" target="_blank">远程连接</a>
|
|
|
</li>
|
|
|
<li class="divider"></li>
|
|
|
+ <li class="">
|
|
|
+ <a href="javascript:;" data-toggle="modal" data-target="#allocate_bandwidth_modal"
|
|
|
+ onclick="$('#instance_uuid').val($($(this).parent().parent().parent().parent().parent().children()[0]).text());
|
|
|
+ $('#allocate_bandwidth_instance_desc').text($($(this).parent().parent().parent().parent().parent().children()[2]).find('div a')[0].textContent + '/' + $($(this).parent().parent().parent().parent().parent().children()[2]).find('div p')[0].textContent)">
|
|
|
+ 分配带宽
|
|
|
+ </a>
|
|
|
+ </li>
|
|
|
+ <li class="divider"></li>
|
|
|
<li class="">
|
|
|
<a href="javascript:;" data-toggle="modal" data-target="#reset_password_modal"
|
|
|
onclick="$('#reset_password_type').val('single')">
|
|
|
@@ -836,6 +898,10 @@
|
|
|
</a>
|
|
|
</li>
|
|
|
<li class="divider"></li>
|
|
|
+ <li>
|
|
|
+ <a href="javascript:;" data-toggle="modal" data-target="#batch_allocate_bandwidth_modal">分配带宽</a>
|
|
|
+ </li>
|
|
|
+ <li class="divider"></li>
|
|
|
<li>
|
|
|
<a href="javascript:;" data-toggle="modal" data-target="#batch_force_shutdown_modal">强制停止</a>
|
|
|
</li>
|
|
|
@@ -975,7 +1041,7 @@
|
|
|
</div>
|
|
|
<div class="modal-body">
|
|
|
<p></p>
|
|
|
- <p>删除的虚拟机将无法找回,上面数据将永久消失。您确定要执行批量删除选择的虚拟机吗?</p>
|
|
|
+ <p>删除的虚拟机将无法找回,上面数据将永久消失。您确定要执行批量删除选定的虚拟机吗?</p>
|
|
|
</div>
|
|
|
<div class="modal-footer">
|
|
|
<button type="button" class="btn btn-sm btn-primary" onclick="batch_delete();">确定</button>
|
|
|
@@ -1011,7 +1077,7 @@
|
|
|
</div>
|
|
|
<div class="modal-body">
|
|
|
<p></p>
|
|
|
- <p>您确定要执行批量重启选择的虚拟机吗?</p>
|
|
|
+ <p>您确定要执行批量重启选定的虚拟机吗?</p>
|
|
|
</div>
|
|
|
<div class="modal-footer">
|
|
|
<button type="button" class="btn btn-sm btn-primary" onclick="batch_reboot();">确定</button>
|
|
|
@@ -1047,7 +1113,7 @@
|
|
|
</div>
|
|
|
<div class="modal-body">
|
|
|
<p></p>
|
|
|
- <p>您确定要执行批量强制重启选择的虚拟机吗?</p>
|
|
|
+ <p>您确定要执行批量强制重启选定的虚拟机吗?</p>
|
|
|
</div>
|
|
|
<div class="modal-footer">
|
|
|
<button type="button" class="btn btn-sm btn-primary" onclick="batch_force_reboot();">确定</button>
|
|
|
@@ -1083,7 +1149,7 @@
|
|
|
</div>
|
|
|
<div class="modal-body">
|
|
|
<p></p>
|
|
|
- <p>您确定要执行批量停止选择的虚拟机吗?</p>
|
|
|
+ <p>您确定要执行批量停止选定的虚拟机吗?</p>
|
|
|
</div>
|
|
|
<div class="modal-footer">
|
|
|
<button type="button" class="btn btn-sm btn-primary" onclick="batch_shutdown();">确定</button>
|
|
|
@@ -1119,7 +1185,7 @@
|
|
|
</div>
|
|
|
<div class="modal-body">
|
|
|
<p></p>
|
|
|
- <p>您确定要执行批量强制停止选择的虚拟机吗?</p>
|
|
|
+ <p>您确定要执行批量强制停止选定的虚拟机吗?</p>
|
|
|
</div>
|
|
|
<div class="modal-footer">
|
|
|
<button type="button" class="btn btn-sm btn-primary" onclick="batch_force_shutdown();">确定</button>
|
|
|
@@ -1175,7 +1241,7 @@
|
|
|
</div>
|
|
|
<div class="modal-body">
|
|
|
<p></p>
|
|
|
- <p>您确定要执行批量暂停选择的虚拟机吗?</p>
|
|
|
+ <p>您确定要执行批量暂停选定的虚拟机吗?</p>
|
|
|
</div>
|
|
|
<div class="modal-footer">
|
|
|
<button type="button" class="btn btn-sm btn-primary" onclick="batch_suspend();">确定</button>
|
|
|
@@ -1211,7 +1277,7 @@
|
|
|
</div>
|
|
|
<div class="modal-body">
|
|
|
<p></p>
|
|
|
- <p>您确定要执行批量恢复暂停的选择的虚拟机吗?</p>
|
|
|
+ <p>您确定要执行批量恢复暂停的选定的虚拟机吗?</p>
|
|
|
</div>
|
|
|
<div class="modal-footer">
|
|
|
<button type="button" class="btn btn-sm btn-primary" onclick="batch_resume();">确定</button>
|
|
|
@@ -1247,7 +1313,7 @@
|
|
|
</div>
|
|
|
<div class="modal-body">
|
|
|
<p></p>
|
|
|
- <p>您确定要执行批量启动选择的虚拟机吗?</p>
|
|
|
+ <p>您确定要执行批量启动选定的虚拟机吗?</p>
|
|
|
</div>
|
|
|
<div class="modal-footer">
|
|
|
<button type="button" class="btn btn-sm btn-primary" onclick="batch_boot();">确定</button>
|
|
|
@@ -1256,4 +1322,82 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
+
|
|
|
+<div class="modal" id="allocate_bandwidth_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
|
|
|
+ <div class="modal-dialog modal-lg">
|
|
|
+ <div class="modal-content">
|
|
|
+ <div class="modal-header">
|
|
|
+ <h4 class="modal-title">给虚拟机重新分配带宽:</h4>
|
|
|
+ </div>
|
|
|
+ <div class="modal-body" style="padding-top: 0;">
|
|
|
+ <div class="example-box-wrapper">
|
|
|
+ <form class="form-horizontal bordered-row">
|
|
|
+ <div class="form-group">
|
|
|
+ <div class="col-sm-1"></div>
|
|
|
+ <label class="col-sm-2 control-label"><span class="glyph-icon icon-elusive-compass-circled"></span> 实例名称</label>
|
|
|
+ <div class="col-sm-9">
|
|
|
+ <h3 style="color: orangered;" id="allocate_bandwidth_instance_desc"></h3>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <div class="col-sm-1"></div>
|
|
|
+ <label class="col-sm-2 control-label"><span class="glyph-icon icon-signal"></span> 内网带宽</label>
|
|
|
+ <div class="col-sm-7">
|
|
|
+ <input id="bandwidth" title="内网带宽" type="text" name="bandwidth">
|
|
|
+ </div>
|
|
|
+ <div class="col-sm-2" style="bottom: -10px;">
|
|
|
+ <select id="bandwidth_unit" name="bandwidth_unit" title="单位..." class="selectpicker" data-width="80%">
|
|
|
+ <option value="k"> Kbps</option>
|
|
|
+ <option value="m" selected> Mbps</option>
|
|
|
+ <option value="g"> Gbps</option>
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </form>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="modal-footer">
|
|
|
+ <button type="button" class="btn btn-sm btn-primary" onclick="allocate_bandwidth_at();">确定</button>
|
|
|
+ <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</div>
|
|
|
+
|
|
|
+<div class="modal" id="batch_allocate_bandwidth_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
|
|
|
+ <div class="modal-dialog modal-lg">
|
|
|
+ <div class="modal-content">
|
|
|
+ <div class="modal-header">
|
|
|
+ <h4 class="modal-title">批量分配带宽给虚拟机:</h4>
|
|
|
+ </div>
|
|
|
+ <div class="modal-body">
|
|
|
+ <p></p>
|
|
|
+ <p>您确定要给选定的虚拟机重新分配带宽吗?</p>
|
|
|
+ <p></p>
|
|
|
+ <div class="example-box-wrapper">
|
|
|
+ <form class="form-horizontal bordered-row">
|
|
|
+ <div class="form-group">
|
|
|
+ <div class="col-sm-1"></div>
|
|
|
+ <label class="col-sm-2 control-label"><span class="glyph-icon icon-signal"></span> 内网带宽</label>
|
|
|
+ <div class="col-sm-7">
|
|
|
+ <input id="batch_bandwidth" title="内网带宽" type="text" name="batch_bandwidth">
|
|
|
+ </div>
|
|
|
+ <div class="col-sm-2" style="bottom: -10px;">
|
|
|
+ <select id="batch_bandwidth_unit" name="batch_bandwidth_unit" title="单位..." class="selectpicker" data-width="80%">
|
|
|
+ <option value="k"> Kbps</option>
|
|
|
+ <option value="m" selected> Mbps</option>
|
|
|
+ <option value="g"> Gbps</option>
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </form>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="modal-footer">
|
|
|
+ <button type="button" class="btn btn-sm btn-primary" onclick="batch_allocate_bandwidth();">确定</button>
|
|
|
+ <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</div>
|
|
|
{% endblock content %}
|