config_show.html 71 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440
  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. .table {
  14. font-size: 12px;
  15. border-width: 1px;
  16. line-height: 20px;
  17. }
  18. .table > thead > tr > th,
  19. .table > tfoot > tr > th {
  20. color: #999999;
  21. font-weight: normal;
  22. border-bottom: 0 solid #e1e6eb;
  23. background-color: #F5F6FA;
  24. }
  25. .table > tbody > tr > td {
  26. color: #424547;
  27. }
  28. .table-bordered > tbody > tr {
  29. padding-top: 10px;
  30. padding-bottom: 10px;
  31. }
  32. .table-bordered > thead > tr > th,
  33. .table-bordered > tbody > tr > th,
  34. .table-bordered > tfoot > tr > th,
  35. .table-bordered > thead > tr > td,
  36. .table-bordered > tbody > tr > td,
  37. .table-bordered > tfoot > tr > td {
  38. border-style: solid;
  39. border-width: 1px 0 0 0;
  40. }
  41. #batch_change_disk_quota_form label {
  42. padding-left: 0;
  43. padding-right: 0;
  44. }
  45. .btn,
  46. .form-group>div>div,
  47. .form-control {
  48. border-radius: 0;
  49. }
  50. .bootstrap-switch-handle-on {
  51. border-top-left-radius: 0 !important;
  52. border-bottom-left-radius: 0 !important;
  53. }
  54. </style>
  55. {% endblock head %}
  56. {% block content %}
  57. <script>
  58. var sheet_tag = window.location.hash;
  59. $(document).ready(function() {
  60. $('body').addClass('add-transition');
  61. $('.add-page-transition').on('click', function(){
  62. var transAttr = $(this).attr('data-transition');
  63. $('.add-transition').attr('class', 'add-transition');
  64. $('.add-transition').addClass(transAttr);
  65. });
  66. $('#storage_mode').on('changed.bs.select', function (me) {
  67. if ($('#storage_mode').val() == '2' || $('#storage_mode').val() == '3') {
  68. $('#dfs_volume_label').css('display', 'unset');
  69. $('#dfs_volume').css('display', 'unset');
  70. } else {
  71. $('#dfs_volume_label').css('display', 'none');
  72. $('#dfs_volume').css('display', 'none');
  73. }
  74. });
  75. register_iops_bps_event();
  76. refresh_ip_pools();
  77. tokens_list_refresh();
  78. vlans_list_refresh();
  79. $('input.input-switch[name="activity"]').on('switchChange.bootstrapSwitch', function(event, state) {
  80. console.log(this); // DOM element
  81. console.log(event); // jQuery event
  82. console.log(state); // true | false
  83. if (state) {
  84. put_ip_pool_activity($(this).data('id'));
  85. }
  86. });
  87. $('#reserved_ip_modal').on('show.bs.modal', function (me) {
  88. reserved_ip_refresh();
  89. });
  90. $("#reserved_ip_input").keydown(function() {
  91. if (event.keyCode == "13") {//keyCode=13是回车键
  92. add_reserved_ip($('#reserved_ip_input').val())
  93. }
  94. });
  95. nav_to_sheet_tag();
  96. });
  97. function refresh() {
  98. window.location.reload();
  99. }
  100. function select_this(me) {
  101. $(me).parent().parent().children().removeClass('active');
  102. $(me).parent().addClass('active');
  103. $('#view_by_jimv_system_config, #view_by_quota, #view_by_ip_pool, #view_by_vlan, #view_by_auxiliary, #view_by_token').css('display', 'none');
  104. if (me.id === 'view_by_quota_label') {
  105. $('#view_by_quota').css('display', 'unset');
  106. history.replaceState(null, null, window.location.pathname);
  107. window.location.hash = "quota";
  108. } else if (me.id === 'view_by_ip_pool_label') {
  109. $('#view_by_ip_pool').css('display', 'unset');
  110. history.replaceState(null, null, window.location.pathname);
  111. window.location.hash = "ip_pool";
  112. } else if (me.id === 'view_by_vlan_label') {
  113. $('#view_by_vlan').css('display', 'unset');
  114. history.replaceState(null, null, window.location.pathname);
  115. window.location.hash = "vlan";
  116. } else if (me.id === 'view_by_token_label') {
  117. $('#view_by_token').css('display', 'unset');
  118. history.replaceState(null, null, window.location.pathname);
  119. window.location.hash = "token";
  120. } else if (me.id === 'view_by_auxiliary_label') {
  121. $('#view_by_auxiliary').css('display', 'unset');
  122. history.replaceState(null, null, window.location.pathname);
  123. window.location.hash = "auxiliary";
  124. } else {
  125. $('#view_by_jimv_system_config').css('display', 'unset');
  126. history.replaceState(null, null, ' ');
  127. }
  128. }
  129. function nav_to_sheet_tag() {
  130. var view_by_jimv_system_config_label = $('#view_by_jimv_system_config_label');
  131. var view_by_quota_label = $('#view_by_quota_label');
  132. var view_by_ip_pool_label = $('#view_by_ip_pool_label');
  133. var view_by_vlan_label = $('#view_by_vlan_label');
  134. var view_by_token_label = $('#view_by_token_label');
  135. var view_by_auxiliary_label = $('#view_by_auxiliary_label');
  136. view_by_jimv_system_config_label.parent().parent().children().removeClass('active');
  137. $('#view_by_jimv_system_config, #view_by_quota, #view_by_ip_pool, #view_by_vlan, #view_by_auxiliary, #view_by_token').css('display', 'none');
  138. if (sheet_tag.indexOf('#quota') != -1) {
  139. view_by_quota_label.parent().addClass('active');
  140. $('#view_by_quota').css('display', 'unset');
  141. } else if (sheet_tag.indexOf('#ip_pool') != -1) {
  142. view_by_ip_pool_label.parent().addClass('active');
  143. $('#view_by_ip_pool').css('display', 'unset');
  144. } else if (sheet_tag.indexOf('#vlan') != -1) {
  145. view_by_vlan_label.parent().addClass('active');
  146. $('#view_by_vlan').css('display', 'unset');
  147. } else if (sheet_tag.indexOf('#token') != -1) {
  148. view_by_token_label.parent().addClass('active');
  149. $('#view_by_token').css('display', 'unset');
  150. } else if (sheet_tag.indexOf('#auxiliary') != -1) {
  151. view_by_auxiliary_label.parent().addClass('active');
  152. $('#view_by_auxiliary').css('display', 'unset');
  153. } else {
  154. view_by_jimv_system_config_label.parent().addClass('active');
  155. $('#view_by_jimv_system_config').css('display', 'unset');
  156. }
  157. }
  158. $(function() { "use strict";
  159. $("#iops_base").TouchSpin({
  160. max: 10000,
  161. min: 0,
  162. verticalbuttons: true,
  163. verticalupclass: 'glyph-icon icon-plus',
  164. verticaldownclass: 'glyph-icon icon-minus'
  165. });
  166. });
  167. $(function() { "use strict";
  168. $("#iops_pre_unit").TouchSpin({
  169. max: 100,
  170. min: 0,
  171. verticalbuttons: true,
  172. verticalupclass: 'glyph-icon icon-plus',
  173. verticaldownclass: 'glyph-icon icon-minus'
  174. });
  175. });
  176. $(function() { "use strict";
  177. $("#iops_cap").TouchSpin({
  178. max: 100000,
  179. min: 0,
  180. verticalbuttons: true,
  181. verticalupclass: 'glyph-icon icon-plus',
  182. verticaldownclass: 'glyph-icon icon-minus'
  183. });
  184. });
  185. $(function() { "use strict";
  186. $("#iops_max").TouchSpin({
  187. max: 200000,
  188. min: 0,
  189. verticalbuttons: true,
  190. verticalupclass: 'glyph-icon icon-plus',
  191. verticaldownclass: 'glyph-icon icon-minus'
  192. });
  193. });
  194. $(function() { "use strict";
  195. $("#iops_max_length").TouchSpin({
  196. max: 600,
  197. min: 0,
  198. postfix: '秒',
  199. verticalbuttons: true,
  200. verticalupclass: 'glyph-icon icon-plus',
  201. verticaldownclass: 'glyph-icon icon-minus'
  202. });
  203. });
  204. $(function() { "use strict";
  205. $("#bps_base").TouchSpin({
  206. max: 1024,
  207. min: 0,
  208. postfix: 'MiB',
  209. verticalbuttons: true,
  210. verticalupclass: 'glyph-icon icon-plus',
  211. verticaldownclass: 'glyph-icon icon-minus'
  212. });
  213. });
  214. $(function() { "use strict";
  215. $("#bps_pre_unit").TouchSpin({
  216. max: 10,
  217. min: 0,
  218. step: 0.01,
  219. decimals: 2,
  220. postfix: 'MiB',
  221. verticalbuttons: true,
  222. verticalupclass: 'glyph-icon icon-plus',
  223. verticaldownclass: 'glyph-icon icon-minus'
  224. });
  225. });
  226. $(function() { "use strict";
  227. $("#bps_cap").TouchSpin({
  228. max: 1024 * 2,
  229. min: 0,
  230. postfix: 'MiB',
  231. verticalbuttons: true,
  232. verticalupclass: 'glyph-icon icon-plus',
  233. verticaldownclass: 'glyph-icon icon-minus'
  234. });
  235. });
  236. $(function() { "use strict";
  237. $("#bps_max").TouchSpin({
  238. max: 1024 * 10,
  239. min: 0,
  240. postfix: 'MiB',
  241. verticalbuttons: true,
  242. verticalupclass: 'glyph-icon icon-plus',
  243. verticaldownclass: 'glyph-icon icon-minus'
  244. });
  245. });
  246. $(function() { "use strict";
  247. $("#bps_max_length").TouchSpin({
  248. max: 600,
  249. min: 0,
  250. postfix: '秒',
  251. verticalbuttons: true,
  252. verticalupclass: 'glyph-icon icon-plus',
  253. verticaldownclass: 'glyph-icon icon-minus'
  254. });
  255. });
  256. $(function() { "use strict";
  257. $("#vlan_id").TouchSpin({
  258. max: 4094,
  259. min: 1,
  260. verticalbuttons: true,
  261. verticalupclass: 'glyph-icon icon-plus',
  262. verticaldownclass: 'glyph-icon icon-minus'
  263. });
  264. });
  265. function register_iops_bps_event() {
  266. $('#iops').on('change', function () {
  267. $("#iops_rd").trigger("touchspin.updatesettings", {max: $('#iops').val() - $('#iops_wr').val()});
  268. $("#iops_wr").trigger("touchspin.updatesettings", {max: $('#iops').val() - $('#iops_rd').val()});
  269. });
  270. $('#iops_rd').on('change', function () {
  271. $("#iops_wr").trigger("touchspin.updatesettings", {max: $('#iops').val() - $('#iops_rd').val()});
  272. });
  273. $('#iops_wr').on('change', function () {
  274. $("#iops_rd").trigger("touchspin.updatesettings", {max: $('#iops').val() - $('#iops_wr').val()});
  275. });
  276. $('#bps').on('change', function () {
  277. $("#bps_rd").trigger("touchspin.updatesettings", {max: $('#bps').val() - $('#bps_wr').val()});
  278. $("#bps_wr").trigger("touchspin.updatesettings", {max: $('#bps').val() - $('#bps_rd').val()});
  279. });
  280. $('#bps_rd').on('change', function () {
  281. $("#bps_wr").trigger("touchspin.updatesettings", {max: $('#bps').val() - $('#bps_rd').val()});
  282. });
  283. $('#bps_wr').on('change', function () {
  284. $("#bps_rd").trigger("touchspin.updatesettings", {max: $('#bps').val() - $('#bps_wr').val()});
  285. });
  286. }
  287. function update_quota() {
  288. $.ajax({
  289. url : '/api/config/_quota',
  290. type : 'PATCH',
  291. contentType: "application/json; charset=utf-8",
  292. data : JSON.stringify({
  293. iops_base: parseInt($('#iops_base').val()),
  294. iops_pre_unit: parseInt($('#iops_pre_unit').val()),
  295. iops_cap: parseInt($('#iops_cap').val()),
  296. iops_max: parseInt($('#iops_max').val()),
  297. iops_max_length: parseInt($('#iops_max_length').val()),
  298. bps_base: parseInt($('#bps_base').val()) * 1024 * 1024,
  299. bps_pre_unit: parseFloat($('#bps_pre_unit').val()) * 1024 * 1024,
  300. bps_cap: parseInt($('#bps_cap').val()) * 1024 * 1024,
  301. bps_max: parseInt($('#bps_max').val()) * 1024 * 1024,
  302. bps_max_length: parseInt($('#bps_max_length').val()),
  303. influence_current_guest: $('#influence_current_guest').prop('checked')
  304. }),
  305. error : function() {
  306. alter_danger('性能配额更新失败!');
  307. },
  308. success : function() {
  309. alter_success('性能配额更新成功!');
  310. setTimeout(function() {
  311. refresh();
  312. }, 1000);
  313. }
  314. });
  315. }
  316. function refresh_guest_state() {
  317. $.ajax({
  318. url : '/api/guests/_refresh_guest_state',
  319. type : 'PATCH',
  320. error : function() {
  321. alter_danger('刷新虚拟机状态失败!');
  322. },
  323. success : function() {
  324. alter_success('刷新虚拟机状态成功!');
  325. setTimeout(function() {
  326. refresh();
  327. }, 1000);
  328. }
  329. });
  330. }
  331. function sync_vlans() {
  332. $.ajax({
  333. url : '/api/vlans/_sync',
  334. type : 'PUT',
  335. error : function() {
  336. alter_danger('同步 VLAN 状态失败!');
  337. },
  338. success : function() {
  339. alter_success('同步 VLAN 状态成功!');
  340. setTimeout(function() {
  341. refresh();
  342. }, 1000);
  343. }
  344. });
  345. }
  346. function exchange_ip_pool_for_panel(ip_pool) {
  347. var activity_checked = '';
  348. if (ip_pool.activity > 0) {
  349. activity_checked = 'checked';
  350. }
  351. return '<div class="panel">\n' +
  352. ' <div class="panel-body">\n' +
  353. ' <form class="form-horizontal bordered-row" style="padding-left: 8%;">\n' +
  354. ' <input title="IP Pool ID" class="form-control" name="id" type="text" value="' + ip_pool.id + '" hidden>\n' +
  355. ' <div class="form-group">\n' +
  356. ' <label class="col-sm-2 control-label">起始 IP</label>\n' +
  357. ' <div class="col-sm-3">\n' +
  358. ' <input title="起始 IP" class="form-control" name="start_ip" type="text" value="' + ip_pool.start_ip + '">\n' +
  359. ' </div>\n' +
  360. ' <label class="col-sm-2 control-label">截止 IP</label>\n' +
  361. ' <div class="col-sm-3">\n' +
  362. ' <input title="截止 IP" class="form-control" name="end_ip" type="text" value="' + ip_pool.end_ip + '">\n' +
  363. ' </div>\n' +
  364. ' </div>\n' +
  365. ' <div class="form-group">\n' +
  366. ' <label class="col-sm-2 control-label">子网掩码</label>\n' +
  367. ' <div class="col-sm-3">\n' +
  368. ' <input title="子网掩码" class="form-control" name="netmask" type="text" value="' + ip_pool.netmask + '">\n' +
  369. ' </div>\n' +
  370. ' <label class="col-sm-2 control-label">网关</label>\n' +
  371. ' <div class="col-sm-3">\n' +
  372. ' <input title="网关" class="form-control" name="gateway" type="text" value="' + ip_pool.gateway + '">\n' +
  373. ' </div>\n' +
  374. ' </div>\n' +
  375. ' <div class="form-group">\n' +
  376. ' <label class="col-sm-2 control-label">DNS1</label>\n' +
  377. ' <div class="col-sm-3">\n' +
  378. ' <input title="DNS1" class="form-control" name="dns1" type="text" value="' + ip_pool.dns1 + '">\n' +
  379. ' </div>\n' +
  380. ' <label class="col-sm-2 control-label">DNS2</label>\n' +
  381. ' <div class="col-sm-3">\n' +
  382. ' <input title="DNS2" class="form-control" name="dns2" type="text" value="' + ip_pool.dns2 + '">\n' +
  383. ' </div>\n' +
  384. ' </div>\n' +
  385. ' <div class="form-group">\n' +
  386. ' <label class="col-sm-2 control-label">名称</label>\n' +
  387. ' <div class="col-sm-3">\n' +
  388. ' <input title="名称" class="form-control" name="name" type="text" value="' + ip_pool.name + '">\n' +
  389. ' </div>\n' +
  390. ' <label class="col-sm-2 control-label">备注</label>\n' +
  391. ' <div class="col-sm-3">\n' +
  392. ' <textarea title="备注" class="form-control" name="description">'+ip_pool.description+'</textarea>\n' +
  393. ' </div>\n' +
  394. ' </div>\n' +
  395. ' <div class="form-group" style="margin-bottom: 0;">\n' +
  396. ' <div class="col-sm-6">\n' +
  397. ' <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' +
  398. ' </div>\n' +
  399. ' <div class="col-sm-6">\n' +
  400. ' <div style="padding: 0; text-align: right;">\n' +
  401. ' <button type="button" class="btn btn-sm btn-primary" style="right: 10%;" data-id="' + ip_pool.id + '" onclick="update_ip_pool(this);">更新</button>\n' +
  402. ' <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' +
  403. ' $(\'#delete_instance_desc\').text(get_ip_pool_field_value(this, \'name\'))">删除</button>\n' +
  404. ' </div>\n' +
  405. ' </div>\n' +
  406. ' </div>\n' +
  407. ' </form>\n' +
  408. ' </div>\n' +
  409. '</div>';
  410. }
  411. function get_ip_pools_html() {
  412. var html = '<div class="row" style="padding: 10px 10px 10px 0; width: 100%;">\n' +
  413. ' <div class="col-sm-12" style="padding-right: 0;">\n' +
  414. ' <div class="pull-right">\n' +
  415. ' <button class="btn btn-default" onclick="window.location.reload();" style="border-radius: 0;"><span class="glyph-icon icon-elusive-arrows-cw"></span></button>\n' +
  416. ' <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' +
  417. ' <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' +
  418. ' </div>\n' +
  419. ' </div>\n' +
  420. '</div>';
  421. $.ajax({
  422. url : '/api/ip_pools',
  423. type : 'GET',
  424. contentType: "application/json; charset=utf-8",
  425. dataType: 'json',
  426. async: false,
  427. error : function() {
  428. },
  429. success : function(data, textStatus, xhr) {
  430. $.each(data.data, function(k, v) {
  431. html += exchange_ip_pool_for_panel(v);
  432. });
  433. }
  434. });
  435. return html
  436. }
  437. function refresh_ip_pools() {
  438. var html = get_ip_pools_html();
  439. $('#view_by_ip_pool').append(html);
  440. }
  441. function get_ip_pool_field_value(me, name) {
  442. return $(me).parent().parent().parent().parent().serializeArray().filter(
  443. function(field) {return field.name == name})[0].value;
  444. }
  445. function update_ip_pool(me) {
  446. var id = get_ip_pool_field_value(me, 'id');
  447. var start_ip = get_ip_pool_field_value(me, 'start_ip');
  448. var end_ip = get_ip_pool_field_value(me, 'end_ip');
  449. var netmask = get_ip_pool_field_value(me, 'netmask');
  450. var gateway = get_ip_pool_field_value(me, 'gateway');
  451. var dns1 = get_ip_pool_field_value(me, 'dns1');
  452. var dns2 = get_ip_pool_field_value(me, 'dns2');
  453. var name = get_ip_pool_field_value(me, 'name');
  454. var description = get_ip_pool_field_value(me, 'description');
  455. var data = {
  456. start_ip: start_ip,
  457. end_ip: end_ip,
  458. netmask: netmask,
  459. gateway: gateway,
  460. dns1: dns1,
  461. dns2: dns2,
  462. name: name,
  463. description: description
  464. };
  465. $.ajax({
  466. url : '/api/ip_pools/' + String(id),
  467. type : 'PATCH',
  468. contentType: "application/json; charset=utf-8",
  469. async: false,
  470. dataType: "json",
  471. data : JSON.stringify(data),
  472. error : function(data, textStatus, xhr) {
  473. alter_danger(data.responseText);
  474. alter_warning('更新 IP 池失败!');
  475. },
  476. success : function(data, textStatus, xhr) {
  477. alter_success('更新 IP 池成功!');
  478. }
  479. });
  480. setTimeout(function() {
  481. window.location.reload();
  482. }, 3000);
  483. }
  484. function create_ip_pool(me) {
  485. $('#add_ip_pool_modal').modal('hide');
  486. var start_ip = get_ip_pool_field_value(me, 'start_ip');
  487. var end_ip = get_ip_pool_field_value(me, 'end_ip');
  488. var netmask = get_ip_pool_field_value(me, 'netmask');
  489. var gateway = get_ip_pool_field_value(me, 'gateway');
  490. var dns1 = get_ip_pool_field_value(me, 'dns1');
  491. var dns2 = get_ip_pool_field_value(me, 'dns2');
  492. var name = get_ip_pool_field_value(me, 'name');
  493. var description = get_ip_pool_field_value(me, 'description');
  494. var activity = $('#activity').prop('checked');
  495. var data = {
  496. start_ip: start_ip,
  497. end_ip: end_ip,
  498. netmask: netmask,
  499. gateway: gateway,
  500. dns1: dns1,
  501. dns2: dns2,
  502. name: name,
  503. description: description,
  504. activity: activity
  505. };
  506. $.ajax({
  507. url : '/api/ip_pool',
  508. type : 'POST',
  509. contentType: "application/json; charset=utf-8",
  510. async: false,
  511. dataType: "json",
  512. data : JSON.stringify(data),
  513. error : function(data, textStatus, xhr) {
  514. alter_danger(data.responseText);
  515. alter_warning('添加 IP 池失败!');
  516. },
  517. success : function(data, textStatus, xhr) {
  518. alter_success('您所提交的 IP 池已创建。页面将在3秒钟后自动跳转到 IP 池列表页面!');
  519. }
  520. });
  521. setTimeout(function() {
  522. window.location.reload();
  523. }, 3000);
  524. }
  525. function put_ip_pool_activity(id) {
  526. $.ajax({
  527. url : '/api/ip_pool/' + String(id),
  528. type : 'PUT',
  529. async: false,
  530. dataType: "json",
  531. error : function(data, textStatus, xhr) {
  532. alter_danger(data.responseText);
  533. alter_warning('IP 池激活失败!');
  534. },
  535. success : function(data, textStatus, xhr) {
  536. alter_success('IP 池激活成功!');
  537. }
  538. });
  539. setTimeout(function() {
  540. window.location.reload();
  541. }, 3000);
  542. }
  543. function ip_pool_delete_at(me) {
  544. var ip_pool_id = $('#ip_pool_id').val();
  545. ip_pool_remove(ip_pool_id);
  546. $('#ip_pool_delete_modal').modal('hide');
  547. }
  548. function ip_pool_remove(id) {
  549. $.ajax({
  550. url : '/api/ip_pools/' + id,
  551. type : 'DELETE',
  552. contentType: "application/json; charset=utf-8",
  553. error : function() {
  554. alter_danger('IP 池删除指令发送失败!');
  555. },
  556. success : function() {
  557. alter_success('IP 池删除指令发送成功!');
  558. setTimeout(function() {
  559. refresh();
  560. }, 1000);
  561. }
  562. });
  563. }
  564. function row_onmouseover(me) {
  565. $(me).find(".delete_reserved_ip_trigger").css('display','inline-flex');
  566. }
  567. function row_onmouseout(me) {
  568. $(me).find(".delete_reserved_ip_trigger").css('display','none');
  569. }
  570. function vlan_row_onmouseover(me) {
  571. $(me).find(".edit_vlan_label_trigger, .edit_vlan_description_trigger").css('display','inline-flex');
  572. }
  573. function vlan_row_onmouseout(me) {
  574. $(me).find(".edit_vlan_label_trigger, .edit_vlan_description_trigger").css('display','none');
  575. }
  576. function add_reserved_ip(ip) {
  577. $.ajax({
  578. url : '/api/reserved_ip',
  579. type : 'POST',
  580. contentType: "application/json; charset=utf-8",
  581. async: false,
  582. dataType: "json",
  583. data : JSON.stringify({ip: ip}),
  584. error : function(data, textStatus, xhr) {
  585. alter_danger(data.responseText);
  586. alter_warning('添加保留 IP 失败!');
  587. },
  588. success : function(data, textStatus, xhr) {
  589. var html = '<tr role="row" data-id="' + data['data']['id'] + '" class="odd" onmouseover="row_onmouseover(this);" onmouseout="row_onmouseout(this);">\n' +
  590. ' <td class="text-center">\n' +
  591. data['data']['ip'] +
  592. ' <div style="display: inline;">\n' +
  593. ' <a href="javascript:;" class="delete_reserved_ip_trigger" style="display: none; float: right;">\n' +
  594. ' <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' +
  595. ' </a>\n' +
  596. ' </div>\n' +
  597. ' </td>\n' +
  598. '</tr>';
  599. $('#reserved_ip_table tbody').append(html);
  600. alter_success('添加保留 IP 成功!');
  601. }
  602. });
  603. }
  604. function reserved_ip_refresh() {
  605. $.ajax({
  606. url : '/api/reserved_ips',
  607. type : 'GET',
  608. contentType: "application/json; charset=utf-8",
  609. dataType: 'json',
  610. async: false,
  611. error : function() {
  612. },
  613. success : function(data, textStatus, xhr) {
  614. var html = NaN;
  615. $('#reserved_ip_table tbody').empty();
  616. $.each(data.data, function(k, v) {
  617. html = '<tr role="row" data-id="' + v['id'] + '" class="odd" onmouseover="row_onmouseover(this);" onmouseout="row_onmouseout(this);">\n' +
  618. ' <td class="text-center">\n' +
  619. v['ip'] +
  620. ' <div style="display: inline;">\n' +
  621. ' <a href="javascript:;" class="delete_reserved_ip_trigger" style="display: none; float: right;">\n' +
  622. ' <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' +
  623. ' </a>\n' +
  624. ' </div>\n' +
  625. ' </td>\n' +
  626. '</tr>';
  627. $('#reserved_ip_table tbody').append(html);
  628. });
  629. }
  630. });
  631. }
  632. function reserved_ip_delete(me) {
  633. var id = $(me).parent().parent().parent().parent().data('id');
  634. $.ajax({
  635. url : '/api/reserved_ips/' + id,
  636. type : 'DELETE',
  637. contentType: "application/json; charset=utf-8",
  638. async: false,
  639. error : function(data, textStatus, xhr) {
  640. alter_danger(data.responseText);
  641. alter_warning('添加保留 IP 失败!');
  642. },
  643. success : function(data, textStatus, xhr) {
  644. $('#reserved_ip_table tbody tr[data-id="' +id + '"]').remove()
  645. alter_success('删除保留 IP 成功!');
  646. }
  647. });
  648. }
  649. function tokens_list_refresh() {
  650. $.ajax({
  651. url : '/api/tokens',
  652. type : 'GET',
  653. contentType: "application/json; charset=utf-8",
  654. dataType: 'json',
  655. async: false,
  656. error : function() {
  657. },
  658. success : function(data, textStatus, xhr) {
  659. var html = NaN;
  660. $('#tokens_list_table tbody').empty();
  661. $.each(data.data, function(k, v) {
  662. var color = 'forestgreen';
  663. var ttl = v['ttl'];
  664. if (ttl < 1) {
  665. ttl = '已过期';
  666. color = 'indianred';
  667. }
  668. html = '<tr role="row" class="odd">\n' +
  669. ' <td class="text-center">' + v['token'] + '</td>\n' +
  670. ' <td class="text-center" style="color: ' + color + ';">' + ttl + '</td>\n' +
  671. ' <td class="text-center">' + v['expire'] + '</td>\n' +
  672. '</tr>';
  673. $('#tokens_list_table tbody').append(html);
  674. });
  675. }
  676. });
  677. }
  678. function add_token() {
  679. $.ajax({
  680. url : '/api/token',
  681. type : 'POST',
  682. contentType: "application/json; charset=utf-8",
  683. async: false,
  684. error : function(data, textStatus, xhr) {
  685. alter_danger(data.responseText);
  686. alter_warning('添加 Token 失败!');
  687. },
  688. success : function(data, textStatus, xhr) {
  689. tokens_list_refresh();
  690. alter_success('添加 Token 成功!');
  691. }
  692. });
  693. }
  694. function exchange_arrival_rate_for_tr(arrival, posts) {
  695. if (arrival === posts) {
  696. return '<span style="color: #00BB00;">' + '100%' + '</span>';
  697. } else {
  698. return '<span style="color: #BB0000;">' + arrival + '/' + posts + '</span>';
  699. }
  700. }
  701. function add_vlan() {
  702. $('#add_vlan_modal').modal('hide');
  703. $.ajax({
  704. url : '/api/vlan',
  705. type : 'POST',
  706. contentType: "application/json; charset=utf-8",
  707. async: false,
  708. dataType: "json",
  709. data : JSON.stringify({
  710. label: $('#vlan_label').val(),
  711. vlan_id: parseInt($('#vlan_id').val()),
  712. description: $('#vlan_description').val()
  713. }),
  714. error : function(data, textStatus, xhr) {
  715. alter_danger(data.responseText);
  716. alter_warning('添加 VLAN 失败!');
  717. },
  718. success : function(data, textStatus, xhr) {
  719. var html = '<tr role="row" data-id="' + data['data']['id'] + '" class="odd" onmouseover="row_onmouseover(this);" onmouseout="row_onmouseout(this);">\n' +
  720. ' <td>\n' +
  721. ' <div>\n' +
  722. ' <p style="display: inline-block;">' + data['data']['label'] + '</p>\n' +
  723. ' <a href="javascript:;" class="edit_vlan_label_trigger" data-toggle="modal" data-target="#edit_vlan_label_modal" style="display: none; float: right;" onclick="$(\'#vlan_index_id\').val($(this).parent().parent().parent().data(\'id\'));$(\'#edit_vlan_label\').val($(this).prev().text())">\n' +
  724. ' <span class="glyph-icon icon-elusive-pencil" style="width: 20px; height: 20px; margin-left: 10px; border-radius: 0; border: 1px solid rgb(220, 233, 255); background-color: #ffffff;"></span>\n' +
  725. ' </a>\n' +
  726. ' </div>\n' +
  727. ' </td>\n' +
  728. ' <td class="text-center">' + data['data']['vlan_id'] + '</td>\n' +
  729. ' <td>' +
  730. ' <div>\n' +
  731. ' <p style="display: inline-block;">' + data['data']['description'] + '</p>\n' +
  732. ' <a href="javascript:;" class="edit_vlan_description_trigger" data-toggle="modal" data-target="#edit_vlan_description_modal" style="display: none; float: right;" onclick="$(\'#vlan_index_id\').val($(this).parent().parent().parent().data(\'id\'));$(\'#edit_vlan_description\').val($(this).prev().text())">\n' +
  733. ' <span class="glyph-icon icon-elusive-pencil" style="width: 20px; height: 20px; margin-left: 10px; border-radius: 0; border: 1px solid rgb(220, 233, 255); background-color: #ffffff;"></span>\n' +
  734. ' </a>\n' +
  735. ' </div>\n' +
  736. ' <td class="text-center"><span style="color: #009cc5;">' + '创建中...' + '</span></td>\n' +
  737. ' <td class="text-center">' + new Date(data['data']['create_time'] / 1000).format('yy-mm-dd HH:MM:ss') + '</td>\n' +
  738. ' <td class="text-center">-</td>\n' +
  739. '</tr>';
  740. $('#vlans_list_table tbody').append(html);
  741. alter_success('添加 VLAN 成功!');
  742. setTimeout(function() {
  743. refresh();
  744. }, 3000);
  745. }
  746. });
  747. }
  748. function vlans_list_refresh() {
  749. $.ajax({
  750. url : '/api/vlans',
  751. type : 'GET',
  752. contentType: "application/json; charset=utf-8",
  753. dataType: 'json',
  754. async: false,
  755. error : function() {
  756. },
  757. success : function(data, textStatus, xhr) {
  758. var html = NaN;
  759. var disabled = '';
  760. $('#vlans_list_table tbody').empty();
  761. $.each(data.data, function(k, v) {
  762. if (v['vlan_id'] === -1) {
  763. disabled = ' disabled';
  764. } else {
  765. disabled = '';
  766. }
  767. html = '<tr role="row" data-id="' + v['id'] + '" class="odd' + disabled + '" onmouseover="vlan_row_onmouseover(this);" onmouseout="vlan_row_onmouseout(this);">\n' +
  768. ' <td>\n' +
  769. ' <div>\n' +
  770. ' <p style="display: inline-block;">' + v['label'] + '</p>\n' +
  771. ' <a href="javascript:;" class="edit_vlan_label_trigger" data-toggle="modal" data-target="#edit_vlan_label_modal" style="display: none; float: right;" onclick="$(\'#vlan_index_id\').val($(this).parent().parent().parent().data(\'id\'));$(\'#edit_vlan_label\').val($(this).prev().text())">\n' +
  772. ' <span class="glyph-icon icon-elusive-pencil" style="width: 20px; height: 20px; margin-left: 10px; border-radius: 0; border: 1px solid rgb(220, 233, 255); background-color: #ffffff;"></span>\n' +
  773. ' </a>\n' +
  774. ' </div>\n' +
  775. ' </td>\n' +
  776. ' <td class="text-center">' + v['vlan_id'] + '</td>\n' +
  777. ' <td>' +
  778. ' <div>\n' +
  779. ' <p style="display: inline-block;">' + v['description'] + '</p>\n' +
  780. ' <a href="javascript:;" class="edit_vlan_description_trigger" data-toggle="modal" data-target="#edit_vlan_description_modal" style="display: none; float: right;" onclick="$(\'#vlan_index_id\').val($(this).parent().parent().parent().data(\'id\'));$(\'#edit_vlan_description\').val($(this).prev().text())">\n' +
  781. ' <span class="glyph-icon icon-elusive-pencil" style="width: 20px; height: 20px; margin-left: 10px; border-radius: 0; border: 1px solid rgb(220, 233, 255); background-color: #ffffff;"></span>\n' +
  782. ' </a>\n' +
  783. ' </div>\n' +
  784. ' </td>\n' +
  785. ' <td class="text-center">' + exchange_arrival_rate_for_tr(v['arrival'], v['posts']) + '</td>\n' +
  786. ' <td class="text-center">' + new Date(v['create_time'] / 1000).format('yy-mm-dd HH:MM:ss') + '</td>\n' +
  787. ' <td class="text-center">\n' +
  788. ' <div class="dropdown inline-block">\n' +
  789. ' <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">更多</a>\n' +
  790. ' <ul class="dropdown-menu">\n' +
  791. ' <li>\n' +
  792. ' <a href="javascript:;" style="color: indianred;" data-toggle="modal" data-target="#vlan_delete_modal"\n'+
  793. ' onclick="$(\'#vlan_index_id\').val($(this).parent().parent().parent().parent().parent().data(\'id\'));' +
  794. ' $(\'#delete_vlan_instance_desc\').text(\'VLAN ID: \' + $(this).parent().parent().parent().parent().parent().children()[1].textContent + \' / \' + $(this).parent().parent().parent().parent().parent().children()[0].textContent)">\n'+
  795. ' 删除\n'+
  796. ' </a>\n'+
  797. ' </li>\n' +
  798. ' <li>\n' +
  799. ' <a href="javascript:;" style="color: indianred;" data-toggle="modal" data-target="#vlan_force_delete_modal"\n'+
  800. ' onclick="$(\'#vlan_index_id\').val($(this).parent().parent().parent().parent().parent().data(\'id\'));' +
  801. ' $(\'#force_delete_vlan_instance_desc\').text(\'VLAN ID: \' + $(this).parent().parent().parent().parent().parent().children()[1].textContent + \' / \' + $(this).parent().parent().parent().parent().parent().children()[0].textContent)">\n'+
  802. ' 强制删除\n'+
  803. ' </a>\n'+
  804. ' </li>\n' +
  805. ' </ul>\n' +
  806. ' </div>\n' +
  807. ' </td>\n' +
  808. '</tr>';
  809. $('#vlans_list_table tbody').append(html);
  810. });
  811. }
  812. });
  813. }
  814. function vlan_label_update(me) {
  815. var vlan_index_id = $('#vlan_index_id').val();
  816. var label = $('#edit_vlan_label').val();
  817. $('#edit_vlan_label_modal').modal('hide');
  818. $.ajax({
  819. url : '/api/vlans/' + vlan_index_id,
  820. type : 'PATCH',
  821. contentType: "application/json; charset=utf-8",
  822. data : JSON.stringify({
  823. label: label
  824. }),
  825. error : function() {
  826. alter_danger('VLAN 名称更新失败!');
  827. },
  828. success : function() {
  829. alter_success('VLAN 名称更新成功!');
  830. setTimeout(function() {
  831. refresh();
  832. }, 1000);
  833. }
  834. });
  835. }
  836. function vlan_description_update(me) {
  837. var vlan_index_id = $('#vlan_index_id').val();
  838. var description = $('#edit_vlan_description').val();
  839. $('#edit_vlan_description_modal').modal('hide');
  840. $.ajax({
  841. url : '/api/vlans/' + vlan_index_id,
  842. type : 'PATCH',
  843. contentType: "application/json; charset=utf-8",
  844. data : JSON.stringify({
  845. description: description
  846. }),
  847. error : function() {
  848. alter_danger('VLAN 备注更新失败!');
  849. },
  850. success : function() {
  851. alter_success('VLAN 备注更新成功!');
  852. setTimeout(function() {
  853. refresh();
  854. }, 1000);
  855. }
  856. });
  857. }
  858. function vlan_delete_at() {
  859. $('#vlan_delete_modal').modal('hide');
  860. var vlan_index_id = $('#vlan_index_id').val();
  861. $.ajax({
  862. url : '/api/vlans/' + vlan_index_id,
  863. type : 'DELETE',
  864. contentType: "application/json; charset=utf-8",
  865. async: false,
  866. error : function(data, textStatus, xhr) {
  867. alter_danger(data.responseText);
  868. alter_warning('删除 VLAN 失败!');
  869. },
  870. success : function(data, textStatus, xhr) {
  871. alter_success('删除 VLAN 成功!');
  872. setTimeout(function() {
  873. refresh();
  874. }, 1000);
  875. }
  876. });
  877. }
  878. function vlan_force_delete_at() {
  879. $('#vlan_force_delete_modal').modal('hide');
  880. var vlan_index_id = $('#vlan_index_id').val();
  881. $.ajax({
  882. url : '/api/vlans/_force/' + vlan_index_id,
  883. type : 'DELETE',
  884. contentType: "application/json; charset=utf-8",
  885. async: false,
  886. error : function(data, textStatus, xhr) {
  887. alter_danger(data.responseText);
  888. alter_warning('强制删除 VLAN 失败!');
  889. },
  890. success : function(data, textStatus, xhr) {
  891. alter_success('强制删除 VLAN 成功!');
  892. setTimeout(function() {
  893. refresh();
  894. }, 1000);
  895. }
  896. });
  897. }
  898. </script>
  899. <div class="panel">
  900. <div class="panel-body">
  901. <ul class="nav nav-tabs mrg25B">
  902. <li class="active"><a href="javascript:;" onclick="select_this(this);" id="view_by_jimv_system_config_label">JimV 系统配置</a></li>
  903. <li><a href="javascript:;" onclick="select_this(this);" id="view_by_ip_pool_label">IP 池</a></li>
  904. <li><a href="javascript:;" onclick="select_this(this);" id="view_by_vlan_label">VLAN</a></li>
  905. <li><a href="javascript:;" onclick="select_this(this);" id="view_by_quota_label">性能配额</a></li>
  906. <li><a href="javascript:;" onclick="select_this(this);" id="view_by_token_label">Token</a></li>
  907. <li><a href="javascript:;" onclick="select_this(this);" id="view_by_auxiliary_label">辅助</a></li>
  908. </ul>
  909. <div id="view_by_jimv_system_config" class="example-box-wrapper">
  910. <form class="form-horizontal bordered-row" style="padding-left: 8%;">
  911. <div class="form-group">
  912. <label class="col-sm-2 control-label">网桥(业务网络)</label>
  913. <div class="col-sm-3">
  914. <input title="Guest 业务网络" class="form-control" name="vm_network" type="text" disabled value="{{ config.vm_network }}">
  915. </div>
  916. <label class="col-sm-2 control-label">网桥(管理网络)</label>
  917. <div class="col-sm-3">
  918. <input title="Guest 管理网络" class="form-control" name="vm_manage_network" type="text" disabled value="{{ config.vm_manage_network }}">
  919. </div>
  920. </div>
  921. <div class="form-group">
  922. <label class="col-sm-2 control-label">虚拟机磁盘存储模式</label>
  923. <div class="col-sm-3">
  924. <select id="storage_mode" title="虚拟机磁盘存储模式" class="selectpicker" name="storage_mode" data-width="100%" disabled>
  925. <option {% if config.storage_mode == 0 %}selected{% endif %} value="0">本地存储</option>
  926. <option {% if config.storage_mode == 1 %}selected{% endif %} value="1" data-subtext="NFS">挂载共享</option>
  927. <option {% if config.storage_mode == 2 %}selected{% endif %} value="2">Ceph</option>
  928. <option {% if config.storage_mode == 3 %}selected{% endif %} value="3">GlusterFS</option>
  929. </select>
  930. </div>
  931. <label id="dfs_volume_label" class="col-sm-2 control-label" style="display: {% if config.storage_mode in [3] %}unset{% else %}none{% endif %};">分布式文件系统存储卷</label>
  932. <div class="col-sm-3">
  933. <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 }}">
  934. </div>
  935. </div>
  936. <div class="form-group">
  937. <label class="col-sm-2 control-label">虚拟机磁盘存放路径</label>
  938. <div class="col-sm-3">
  939. <input title="虚拟机磁盘存放路径" class="form-control" name="storage_path" type="text" disabled value="{{ config.storage_path }}">
  940. </div>
  941. </div>
  942. </form>
  943. </div>
  944. <div id="view_by_quota" class="example-box-wrapper" style="display: none;">
  945. <form class="form-horizontal bordered-row" style="padding-left: 8%;">
  946. <div class="form-group" style="margin-bottom: 0;">
  947. <label class="col-sm-2 control-label">
  948. <span class="glyph-icon icon-exchange" style="transform: rotate(90deg); display: inline-flex;"></span>
  949. &nbsp;&nbsp;IOPS 基准值
  950. </label>
  951. <div class="col-sm-3">
  952. <input id="iops_base" title="IOPS 基准值" class="form-control" type="text" value="{{ config.iops_base }}" name="iops_base">
  953. </div>
  954. <span class="col-sm-1"></span>
  955. <label class="col-sm-2 control-label"><span class="glyph-icon icon-openid"></span>&nbsp;&nbsp;BPS 基准值</label>
  956. <div class="col-sm-3">
  957. <input id="bps_base" title="BPS 基准值" class="form-control" type="text" value="{{ (config.bps_base / 1024 / 1024) | int }}" name="bps_base">
  958. </div>
  959. <span class="col-sm-1"></span>
  960. </div>
  961. <div class="form-group" style="margin-bottom: 0;">
  962. <label class="col-sm-2 control-label">
  963. <span class="glyph-icon icon-exchange" style="transform: rotate(90deg); display: inline-flex;"></span>
  964. &nbsp;&nbsp;IOPS/GiB 增益
  965. </label>
  966. <div class="col-sm-3">
  967. <input id="iops_pre_unit" title="IOPS/GiB 增益" class="form-control" type="text" value="{{ config.iops_pre_unit }}" name="iops_pre_unit">
  968. </div>
  969. <span class="col-sm-1"></span>
  970. <label class="col-sm-2 control-label"><span class="glyph-icon icon-openid"></span>&nbsp;&nbsp;BPS/GiB 增益</label>
  971. <div class="col-sm-3">
  972. <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">
  973. </div>
  974. <span class="col-sm-1"></span>
  975. </div>
  976. <div class="form-group" style="margin-bottom: 0;">
  977. <label class="col-sm-2 control-label">
  978. <span class="glyph-icon icon-exchange" style="transform: rotate(90deg); display: inline-flex;"></span>
  979. &nbsp;&nbsp;IOPS 增益上限
  980. </label>
  981. <div class="col-sm-3">
  982. <input id="iops_cap" title="IOPS 增益上限" class="form-control" type="text" value="{{ config.iops_cap }}" name="iops_cap">
  983. </div>
  984. <span class="col-sm-1"></span>
  985. <label class="col-sm-2 control-label"><span class="glyph-icon icon-openid"></span>&nbsp;&nbsp;BPS 增益上限</label>
  986. <div class="col-sm-3">
  987. <input id="bps_cap" title="BPS 增益上限 (MiB)" class="form-control" type="text" value="{{ (config.bps_cap / 1024 / 1024) | int }}" name="bps_cap">
  988. </div>
  989. <span class="col-sm-1"></span>
  990. </div>
  991. <div class="form-group" style="margin-bottom: 0;">
  992. <label class="col-sm-2 control-label">
  993. <span class="glyph-icon icon-exchange" style="transform: rotate(90deg); display: inline-flex;"></span>
  994. <span class="glyph-icon icon-bitbucket" style="margin-left: -4px;"></span>
  995. &nbsp;&nbsp;IOPS 桶宽
  996. </label>
  997. <div class="col-sm-3">
  998. <input id="iops_max" title="IOPS 桶宽" class="form-control" type="text" value="{{ config.iops_max }}" name="iops_max">
  999. </div>
  1000. <span class="col-sm-1"></span>
  1001. <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>
  1002. <div class="col-sm-3">
  1003. <input id="bps_max" title="BPS 桶宽 (MiB)" class="form-control" type="text" value="{{ (config.bps_max / 1024 / 1024) | int }}" name="bps_max">
  1004. </div>
  1005. <span class="col-sm-1"></span>
  1006. </div>
  1007. <div class="form-group" style="margin-bottom: 0;">
  1008. <label class="col-sm-2 control-label">
  1009. <span class="glyph-icon icon-exchange" style="transform: rotate(90deg); display: inline-flex;"></span>
  1010. <span class="glyph-icon icon-bitbucket" style="margin-left: -4px;"></span>
  1011. &nbsp;&nbsp;IOPS 桶高
  1012. </label>
  1013. <div class="col-sm-3">
  1014. <input id="iops_max_length" title="IOPS 桶高 (秒)" class="form-control" type="text" value="{{ config.iops_max_length }}" name="iops_max_length">
  1015. </div>
  1016. <span class="col-sm-1"></span>
  1017. <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>
  1018. <div class="col-sm-3">
  1019. <input id="bps_max_length" title="BPS 桶高 (秒)" class="form-control" type="text" value="{{ config.bps_max_length }}" name="bps_max_length">
  1020. </div>
  1021. <span class="col-sm-1"></span>
  1022. </div>
  1023. <div class="form-group" style="margin-bottom: 0;">
  1024. <div class="col-sm-6">
  1025. <label>
  1026. <input id="influence_current_guest" type="checkbox" name="influence_current_guest">
  1027. 同时更新已存在的实例
  1028. </label>
  1029. </div>
  1030. <div class="col-sm-6">
  1031. <div style="padding: 0; text-align: right;">
  1032. <button type="button" class="btn btn-sm btn-primary" style="right: 10%;" onclick="update_quota();">更新</button>
  1033. </div>
  1034. </div>
  1035. </div>
  1036. </form>
  1037. </div>
  1038. <div id="view_by_ip_pool" class="example-box-wrapper" style="display: none;">
  1039. </div>
  1040. <div id="view_by_vlan" class="example-box-wrapper" style="display: none;">
  1041. <div class="row" style="padding: 10px 10px 10px 0; width: 100%;">
  1042. <div class="col-sm-12" style="padding-right: 0;">
  1043. <div class="pull-right">
  1044. <button class="btn btn-default" onclick="window.location.reload();" style="border-radius: 0;"><span class="glyph-icon icon-elusive-arrows-cw"></span></button>
  1045. <a class="btn btn-info" href="javascript:;" data-toggle="modal" data-target="#add_vlan_modal" style="border-radius: 0; padding-left: 40px; padding-right: 40px;">添加 VLAN</a>
  1046. </div>
  1047. </div>
  1048. </div>
  1049. <table id="vlans_list_table" class="table table-bordered table-hover" cellspacing="0" width="100%" role="grid" style="width: 100%; margin-bottom: 0;">
  1050. <thead>
  1051. <tr role="row">
  1052. <th width="180px">名称</th>
  1053. <th class="text-center" width="120px">VLAN ID</th>
  1054. <th>描述</th>
  1055. <th class="text-center" width="100px">完整度</th>
  1056. <th class="text-center" width="160px">创建时间</th>
  1057. <th class="text-center" width="100px">操作</th>
  1058. </tr>
  1059. </thead>
  1060. <tbody>
  1061. </tbody>
  1062. </table>
  1063. </div>
  1064. <div id="view_by_token" class="example-box-wrapper" style="display: none;">
  1065. <div class="row" style="padding: 10px 10px 10px 0; width: 100%;">
  1066. <div class="col-sm-12" style="padding-right: 0;">
  1067. <div class="pull-right">
  1068. <button class="btn btn-default" onclick="window.location.reload();" style="border-radius: 0;"><span class="glyph-icon icon-elusive-arrows-cw"></span></button>
  1069. <a class="btn btn-info" href="javascript:;" onclick="add_token();" style="border-radius: 0; padding-left: 40px; padding-right: 40px;">添加 Token</a>
  1070. </div>
  1071. </div>
  1072. </div>
  1073. <table id="tokens_list_table" class="table table-bordered table-hover" cellspacing="0" width="100%" role="grid" style="width: 100%;">
  1074. <thead>
  1075. <tr role="row">
  1076. <th class="text-center">Token</th>
  1077. <th class="text-center">TTL</th>
  1078. <th class="text-center">逾期时间</th>
  1079. </tr>
  1080. </thead>
  1081. <tbody>
  1082. </tbody>
  1083. </table>
  1084. </div>
  1085. <div id="view_by_auxiliary" class="example-box-wrapper" style="display: none;">
  1086. <form class="form-horizontal bordered-row" style="padding-left: 8%;">
  1087. <div class="form-group" style="margin-bottom: 0;">
  1088. <div class="col-sm-3">
  1089. <button type="button" class="btn btn-primary" onclick="refresh_guest_state();">刷新虚拟机状态</button>
  1090. </div>
  1091. <div class="col-sm-3">
  1092. <button type="button" class="btn btn-primary" onclick="sync_vlans();">同步计算节点 VLAN</button>
  1093. </div>
  1094. </div>
  1095. </form>
  1096. </div>
  1097. </div>
  1098. </div>
  1099. <input id="ip_pool_id" title="IP Pool ID" name="ip_pool_id" hidden>
  1100. <input id="vlan_index_id" title="VLAN Index ID" name="vlan_index_id" hidden>
  1101. <div class="modal" id="add_ip_pool_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  1102. <div class="modal-dialog modal-lg">
  1103. <div class="modal-content">
  1104. <div class="modal-header">
  1105. <h4 class="modal-title">添加 IP 池:</h4>
  1106. </div>
  1107. <div class="panel">
  1108. <div class="panel-body">
  1109. <form class="form-horizontal bordered-row" style="padding-left: 16%;">
  1110. <div class="form-group">
  1111. <label class="col-sm-2 control-label">起始 IP</label>
  1112. <div class="col-sm-3">
  1113. <input title="起始 IP" class="form-control" name="start_ip" type="text">
  1114. </div>
  1115. <label class="col-sm-2 control-label">截止 IP</label>
  1116. <div class="col-sm-3">
  1117. <input title="截止 IP" class="form-control" name="end_ip" type="text">
  1118. </div>
  1119. </div>
  1120. <div class="form-group">
  1121. <label class="col-sm-2 control-label">子网掩码</label>
  1122. <div class="col-sm-3">
  1123. <input title="子网掩码" class="form-control" name="netmask" type="text">
  1124. </div>
  1125. <label class="col-sm-2 control-label">网关</label>
  1126. <div class="col-sm-3">
  1127. <input title="网关" class="form-control" name="gateway" type="text">
  1128. </div>
  1129. </div>
  1130. <div class="form-group">
  1131. <label class="col-sm-2 control-label">DNS1</label>
  1132. <div class="col-sm-3">
  1133. <input title="DNS1" class="form-control" name="dns1" type="text">
  1134. </div>
  1135. <label class="col-sm-2 control-label">DNS2</label>
  1136. <div class="col-sm-3">
  1137. <input title="DNS2" class="form-control" name="dns2" type="text">
  1138. </div>
  1139. </div>
  1140. <div class="form-group">
  1141. <label class="col-sm-2 control-label">名称</label>
  1142. <div class="col-sm-3">
  1143. <input title="名称" class="form-control" name="name" type="text">
  1144. </div>
  1145. <label class="col-sm-2 control-label">备注</label>
  1146. <div class="col-sm-3">
  1147. <textarea title="备注" class="form-control" name="description"></textarea>
  1148. </div>
  1149. </div>
  1150. <div class="form-group" style="margin-bottom: 0;">
  1151. <div class="col-sm-6">
  1152. <div class="checkbox checkbox-info">
  1153. <label>
  1154. <input id="activity" name="activity" type="checkbox" checked class="custom-checkbox">
  1155. 设为默认
  1156. </label>
  1157. </div>
  1158. </div>
  1159. <div class="col-sm-6">
  1160. <div style="padding: 0; text-align: right;">
  1161. <button type="button" class="btn btn-sm btn-primary" style="right: 20%;" onclick="create_ip_pool(this);">创建</button>
  1162. <button type="button" class="btn btn-sm btn-default" style="right: 10%;" data-dismiss="modal">取消</button>
  1163. </div>
  1164. </div>
  1165. </div>
  1166. </form>
  1167. </div>
  1168. </div>
  1169. </div>
  1170. </div>
  1171. </div>
  1172. <div class="modal" id="ip_pool_delete_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  1173. <div class="modal-dialog">
  1174. <div class="modal-content">
  1175. <div class="modal-header">
  1176. <h4 class="modal-title">删除 IP 池:</h4>
  1177. </div>
  1178. <div class="modal-body">
  1179. <p>您确定要删除该 IP 池吗?</p>
  1180. <h3 style="color: orangered;" id="delete_instance_desc"></h3>
  1181. </div>
  1182. <div class="modal-footer">
  1183. <button type="button" class="btn btn-sm btn-primary" onclick="ip_pool_delete_at();">确定</button>
  1184. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  1185. </div>
  1186. </div>
  1187. </div>
  1188. </div>
  1189. <div class="modal" id="reserved_ip_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  1190. <div class="modal-dialog modal-sm">
  1191. <div class="modal-content">
  1192. <div class="modal-header">
  1193. <h4 class="modal-title">保留 IP:</h4>
  1194. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  1195. <span aria-hidden="true">&times;</span>
  1196. </button>
  1197. </div>
  1198. <div class="modal-body" style="padding-top: 0; padding-bottom: 0;">
  1199. <div class="example-box-wrapper">
  1200. <form id="reserved_ip_form" class="form-horizontal bordered-row" action="javascript:;">
  1201. <div class="form-group">
  1202. <div class="col-sm-1"></div>
  1203. <div class="col-sm-10" style="height: 300px; overflow: auto;">
  1204. <table id="reserved_ip_table" class="table table-bordered table-hover" cellspacing="0" width="100%" role="grid"
  1205. style="width: 100%; margin-bottom: 0;">
  1206. <tbody></tbody>
  1207. </table>
  1208. </div>
  1209. <div class="col-sm-1"></div>
  1210. </div>
  1211. <div class="form-group">
  1212. <div class="col-sm-1"></div>
  1213. <div class="col-sm-10">
  1214. <input id="reserved_ip_input" class="form-control" style="text-align: center;" type="text" placeholder="将要保留的 IP">
  1215. </div>
  1216. <div class="col-sm-1"></div>
  1217. </div>
  1218. </form>
  1219. </div>
  1220. </div>
  1221. </div>
  1222. </div>
  1223. </div>
  1224. <div class="modal" id="add_vlan_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  1225. <div class="modal-dialog modal-sm">
  1226. <div class="modal-content">
  1227. <div class="modal-header">
  1228. <h4 class="modal-title">添加 VLAN:</h4>
  1229. </div>
  1230. <div class="panel">
  1231. <div class="panel-body">
  1232. <form class="form-horizontal bordered-row" style="padding-left: 16%;">
  1233. <div class="form-group">
  1234. <label class="col-sm-3 control-label" style="padding-right: 0;">名称</label>
  1235. <div class="col-sm-8">
  1236. <input title="VLAN 名称" class="form-control" id="vlan_label" name="vlan_label" type="text">
  1237. </div>
  1238. </div>
  1239. <div class="form-group">
  1240. <label class="col-sm-3 control-label" style="padding-right: 0;">VLAN ID</label>
  1241. <div class="col-sm-8">
  1242. <input title="VLAN ID" class="form-control" id="vlan_id" name="vlan_id" type="text">
  1243. </div>
  1244. </div>
  1245. <div class="form-group">
  1246. <label class="col-sm-3 control-label" style="padding-right: 0;">备注</label>
  1247. <div class="col-sm-8">
  1248. <textarea title="备注" class="form-control" id="vlan_description" name="vlan_description"></textarea>
  1249. </div>
  1250. </div>
  1251. <div class="form-group" style="margin-bottom: 0;">
  1252. <div class="col-sm-6">
  1253. </div>
  1254. <div class="col-sm-6">
  1255. <div style="padding: 0; text-align: right;">
  1256. <button type="button" class="btn btn-sm btn-primary" style="right: 20%;" onclick="add_vlan(this);">创建</button>
  1257. <button type="button" class="btn btn-sm btn-default" style="right: 10%;" data-dismiss="modal">取消</button>
  1258. </div>
  1259. </div>
  1260. </div>
  1261. </form>
  1262. </div>
  1263. </div>
  1264. </div>
  1265. </div>
  1266. </div>
  1267. <div class="modal" id="edit_vlan_label_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  1268. <div class="modal-dialog modal-sm">
  1269. <div class="modal-content">
  1270. <div class="modal-header">
  1271. <h4 class="modal-title">编辑 VLAN 名称:</h4>
  1272. </div>
  1273. <div class="modal-body">
  1274. <input id="edit_vlan_label" title="VLAN 名称" class="form-control" name="vlan_label">
  1275. </div>
  1276. <div class="modal-footer">
  1277. <button type="button" class="btn btn-sm btn-primary" onclick="vlan_label_update();">确定</button>
  1278. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  1279. </div>
  1280. </div>
  1281. </div>
  1282. </div>
  1283. <div class="modal" id="edit_vlan_description_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  1284. <div class="modal-dialog modal-sm">
  1285. <div class="modal-content">
  1286. <div class="modal-header">
  1287. <h4 class="modal-title">编辑 VLAN 备注:</h4>
  1288. </div>
  1289. <div class="modal-body">
  1290. <textarea id="edit_vlan_description" rows="6" title="VLAN 备注" class="form-control" name="vlan_description"></textarea>
  1291. </div>
  1292. <div class="modal-footer">
  1293. <button type="button" class="btn btn-sm btn-primary" onclick="vlan_description_update();">确定</button>
  1294. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  1295. </div>
  1296. </div>
  1297. </div>
  1298. </div>
  1299. <div class="modal" id="vlan_delete_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  1300. <div class="modal-dialog">
  1301. <div class="modal-content">
  1302. <div class="modal-header">
  1303. <h4 class="modal-title">删除 VLAN:</h4>
  1304. </div>
  1305. <div class="modal-body">
  1306. <p>您确定要删除该 VLAN 吗?</p>
  1307. <h3 style="color: orangered;" id="delete_vlan_instance_desc"></h3>
  1308. </div>
  1309. <div class="modal-footer">
  1310. <button type="button" class="btn btn-sm btn-primary" onclick="vlan_delete_at();">确定</button>
  1311. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  1312. </div>
  1313. </div>
  1314. </div>
  1315. </div>
  1316. <div class="modal" id="vlan_force_delete_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  1317. <div class="modal-dialog">
  1318. <div class="modal-content">
  1319. <div class="modal-header">
  1320. <h4 class="modal-title">强制删除 VLAN:</h4>
  1321. </div>
  1322. <div class="modal-body">
  1323. <p>您确定要强制删除该 VLAN 吗?</p>
  1324. <h3 style="color: orangered;" id="force_delete_vlan_instance_desc"></h3>
  1325. </div>
  1326. <div class="modal-footer">
  1327. <button type="button" class="btn btn-sm btn-primary" onclick="vlan_force_delete_at();">确定</button>
  1328. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  1329. </div>
  1330. </div>
  1331. </div>
  1332. </div>
  1333. {% endblock content %}