config_show.html 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882
  1. {% extends theme("layout.html") %}
  2. {% block head %}
  3. {{ super() }}
  4. <style type="text/css">
  5. @media (min-width: 768px) {
  6. .form-horizontal .control-label {
  7. text-align: left;
  8. }
  9. }
  10. label>span {
  11. color: deepskyblue;
  12. }
  13. #batch_change_disk_quota_form label {
  14. padding-left: 0;
  15. padding-right: 0;
  16. }
  17. .btn,
  18. .form-group>div>div,
  19. .form-control {
  20. border-radius: 0;
  21. }
  22. .bootstrap-switch-handle-on {
  23. border-top-left-radius: 0 !important;
  24. border-bottom-left-radius: 0 !important;
  25. }
  26. </style>
  27. {% endblock head %}
  28. {% block content %}
  29. <script>
  30. $(document).ready(function() {
  31. $('body').addClass('add-transition');
  32. $('.add-page-transition').on('click', function(){
  33. var transAttr = $(this).attr('data-transition');
  34. $('.add-transition').attr('class', 'add-transition');
  35. $('.add-transition').addClass(transAttr);
  36. });
  37. $('#storage_mode').on('changed.bs.select', function (me) {
  38. if ($('#storage_mode').val() == '2' || $('#storage_mode').val() == '3') {
  39. $('#dfs_volume_label').css('display', 'unset');
  40. $('#dfs_volume').css('display', 'unset');
  41. } else {
  42. $('#dfs_volume_label').css('display', 'none');
  43. $('#dfs_volume').css('display', 'none');
  44. }
  45. });
  46. register_iops_bps_event();
  47. refresh_ip_pools();
  48. $('input.input-switch[name="activity"]').on('switchChange.bootstrapSwitch', function(event, state) {
  49. console.log(this); // DOM element
  50. console.log(event); // jQuery event
  51. console.log(state); // true | false
  52. if (state) {
  53. put_ip_pool_activity($(this).data('id'));
  54. }
  55. });
  56. $('#reserved_ip_modal').on('show.bs.modal', function (me) {
  57. reserved_ip_refresh();
  58. });
  59. $("#reserved_ip_input").keydown(function() {
  60. if (event.keyCode == "13") {//keyCode=13是回车键
  61. add_reserved_ip($('#reserved_ip_input').val())
  62. }
  63. });
  64. });
  65. function refresh() {
  66. window.location.reload();
  67. }
  68. function select_this(me) {
  69. $(me).parent().parent().children().removeClass('active');
  70. $(me).parent().addClass('active');
  71. $('#jimv_system_config, #quota, #ip_pool, #auxiliary').css('display', 'none');
  72. if (me.id === 'quota_label') {
  73. $('#quota').css('display', 'unset');
  74. } else if (me.id === 'ip_pool_label') {
  75. $('#ip_pool').css('display', 'unset');
  76. } else if (me.id === 'auxiliary_label') {
  77. $('#auxiliary').css('display', 'unset');
  78. } else {
  79. $('#jimv_system_config').css('display', 'unset');
  80. }
  81. }
  82. $(function() { "use strict";
  83. $("#iops_base").TouchSpin({
  84. max: 10000,
  85. min: 0,
  86. verticalbuttons: true,
  87. verticalupclass: 'glyph-icon icon-plus',
  88. verticaldownclass: 'glyph-icon icon-minus'
  89. });
  90. });
  91. $(function() { "use strict";
  92. $("#iops_pre_unit").TouchSpin({
  93. max: 100,
  94. min: 0,
  95. verticalbuttons: true,
  96. verticalupclass: 'glyph-icon icon-plus',
  97. verticaldownclass: 'glyph-icon icon-minus'
  98. });
  99. });
  100. $(function() { "use strict";
  101. $("#iops_cap").TouchSpin({
  102. max: 100000,
  103. min: 0,
  104. verticalbuttons: true,
  105. verticalupclass: 'glyph-icon icon-plus',
  106. verticaldownclass: 'glyph-icon icon-minus'
  107. });
  108. });
  109. $(function() { "use strict";
  110. $("#iops_max").TouchSpin({
  111. max: 200000,
  112. min: 0,
  113. verticalbuttons: true,
  114. verticalupclass: 'glyph-icon icon-plus',
  115. verticaldownclass: 'glyph-icon icon-minus'
  116. });
  117. });
  118. $(function() { "use strict";
  119. $("#iops_max_length").TouchSpin({
  120. max: 600,
  121. min: 0,
  122. postfix: '秒',
  123. verticalbuttons: true,
  124. verticalupclass: 'glyph-icon icon-plus',
  125. verticaldownclass: 'glyph-icon icon-minus'
  126. });
  127. });
  128. $(function() { "use strict";
  129. $("#bps_base").TouchSpin({
  130. max: 1024,
  131. min: 0,
  132. postfix: 'MiB',
  133. verticalbuttons: true,
  134. verticalupclass: 'glyph-icon icon-plus',
  135. verticaldownclass: 'glyph-icon icon-minus'
  136. });
  137. });
  138. $(function() { "use strict";
  139. $("#bps_pre_unit").TouchSpin({
  140. max: 10,
  141. min: 0,
  142. step: 0.01,
  143. decimals: 2,
  144. postfix: 'MiB',
  145. verticalbuttons: true,
  146. verticalupclass: 'glyph-icon icon-plus',
  147. verticaldownclass: 'glyph-icon icon-minus'
  148. });
  149. });
  150. $(function() { "use strict";
  151. $("#bps_cap").TouchSpin({
  152. max: 1024 * 2,
  153. min: 0,
  154. postfix: 'MiB',
  155. verticalbuttons: true,
  156. verticalupclass: 'glyph-icon icon-plus',
  157. verticaldownclass: 'glyph-icon icon-minus'
  158. });
  159. });
  160. $(function() { "use strict";
  161. $("#bps_max").TouchSpin({
  162. max: 1024 * 10,
  163. min: 0,
  164. postfix: 'MiB',
  165. verticalbuttons: true,
  166. verticalupclass: 'glyph-icon icon-plus',
  167. verticaldownclass: 'glyph-icon icon-minus'
  168. });
  169. });
  170. $(function() { "use strict";
  171. $("#bps_max_length").TouchSpin({
  172. max: 600,
  173. min: 0,
  174. postfix: '秒',
  175. verticalbuttons: true,
  176. verticalupclass: 'glyph-icon icon-plus',
  177. verticaldownclass: 'glyph-icon icon-minus'
  178. });
  179. });
  180. function register_iops_bps_event() {
  181. $('#iops').on('change', function () {
  182. $("#iops_rd").trigger("touchspin.updatesettings", {max: $('#iops').val() - $('#iops_wr').val()});
  183. $("#iops_wr").trigger("touchspin.updatesettings", {max: $('#iops').val() - $('#iops_rd').val()});
  184. });
  185. $('#iops_rd').on('change', function () {
  186. $("#iops_wr").trigger("touchspin.updatesettings", {max: $('#iops').val() - $('#iops_rd').val()});
  187. });
  188. $('#iops_wr').on('change', function () {
  189. $("#iops_rd").trigger("touchspin.updatesettings", {max: $('#iops').val() - $('#iops_wr').val()});
  190. });
  191. $('#bps').on('change', function () {
  192. $("#bps_rd").trigger("touchspin.updatesettings", {max: $('#bps').val() - $('#bps_wr').val()});
  193. $("#bps_wr").trigger("touchspin.updatesettings", {max: $('#bps').val() - $('#bps_rd').val()});
  194. });
  195. $('#bps_rd').on('change', function () {
  196. $("#bps_wr").trigger("touchspin.updatesettings", {max: $('#bps').val() - $('#bps_rd').val()});
  197. });
  198. $('#bps_wr').on('change', function () {
  199. $("#bps_rd").trigger("touchspin.updatesettings", {max: $('#bps').val() - $('#bps_wr').val()});
  200. });
  201. }
  202. function update_quota() {
  203. $.ajax({
  204. url : '/api/config/_quota',
  205. type : 'PATCH',
  206. contentType: "application/json; charset=utf-8",
  207. data : JSON.stringify({
  208. iops_base: parseInt($('#iops_base').val()),
  209. iops_pre_unit: parseInt($('#iops_pre_unit').val()),
  210. iops_cap: parseInt($('#iops_cap').val()),
  211. iops_max: parseInt($('#iops_max').val()),
  212. iops_max_length: parseInt($('#iops_max_length').val()),
  213. bps_base: parseInt($('#bps_base').val()) * 1024 * 1024,
  214. bps_pre_unit: parseFloat($('#bps_pre_unit').val()) * 1024 * 1024,
  215. bps_cap: parseInt($('#bps_cap').val()) * 1024 * 1024,
  216. bps_max: parseInt($('#bps_max').val()) * 1024 * 1024,
  217. bps_max_length: parseInt($('#bps_max_length').val()),
  218. influence_current_guest: $('#influence_current_guest').prop('checked')
  219. }),
  220. error : function() {
  221. alter_danger('性能配额更新失败!');
  222. },
  223. success : function() {
  224. alter_success('性能配额更新成功!');
  225. setTimeout(function() {
  226. refresh();
  227. }, 1000);
  228. }
  229. });
  230. }
  231. function refresh_guest_state() {
  232. $.ajax({
  233. url : '/api/guests/_refresh_guest_state',
  234. type : 'PATCH',
  235. error : function() {
  236. alter_danger('刷新虚拟机状态失败!');
  237. },
  238. success : function() {
  239. alter_success('刷新虚拟机状态成功!');
  240. setTimeout(function() {
  241. refresh();
  242. }, 1000);
  243. }
  244. });
  245. }
  246. function exchange_ip_pool_for_panel(ip_pool) {
  247. var activity_checked = '';
  248. if (ip_pool.activity > 0) {
  249. activity_checked = 'checked';
  250. }
  251. return '<div class="panel">\n' +
  252. ' <div class="panel-body">\n' +
  253. ' <form class="form-horizontal bordered-row" style="padding-left: 8%;">\n' +
  254. ' <input title="IP Pool ID" class="form-control" name="id" type="text" value="' + ip_pool.id + '" hidden>\n' +
  255. ' <div class="form-group">\n' +
  256. ' <label class="col-sm-2 control-label">起始 IP</label>\n' +
  257. ' <div class="col-sm-3">\n' +
  258. ' <input title="起始 IP" class="form-control" name="start_ip" type="text" value="' + ip_pool.start_ip + '">\n' +
  259. ' </div>\n' +
  260. ' <label class="col-sm-2 control-label">截止 IP</label>\n' +
  261. ' <div class="col-sm-3">\n' +
  262. ' <input title="截止 IP" class="form-control" name="end_ip" type="text" value="' + ip_pool.end_ip + '">\n' +
  263. ' </div>\n' +
  264. ' </div>\n' +
  265. ' <div class="form-group">\n' +
  266. ' <label class="col-sm-2 control-label">子网掩码</label>\n' +
  267. ' <div class="col-sm-3">\n' +
  268. ' <input title="子网掩码" class="form-control" name="netmask" type="text" value="' + ip_pool.netmask + '">\n' +
  269. ' </div>\n' +
  270. ' <label class="col-sm-2 control-label">网关</label>\n' +
  271. ' <div class="col-sm-3">\n' +
  272. ' <input title="网关" class="form-control" name="gateway" type="text" value="' + ip_pool.gateway + '">\n' +
  273. ' </div>\n' +
  274. ' </div>\n' +
  275. ' <div class="form-group">\n' +
  276. ' <label class="col-sm-2 control-label">DNS1</label>\n' +
  277. ' <div class="col-sm-3">\n' +
  278. ' <input title="DNS1" class="form-control" name="dns1" type="text" value="' + ip_pool.dns1 + '">\n' +
  279. ' </div>\n' +
  280. ' <label class="col-sm-2 control-label">DNS2</label>\n' +
  281. ' <div class="col-sm-3">\n' +
  282. ' <input title="DNS2" class="form-control" name="dns2" type="text" value="' + ip_pool.dns2 + '">\n' +
  283. ' </div>\n' +
  284. ' </div>\n' +
  285. ' <div class="form-group">\n' +
  286. ' <label class="col-sm-2 control-label">名称</label>\n' +
  287. ' <div class="col-sm-3">\n' +
  288. ' <input title="名称" class="form-control" name="name" type="text" value="' + ip_pool.name + '">\n' +
  289. ' </div>\n' +
  290. ' <label class="col-sm-2 control-label">备注</label>\n' +
  291. ' <div class="col-sm-3">\n' +
  292. ' <textarea title="备注" class="form-control" name="description">'+ip_pool.description+'</textarea>\n' +
  293. ' </div>\n' +
  294. ' </div>\n' +
  295. ' <div class="form-group" style="margin-bottom: 0;">\n' +
  296. ' <div class="col-sm-6">\n' +
  297. ' <input type="checkbox" name="activity" data-on-color="info" class="input-switch" data-id="' + ip_pool.id + '" ' + activity_checked + ' data-size="medium" data-on-text="活跃" data-off-text="非活跃">\n' +
  298. ' </div>\n' +
  299. ' <div class="col-sm-6">\n' +
  300. ' <div style="padding: 0; text-align: right;">\n' +
  301. ' <button type="button" class="btn btn-sm btn-primary" style="right: 10%;" data-id="' + ip_pool.id + '" onclick="update_ip_pool(this);">更新</button>\n' +
  302. ' <button type="button" class="btn btn-sm btn-danger" style="right: 4%;" data-toggle="modal" data-target="#ip_pool_delete_modal" onclick="$(\'#ip_pool_id\').val(get_ip_pool_field_value(this, \'id\'));\n' +
  303. ' $(\'#delete_instance_desc\').text(get_ip_pool_field_value(this, \'name\'))">删除</button>\n' +
  304. ' </div>\n' +
  305. ' </div>\n' +
  306. ' </div>\n' +
  307. ' </form>\n' +
  308. ' </div>\n' +
  309. '</div>';
  310. }
  311. function get_ip_pools_html() {
  312. var html = '<div class="row" style="padding: 10px 10px 10px 0; width: 100%;">\n' +
  313. ' <div class="col-sm-12" style="padding-right: 0;">\n' +
  314. ' <div class="pull-right">\n' +
  315. ' <button class="btn btn-default" onclick="window.location.reload();" style="border-radius: 0;"><span class="glyph-icon icon-elusive-arrows-cw"></span></button>\n' +
  316. ' <a class="btn btn-info" href="javascript:;" data-toggle="modal" data-target="#add_ip_pool_modal" style="border-radius: 0; padding-left: 40px; padding-right: 40px;">添加 IP 池</a>\n' +
  317. ' <a class="btn btn-black" href="javascript:;" data-toggle="modal" data-target="#reserved_ip_modal" style="border-radius: 0; padding-left: 40px; padding-right: 40px; color: white;">保留 IP</a>\n' +
  318. ' </div>\n' +
  319. ' </div>\n' +
  320. '</div>';
  321. $.ajax({
  322. url : '/api/ip_pools',
  323. type : 'GET',
  324. contentType: "application/json; charset=utf-8",
  325. dataType: 'json',
  326. async: false,
  327. error : function() {
  328. },
  329. success : function(data, textStatus, xhr) {
  330. $.each(data.data, function(k, v) {
  331. html += exchange_ip_pool_for_panel(v);
  332. });
  333. }
  334. });
  335. return html
  336. }
  337. function refresh_ip_pools() {
  338. var html = get_ip_pools_html();
  339. $('#ip_pool').append(html);
  340. }
  341. function get_ip_pool_field_value(me, name) {
  342. return $(me).parent().parent().parent().parent().serializeArray().filter(
  343. function(field) {return field.name == name})[0].value;
  344. }
  345. function update_ip_pool(me) {
  346. var id = get_ip_pool_field_value(me, 'id');
  347. var start_ip = get_ip_pool_field_value(me, 'start_ip');
  348. var end_ip = get_ip_pool_field_value(me, 'end_ip');
  349. var netmask = get_ip_pool_field_value(me, 'netmask');
  350. var gateway = get_ip_pool_field_value(me, 'gateway');
  351. var dns1 = get_ip_pool_field_value(me, 'dns1');
  352. var dns2 = get_ip_pool_field_value(me, 'dns2');
  353. var name = get_ip_pool_field_value(me, 'name');
  354. var description = get_ip_pool_field_value(me, 'description');
  355. var data = {
  356. start_ip: start_ip,
  357. end_ip: end_ip,
  358. netmask: netmask,
  359. gateway: gateway,
  360. dns1: dns1,
  361. dns2: dns2,
  362. name: name,
  363. description: description
  364. };
  365. $.ajax({
  366. url : '/api/ip_pools/' + String(id),
  367. type : 'PATCH',
  368. contentType: "application/json; charset=utf-8",
  369. async: false,
  370. dataType: "json",
  371. data : JSON.stringify(data),
  372. error : function(data, textStatus, xhr) {
  373. alter_danger(data.responseText);
  374. alter_warning('更新 IP 池失败!');
  375. },
  376. success : function(data, textStatus, xhr) {
  377. alter_success('更新 IP 池成功!');
  378. }
  379. });
  380. setTimeout(function() {
  381. window.location.reload();
  382. }, 3000);
  383. }
  384. function create_ip_pool(me) {
  385. $('#add_ip_pool_modal').modal('hide');
  386. var start_ip = get_ip_pool_field_value(me, 'start_ip');
  387. var end_ip = get_ip_pool_field_value(me, 'end_ip');
  388. var netmask = get_ip_pool_field_value(me, 'netmask');
  389. var gateway = get_ip_pool_field_value(me, 'gateway');
  390. var dns1 = get_ip_pool_field_value(me, 'dns1');
  391. var dns2 = get_ip_pool_field_value(me, 'dns2');
  392. var name = get_ip_pool_field_value(me, 'name');
  393. var description = get_ip_pool_field_value(me, 'description');
  394. var activity = $('#activity').prop('checked');
  395. var data = {
  396. start_ip: start_ip,
  397. end_ip: end_ip,
  398. netmask: netmask,
  399. gateway: gateway,
  400. dns1: dns1,
  401. dns2: dns2,
  402. name: name,
  403. description: description,
  404. activity: activity
  405. };
  406. $.ajax({
  407. url : '/api/ip_pool',
  408. type : 'POST',
  409. contentType: "application/json; charset=utf-8",
  410. async: false,
  411. dataType: "json",
  412. data : JSON.stringify(data),
  413. error : function(data, textStatus, xhr) {
  414. alter_danger(data.responseText);
  415. alter_warning('添加 IP 池失败!');
  416. },
  417. success : function(data, textStatus, xhr) {
  418. alter_success('您所提交的 IP 池已创建。页面将在3秒钟后自动跳转到 IP 池列表页面!');
  419. }
  420. });
  421. setTimeout(function() {
  422. window.location.reload();
  423. }, 3000);
  424. }
  425. function put_ip_pool_activity(id) {
  426. $.ajax({
  427. url : '/api/ip_pool/' + String(id),
  428. type : 'PUT',
  429. async: false,
  430. dataType: "json",
  431. error : function(data, textStatus, xhr) {
  432. alter_danger(data.responseText);
  433. alter_warning('IP 池激活失败!');
  434. },
  435. success : function(data, textStatus, xhr) {
  436. alter_success('IP 池激活成功!');
  437. }
  438. });
  439. setTimeout(function() {
  440. window.location.reload();
  441. }, 3000);
  442. }
  443. function ip_pool_delete_at(me) {
  444. var ip_pool_id = $('#ip_pool_id').val();
  445. ip_pool_remove(ip_pool_id);
  446. $('#ip_pool_delete_modal').modal('hide');
  447. }
  448. function ip_pool_remove(id) {
  449. $.ajax({
  450. url : '/api/ip_pools/' + id,
  451. type : 'DELETE',
  452. contentType: "application/json; charset=utf-8",
  453. error : function() {
  454. alter_danger('IP 池删除指令发送失败!');
  455. },
  456. success : function() {
  457. alter_success('IP 池删除指令发送成功!');
  458. setTimeout(function() {
  459. refresh();
  460. }, 1000);
  461. }
  462. });
  463. }
  464. function row_onmouseover(me) {
  465. $(me).find(".delete_reserved_ip_trigger").css('display','inline-flex');
  466. }
  467. function row_onmouseout(me) {
  468. $(me).find(".delete_reserved_ip_trigger").css('display','none');
  469. }
  470. function add_reserved_ip(ip) {
  471. $.ajax({
  472. url : '/api/reserved_ip',
  473. type : 'POST',
  474. contentType: "application/json; charset=utf-8",
  475. async: false,
  476. dataType: "json",
  477. data : JSON.stringify({ip: ip}),
  478. error : function(data, textStatus, xhr) {
  479. alter_danger(data.responseText);
  480. alter_warning('添加保留 IP 失败!');
  481. },
  482. success : function(data, textStatus, xhr) {
  483. var html = '<tr role="row" data-id="' + data['data']['id'] + '" class="odd" onmouseover="row_onmouseover(this);" onmouseout="row_onmouseout(this);">\n' +
  484. ' <td class="text-center">\n' +
  485. data['data']['ip'] +
  486. ' <div style="display: inline;">\n' +
  487. ' <a href="javascript:;" class="delete_reserved_ip_trigger" style="display: none; float: right;">\n' +
  488. ' <span onclick="reserved_ip_delete(this);" class="glyph-icon icon-iconic-cancel" style="width: 20px; height: 20px; margin-left: 10px; border-radius: 0; color: indianred;"></span>\n' +
  489. ' </a>\n' +
  490. ' </div>\n' +
  491. ' </td>\n' +
  492. '</tr>';
  493. $('#reserved_ip_table tbody').append(html);
  494. alter_success('添加保留 IP 成功!');
  495. }
  496. });
  497. }
  498. function reserved_ip_refresh() {
  499. $.ajax({
  500. url : '/api/reserved_ips',
  501. type : 'GET',
  502. contentType: "application/json; charset=utf-8",
  503. dataType: 'json',
  504. async: false,
  505. error : function() {
  506. },
  507. success : function(data, textStatus, xhr) {
  508. var html = NaN;
  509. $('#reserved_ip_table tbody').empty();
  510. $.each(data.data, function(k, v) {
  511. html = '<tr role="row" data-id="' + v['id'] + '" class="odd" onmouseover="row_onmouseover(this);" onmouseout="row_onmouseout(this);">\n' +
  512. ' <td class="text-center">\n' +
  513. v['ip'] +
  514. ' <div style="display: inline;">\n' +
  515. ' <a href="javascript:;" class="delete_reserved_ip_trigger" style="display: none; float: right;">\n' +
  516. ' <span onclick="reserved_ip_delete(this);" class="glyph-icon icon-iconic-cancel" style="width: 20px; height: 20px; margin-left: 10px; border-radius: 0; color: indianred;"></span>\n' +
  517. ' </a>\n' +
  518. ' </div>\n' +
  519. ' </td>\n' +
  520. '</tr>';
  521. $('#reserved_ip_table tbody').append(html);
  522. });
  523. }
  524. });
  525. }
  526. function reserved_ip_delete(me) {
  527. var id = $(me).parent().parent().parent().parent().data('id');
  528. $.ajax({
  529. url : '/api/reserved_ips/' + id,
  530. type : 'DELETE',
  531. contentType: "application/json; charset=utf-8",
  532. async: false,
  533. error : function(data, textStatus, xhr) {
  534. alter_danger(data.responseText);
  535. alter_warning('添加保留 IP 失败!');
  536. },
  537. success : function(data, textStatus, xhr) {
  538. $('#reserved_ip_table tbody tr[data-id="' +id + '"]').remove()
  539. alter_success('删除保留 IP 成功!');
  540. }
  541. });
  542. }
  543. </script>
  544. <div class="panel">
  545. <div class="panel-body">
  546. <ul class="nav nav-tabs mrg25B">
  547. <li class="active"><a href="javascript:;" onclick="select_this(this);" id="jimv_system_config_label">JimV 系统配置</a></li>
  548. <li><a href="javascript:;" onclick="select_this(this);" id="ip_pool_label">IP 池</a></li>
  549. <li><a href="javascript:;" onclick="select_this(this);" id="quota_label">性能配额</a></li>
  550. <li><a href="javascript:;" onclick="select_this(this);" id="auxiliary_label">辅助</a></li>
  551. </ul>
  552. <div id="jimv_system_config" class="example-box-wrapper">
  553. <form class="form-horizontal bordered-row" style="padding-left: 8%;">
  554. <div class="form-group">
  555. <label class="col-sm-2 control-label">网桥(业务网络)</label>
  556. <div class="col-sm-3">
  557. <input title="Guest 业务网络" class="form-control" name="vm_network" type="text" disabled value="{{ config.vm_network }}">
  558. </div>
  559. <label class="col-sm-2 control-label">网桥(管理网络)</label>
  560. <div class="col-sm-3">
  561. <input title="Guest 管理网络" class="form-control" name="vm_manage_network" type="text" disabled value="{{ config.vm_manage_network }}">
  562. </div>
  563. </div>
  564. <div class="form-group">
  565. <label class="col-sm-2 control-label">虚拟机磁盘存储模式</label>
  566. <div class="col-sm-3">
  567. <select id="storage_mode" title="虚拟机磁盘存储模式" class="selectpicker" name="storage_mode" data-width="100%" disabled>
  568. <option {% if config.storage_mode == 0 %}selected{% endif %} value="0">本地存储</option>
  569. <option {% if config.storage_mode == 1 %}selected{% endif %} value="1" data-subtext="NFS">挂载共享</option>
  570. <option {% if config.storage_mode == 2 %}selected{% endif %} value="2">Ceph</option>
  571. <option {% if config.storage_mode == 3 %}selected{% endif %} value="3">GlusterFS</option>
  572. </select>
  573. </div>
  574. <label id="dfs_volume_label" class="col-sm-2 control-label" style="display: {% if config.storage_mode in [3] %}unset{% else %}none{% endif %};">分布式文件系统存储卷</label>
  575. <div class="col-sm-3">
  576. <input id="dfs_volume" title="分布式文件系统存储卷" class="form-control" name="dfs_volume" type="text" style="display: {% if config.storage_mode in [3] %}unset{% else %}none{% endif %};" disabled value="{{ config.dfs_volume }}">
  577. </div>
  578. </div>
  579. <div class="form-group">
  580. <label class="col-sm-2 control-label">虚拟机磁盘存放路径</label>
  581. <div class="col-sm-3">
  582. <input title="虚拟机磁盘存放路径" class="form-control" name="storage_path" type="text" disabled value="{{ config.storage_path }}">
  583. </div>
  584. </div>
  585. </form>
  586. </div>
  587. <div id="quota" class="example-box-wrapper" style="display: none;">
  588. <form class="form-horizontal bordered-row" style="padding-left: 8%;">
  589. <div class="form-group" style="margin-bottom: 0;">
  590. <label class="col-sm-2 control-label">
  591. <span class="glyph-icon icon-exchange" style="transform: rotate(90deg); display: inline-flex;"></span>
  592. &nbsp;&nbsp;IOPS 基准值
  593. </label>
  594. <div class="col-sm-3">
  595. <input id="iops_base" title="IOPS 基准值" class="form-control" type="text" value="{{ config.iops_base }}" name="iops_base">
  596. </div>
  597. <span class="col-sm-1"></span>
  598. <label class="col-sm-2 control-label"><span class="glyph-icon icon-openid"></span>&nbsp;&nbsp;BPS 基准值</label>
  599. <div class="col-sm-3">
  600. <input id="bps_base" title="BPS 基准值" class="form-control" type="text" value="{{ (config.bps_base / 1024 / 1024) | int }}" name="bps_base">
  601. </div>
  602. <span class="col-sm-1"></span>
  603. </div>
  604. <div class="form-group" style="margin-bottom: 0;">
  605. <label class="col-sm-2 control-label">
  606. <span class="glyph-icon icon-exchange" style="transform: rotate(90deg); display: inline-flex;"></span>
  607. &nbsp;&nbsp;IOPS/GiB 增益
  608. </label>
  609. <div class="col-sm-3">
  610. <input id="iops_pre_unit" title="IOPS/GiB 增益" class="form-control" type="text" value="{{ config.iops_pre_unit }}" name="iops_pre_unit">
  611. </div>
  612. <span class="col-sm-1"></span>
  613. <label class="col-sm-2 control-label"><span class="glyph-icon icon-openid"></span>&nbsp;&nbsp;BPS/GiB 增益</label>
  614. <div class="col-sm-3">
  615. <input id="bps_pre_unit" title="BPS/GiB 增益 (MiB)" class="form-control" type="text" value="{{ '%0.2f'|format(config.bps_pre_unit / 1024 / 1024) }}" name="bps_pre_unit">
  616. </div>
  617. <span class="col-sm-1"></span>
  618. </div>
  619. <div class="form-group" style="margin-bottom: 0;">
  620. <label class="col-sm-2 control-label">
  621. <span class="glyph-icon icon-exchange" style="transform: rotate(90deg); display: inline-flex;"></span>
  622. &nbsp;&nbsp;IOPS 增益上限
  623. </label>
  624. <div class="col-sm-3">
  625. <input id="iops_cap" title="IOPS 增益上限" class="form-control" type="text" value="{{ config.iops_cap }}" name="iops_cap">
  626. </div>
  627. <span class="col-sm-1"></span>
  628. <label class="col-sm-2 control-label"><span class="glyph-icon icon-openid"></span>&nbsp;&nbsp;BPS 增益上限</label>
  629. <div class="col-sm-3">
  630. <input id="bps_cap" title="BPS 增益上限 (MiB)" class="form-control" type="text" value="{{ (config.bps_cap / 1024 / 1024) | int }}" name="bps_cap">
  631. </div>
  632. <span class="col-sm-1"></span>
  633. </div>
  634. <div class="form-group" style="margin-bottom: 0;">
  635. <label class="col-sm-2 control-label">
  636. <span class="glyph-icon icon-exchange" style="transform: rotate(90deg); display: inline-flex;"></span>
  637. <span class="glyph-icon icon-bitbucket" style="margin-left: -4px;"></span>
  638. &nbsp;&nbsp;IOPS 桶宽
  639. </label>
  640. <div class="col-sm-3">
  641. <input id="iops_max" title="IOPS 桶宽" class="form-control" type="text" value="{{ config.iops_max }}" name="iops_max">
  642. </div>
  643. <span class="col-sm-1"></span>
  644. <label class="col-sm-2 control-label"><span class="glyph-icon icon-openid"></span><span class="glyph-icon icon-bitbucket"></span>&nbsp;&nbsp;BPS 桶宽</label>
  645. <div class="col-sm-3">
  646. <input id="bps_max" title="BPS 桶宽 (MiB)" class="form-control" type="text" value="{{ (config.bps_max / 1024 / 1024) | int }}" name="bps_max">
  647. </div>
  648. <span class="col-sm-1"></span>
  649. </div>
  650. <div class="form-group" style="margin-bottom: 0;">
  651. <label class="col-sm-2 control-label">
  652. <span class="glyph-icon icon-exchange" style="transform: rotate(90deg); display: inline-flex;"></span>
  653. <span class="glyph-icon icon-bitbucket" style="margin-left: -4px;"></span>
  654. &nbsp;&nbsp;IOPS 桶高
  655. </label>
  656. <div class="col-sm-3">
  657. <input id="iops_max_length" title="IOPS 桶高 (秒)" class="form-control" type="text" value="{{ config.iops_max_length }}" name="iops_max_length">
  658. </div>
  659. <span class="col-sm-1"></span>
  660. <label class="col-sm-2 control-label"><span class="glyph-icon icon-openid"></span><span class="glyph-icon icon-bitbucket"></span>&nbsp;&nbsp;BPS 桶高</label>
  661. <div class="col-sm-3">
  662. <input id="bps_max_length" title="BPS 桶高 (秒)" class="form-control" type="text" value="{{ config.bps_max_length }}" name="bps_max_length">
  663. </div>
  664. <span class="col-sm-1"></span>
  665. </div>
  666. <div class="form-group" style="margin-bottom: 0;">
  667. <div class="col-sm-6">
  668. <label>
  669. <input id="influence_current_guest" type="checkbox" name="influence_current_guest">
  670. 同时更新已存在的实例
  671. </label>
  672. </div>
  673. <div class="col-sm-6">
  674. <div style="padding: 0; text-align: right;">
  675. <button type="button" class="btn btn-sm btn-primary" style="right: 10%;" onclick="update_quota();">更新</button>
  676. </div>
  677. </div>
  678. </div>
  679. </form>
  680. </div>
  681. <div id="ip_pool" class="example-box-wrapper" style="display: none;">
  682. </div>
  683. <div id="auxiliary" class="example-box-wrapper" style="display: none;">
  684. <form class="form-horizontal bordered-row" style="padding-left: 8%;">
  685. <div class="form-group" style="margin-bottom: 0;">
  686. <div class="col-sm-3">
  687. <button type="button" class="btn btn-primary" onclick="refresh_guest_state();">刷新虚拟机状态</button>
  688. </div>
  689. </div>
  690. </form>
  691. </div>
  692. </div>
  693. </div>
  694. <input id="ip_pool_id" title="IP Pool ID" class="form-control" name="ip_pool_id" hidden>
  695. <div class="modal" id="add_ip_pool_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  696. <div class="modal-dialog modal-lg">
  697. <div class="modal-content">
  698. <div class="modal-header">
  699. <h4 class="modal-title">添加 IP 池:</h4>
  700. </div>
  701. <div class="panel">
  702. <div class="panel-body">
  703. <form class="form-horizontal bordered-row" style="padding-left: 16%;">
  704. <div class="form-group">
  705. <label class="col-sm-2 control-label">起始 IP</label>
  706. <div class="col-sm-3">
  707. <input title="起始 IP" class="form-control" name="start_ip" type="text">
  708. </div>
  709. <label class="col-sm-2 control-label">截止 IP</label>
  710. <div class="col-sm-3">
  711. <input title="截止 IP" class="form-control" name="end_ip" type="text">
  712. </div>
  713. </div>
  714. <div class="form-group">
  715. <label class="col-sm-2 control-label">子网掩码</label>
  716. <div class="col-sm-3">
  717. <input title="子网掩码" class="form-control" name="netmask" type="text">
  718. </div>
  719. <label class="col-sm-2 control-label">网关</label>
  720. <div class="col-sm-3">
  721. <input title="网关" class="form-control" name="gateway" type="text">
  722. </div>
  723. </div>
  724. <div class="form-group">
  725. <label class="col-sm-2 control-label">DNS1</label>
  726. <div class="col-sm-3">
  727. <input title="DNS1" class="form-control" name="dns1" type="text">
  728. </div>
  729. <label class="col-sm-2 control-label">DNS2</label>
  730. <div class="col-sm-3">
  731. <input title="DNS2" class="form-control" name="dns2" type="text">
  732. </div>
  733. </div>
  734. <div class="form-group">
  735. <label class="col-sm-2 control-label">名称</label>
  736. <div class="col-sm-3">
  737. <input title="名称" class="form-control" name="name" type="text">
  738. </div>
  739. <label class="col-sm-2 control-label">备注</label>
  740. <div class="col-sm-3">
  741. <textarea title="备注" class="form-control" name="description"></textarea>
  742. </div>
  743. </div>
  744. <div class="form-group" style="margin-bottom: 0;">
  745. <div class="col-sm-6">
  746. <div class="checkbox checkbox-info">
  747. <label>
  748. <input id="activity" name="activity" type="checkbox" checked class="custom-checkbox">
  749. 设为默认
  750. </label>
  751. </div>
  752. </div>
  753. <div class="col-sm-6">
  754. <div style="padding: 0; text-align: right;">
  755. <button type="button" class="btn btn-sm btn-primary" style="right: 20%;" onclick="create_ip_pool(this);">创建</button>
  756. <button type="button" class="btn btn-sm btn-default" style="right: 10%;" data-dismiss="modal">取消</button>
  757. </div>
  758. </div>
  759. </div>
  760. </form>
  761. </div>
  762. </div>
  763. </div>
  764. </div>
  765. </div>
  766. <div class="modal" id="ip_pool_delete_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  767. <div class="modal-dialog">
  768. <div class="modal-content">
  769. <div class="modal-header">
  770. <h4 class="modal-title">删除 IP 池:</h4>
  771. </div>
  772. <div class="modal-body">
  773. <p>您确定要删除该 IP 池吗?</p>
  774. <h3 style="color: orangered;" id="delete_instance_desc"></h3>
  775. </div>
  776. <div class="modal-footer">
  777. <button type="button" class="btn btn-sm btn-primary" onclick="ip_pool_delete_at();">确定</button>
  778. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  779. </div>
  780. </div>
  781. </div>
  782. </div>
  783. <div class="modal" id="reserved_ip_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  784. <div class="modal-dialog modal-sm">
  785. <div class="modal-content">
  786. <div class="modal-header">
  787. <h4 class="modal-title">保留 IP:</h4>
  788. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  789. <span aria-hidden="true">&times;</span>
  790. </button>
  791. </div>
  792. <div class="modal-body" style="padding-top: 0; padding-bottom: 0;">
  793. <div class="example-box-wrapper">
  794. <form id="reserved_ip_form" class="form-horizontal bordered-row" action="javascript:;">
  795. <div class="form-group">
  796. <div class="col-sm-1"></div>
  797. <div class="col-sm-10" style="height: 300px; overflow: auto;">
  798. <table id="reserved_ip_table" class="table table-bordered table-hover" cellspacing="0" width="100%" role="grid"
  799. style="width: 100%; margin-bottom: 0;">
  800. <tbody></tbody>
  801. </table>
  802. </div>
  803. <div class="col-sm-1"></div>
  804. </div>
  805. <div class="form-group">
  806. <div class="col-sm-1"></div>
  807. <div class="col-sm-10">
  808. <input id="reserved_ip_input" class="form-control" style="text-align: center;" type="text" placeholder="将要保留的 IP">
  809. </div>
  810. <div class="col-sm-1"></div>
  811. </div>
  812. </form>
  813. </div>
  814. </div>
  815. </div>
  816. </div>
  817. </div>
  818. {% endblock content %}