config_show.html 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. {% extends "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. </style>
  23. {% endblock head %}
  24. {% block content %}
  25. <script>
  26. $(document).ready(function() {
  27. $('body').addClass('add-transition');
  28. $('.add-page-transition').on('click', function(){
  29. var transAttr = $(this).attr('data-transition');
  30. $('.add-transition').attr('class', 'add-transition');
  31. $('.add-transition').addClass(transAttr);
  32. });
  33. $('#storage_mode').on('changed.bs.select', function (me) {
  34. if ($('#storage_mode').val() == '2' || $('#storage_mode').val() == '3') {
  35. $('#dfs_volume_label').css('display', 'unset');
  36. $('#dfs_volume').css('display', 'unset');
  37. } else {
  38. $('#dfs_volume_label').css('display', 'none');
  39. $('#dfs_volume').css('display', 'none');
  40. }
  41. });
  42. register_iops_bps_event();
  43. });
  44. function refresh() {
  45. window.location.href=window.location.pathname;
  46. }
  47. function select_this(me) {
  48. $(me).parent().parent().children().removeClass('active');
  49. $(me).parent().addClass('active');
  50. $('#jimv_system_config, #quota').css('display', 'none');
  51. if (me.id === 'quota_label') {
  52. $('#quota').css('display', 'unset');
  53. } else {
  54. $('#jimv_system_config').css('display', 'unset');
  55. }
  56. }
  57. $(function() { "use strict";
  58. $("#iops_base").TouchSpin({
  59. max: 10000,
  60. min: 0,
  61. verticalbuttons: true,
  62. verticalupclass: 'glyph-icon icon-plus',
  63. verticaldownclass: 'glyph-icon icon-minus'
  64. });
  65. });
  66. $(function() { "use strict";
  67. $("#iops_pre_unit").TouchSpin({
  68. max: 100,
  69. min: 0,
  70. verticalbuttons: true,
  71. verticalupclass: 'glyph-icon icon-plus',
  72. verticaldownclass: 'glyph-icon icon-minus'
  73. });
  74. });
  75. $(function() { "use strict";
  76. $("#iops_cap").TouchSpin({
  77. max: 100000,
  78. min: 0,
  79. verticalbuttons: true,
  80. verticalupclass: 'glyph-icon icon-plus',
  81. verticaldownclass: 'glyph-icon icon-minus'
  82. });
  83. });
  84. $(function() { "use strict";
  85. $("#iops_max").TouchSpin({
  86. max: 200000,
  87. min: 0,
  88. verticalbuttons: true,
  89. verticalupclass: 'glyph-icon icon-plus',
  90. verticaldownclass: 'glyph-icon icon-minus'
  91. });
  92. });
  93. $(function() { "use strict";
  94. $("#iops_max_length").TouchSpin({
  95. max: 600,
  96. min: 0,
  97. postfix: '秒',
  98. verticalbuttons: true,
  99. verticalupclass: 'glyph-icon icon-plus',
  100. verticaldownclass: 'glyph-icon icon-minus'
  101. });
  102. });
  103. $(function() { "use strict";
  104. $("#bps_base").TouchSpin({
  105. max: 1024,
  106. min: 0,
  107. postfix: 'MiB',
  108. verticalbuttons: true,
  109. verticalupclass: 'glyph-icon icon-plus',
  110. verticaldownclass: 'glyph-icon icon-minus'
  111. });
  112. });
  113. $(function() { "use strict";
  114. $("#bps_pre_unit").TouchSpin({
  115. max: 10,
  116. min: 0,
  117. step: 0.01,
  118. decimals: 2,
  119. postfix: 'MiB',
  120. verticalbuttons: true,
  121. verticalupclass: 'glyph-icon icon-plus',
  122. verticaldownclass: 'glyph-icon icon-minus'
  123. });
  124. });
  125. $(function() { "use strict";
  126. $("#bps_cap").TouchSpin({
  127. max: 1024 * 2,
  128. min: 0,
  129. postfix: 'MiB',
  130. verticalbuttons: true,
  131. verticalupclass: 'glyph-icon icon-plus',
  132. verticaldownclass: 'glyph-icon icon-minus'
  133. });
  134. });
  135. $(function() { "use strict";
  136. $("#bps_max").TouchSpin({
  137. max: 1024 * 10,
  138. min: 0,
  139. postfix: 'MiB',
  140. verticalbuttons: true,
  141. verticalupclass: 'glyph-icon icon-plus',
  142. verticaldownclass: 'glyph-icon icon-minus'
  143. });
  144. });
  145. $(function() { "use strict";
  146. $("#bps_max_length").TouchSpin({
  147. max: 600,
  148. min: 0,
  149. postfix: '秒',
  150. verticalbuttons: true,
  151. verticalupclass: 'glyph-icon icon-plus',
  152. verticaldownclass: 'glyph-icon icon-minus'
  153. });
  154. });
  155. function register_iops_bps_event() {
  156. $('#iops').on('change', function () {
  157. $("#iops_rd").trigger("touchspin.updatesettings", {max: $('#iops').val() - $('#iops_wr').val()});
  158. $("#iops_wr").trigger("touchspin.updatesettings", {max: $('#iops').val() - $('#iops_rd').val()});
  159. });
  160. $('#iops_rd').on('change', function () {
  161. $("#iops_wr").trigger("touchspin.updatesettings", {max: $('#iops').val() - $('#iops_rd').val()});
  162. });
  163. $('#iops_wr').on('change', function () {
  164. $("#iops_rd").trigger("touchspin.updatesettings", {max: $('#iops').val() - $('#iops_wr').val()});
  165. });
  166. $('#bps').on('change', function () {
  167. $("#bps_rd").trigger("touchspin.updatesettings", {max: $('#bps').val() - $('#bps_wr').val()});
  168. $("#bps_wr").trigger("touchspin.updatesettings", {max: $('#bps').val() - $('#bps_rd').val()});
  169. });
  170. $('#bps_rd').on('change', function () {
  171. $("#bps_wr").trigger("touchspin.updatesettings", {max: $('#bps').val() - $('#bps_rd').val()});
  172. });
  173. $('#bps_wr').on('change', function () {
  174. $("#bps_rd").trigger("touchspin.updatesettings", {max: $('#bps').val() - $('#bps_wr').val()});
  175. });
  176. }
  177. function update_quota() {
  178. $.ajax({
  179. url : '/api/config/_quota',
  180. type : 'PATCH',
  181. contentType: "application/json; charset=utf-8",
  182. data : JSON.stringify({
  183. iops_base: parseInt($('#iops_base').val()),
  184. iops_pre_unit: parseInt($('#iops_pre_unit').val()),
  185. iops_cap: parseInt($('#iops_cap').val()),
  186. iops_max: parseInt($('#iops_max').val()),
  187. iops_max_length: parseInt($('#iops_max_length').val()),
  188. bps_base: parseInt($('#bps_base').val()) * 1024 * 1024,
  189. bps_pre_unit: parseFloat($('#bps_pre_unit').val()) * 1024 * 1024,
  190. bps_cap: parseInt($('#bps_cap').val()) * 1024 * 1024,
  191. bps_max: parseInt($('#bps_max').val()) * 1024 * 1024,
  192. bps_max_length: parseInt($('#bps_max_length').val()),
  193. influence_current_guest: $('#influence_current_guest').prop('checked')
  194. }),
  195. error : function() {
  196. alter_danger('性能配额更新失败!');
  197. },
  198. success : function() {
  199. alter_success('性能配额更新成功!');
  200. setTimeout(function() {
  201. refresh();
  202. }, 1000);
  203. }
  204. });
  205. }
  206. </script>
  207. <div class="panel">
  208. <div class="panel-body">
  209. <ul class="nav nav-tabs mrg25B">
  210. <li class="active"><a href="javascript:;" onclick="select_this(this);" id="jimv_system_config_label">JimV 系统配置</a></li>
  211. <li><a href="javascript:;" onclick="select_this(this);" id="quota_label">性能配额</a></li>
  212. </ul>
  213. <div id="jimv_system_config" class="example-box-wrapper">
  214. <form class="form-horizontal bordered-row" style="padding-left: 8%;">
  215. <div class="form-group">
  216. <label class="col-sm-2 control-label">网桥(业务网络)</label>
  217. <div class="col-sm-3">
  218. <input title="Guest 业务网络" class="form-control" name="vm_network" type="text" disabled value="{{ config_ret.data.vm_network }}">
  219. </div>
  220. <label class="col-sm-2 control-label">网桥(管理网络)</label>
  221. <div class="col-sm-3">
  222. <input title="Guest 管理网络" class="form-control" name="vm_manage_network" type="text" disabled value="{{ config_ret.data.vm_manage_network }}">
  223. </div>
  224. </div>
  225. <div class="form-group">
  226. <label class="col-sm-2 control-label">起始 IP</label>
  227. <div class="col-sm-3">
  228. <input title="起始 IP" class="form-control" name="start_ip" type="text" disabled value="{{ config_ret.data.start_ip }}">
  229. </div>
  230. <label class="col-sm-2 control-label">截止 IP</label>
  231. <div class="col-sm-3">
  232. <input title="截止 IP" class="form-control" name="end_ip" type="text" disabled value="{{ config_ret.data.end_ip }}">
  233. </div>
  234. </div>
  235. <div class="form-group">
  236. <label class="col-sm-2 control-label">子网掩码</label>
  237. <div class="col-sm-3">
  238. <input title="子网掩码" class="form-control" name="netmask" type="text" disabled value="{{ config_ret.data.netmask }}">
  239. </div>
  240. <label class="col-sm-2 control-label">网关</label>
  241. <div class="col-sm-3">
  242. <input title="网关" class="form-control" name="gateway" type="text" disabled value="{{ config_ret.data.gateway }}">
  243. </div>
  244. </div>
  245. <div class="form-group">
  246. <label class="col-sm-2 control-label">DNS1</label>
  247. <div class="col-sm-3">
  248. <input title="DNS1" class="form-control" name="dns1" type="text" disabled value="{{ config_ret.data.dns1 }}">
  249. </div>
  250. <label class="col-sm-2 control-label">DNS2</label>
  251. <div class="col-sm-3">
  252. <input title="DNS2" class="form-control" name="dns2" type="text" disabled value="{{ config_ret.data.dns2 }}">
  253. </div>
  254. </div>
  255. <div class="form-group">
  256. <label class="col-sm-2 control-label">起始 VNC 端口</label>
  257. <div class="col-sm-3">
  258. <input title="起始 VNC 端口" class="form-control" name="start_vnc_port" type="text" disabled value="{{ config_ret.data.start_vnc_port }}">
  259. </div>
  260. </div>
  261. <div class="form-group">
  262. <label class="col-sm-2 control-label">虚拟机磁盘存储模式</label>
  263. <div class="col-sm-3">
  264. <select id="storage_mode" title="虚拟机磁盘存储模式" class="selectpicker" name="storage_mode" data-width="100%" disabled>
  265. <option {% if config_ret.data.storage_mode == 0 %}selected{% endif %} value="0">本地存储</option>
  266. <option {% if config_ret.data.storage_mode == 1 %}selected{% endif %} value="1" data-subtext="NFS">挂载共享</option>
  267. <option {% if config_ret.data.storage_mode == 2 %}selected{% endif %} value="2">Ceph</option>
  268. <option {% if config_ret.data.storage_mode == 3 %}selected{% endif %} value="3">GlusterFS</option>
  269. </select>
  270. </div>
  271. <label id="dfs_volume_label" class="col-sm-2 control-label" style="display: {% if config_ret.data.storage_mode in [3] %}unset{% else %}none{% endif %};">分布式文件系统存储卷</label>
  272. <div class="col-sm-3">
  273. <input id="dfs_volume" title="分布式文件系统存储卷" class="form-control" name="dfs_volume" type="text" style="display: {% if config_ret.data.storage_mode in [3] %}unset{% else %}none{% endif %};" disabled value="{{ config_ret.data.dfs_volume }}">
  274. </div>
  275. </div>
  276. <div class="form-group">
  277. <label class="col-sm-2 control-label">虚拟机磁盘存放路径</label>
  278. <div class="col-sm-3">
  279. <input title="虚拟机磁盘存放路径" class="form-control" name="storage_path" type="text" disabled value="{{ config_ret.data.storage_path }}">
  280. </div>
  281. </div>
  282. </form>
  283. </div>
  284. <div id="quota" class="example-box-wrapper" style="display: none;">
  285. <form class="form-horizontal bordered-row" style="padding-left: 8%;">
  286. <div class="form-group" style="margin-bottom: 0;">
  287. <label class="col-sm-2 control-label">
  288. <span class="glyph-icon icon-exchange" style="transform: rotate(90deg); display: inline-flex;"></span>
  289. &nbsp;&nbsp;IOPS 基准值
  290. </label>
  291. <div class="col-sm-3">
  292. <input id="iops_base" title="IOPS 基准值" class="form-control" type="text" value="{{ config_ret.data.iops_base }}" name="iops_base">
  293. </div>
  294. <span class="col-sm-1"></span>
  295. <label class="col-sm-2 control-label"><span class="glyph-icon icon-openid"></span>&nbsp;&nbsp;BPS 基准值</label>
  296. <div class="col-sm-3">
  297. <input id="bps_base" title="BPS 基准值" class="form-control" type="text" value="{{ (config_ret.data.bps_base / 1024 / 1024) | int }}" name="bps_base">
  298. </div>
  299. <span class="col-sm-1"></span>
  300. </div>
  301. <div class="form-group" style="margin-bottom: 0;">
  302. <label class="col-sm-2 control-label">
  303. <span class="glyph-icon icon-exchange" style="transform: rotate(90deg); display: inline-flex;"></span>
  304. &nbsp;&nbsp;IOPS/GiB 增益
  305. </label>
  306. <div class="col-sm-3">
  307. <input id="iops_pre_unit" title="IOPS/GiB 增益" class="form-control" type="text" value="{{ config_ret.data.iops_pre_unit }}" name="iops_pre_unit">
  308. </div>
  309. <span class="col-sm-1"></span>
  310. <label class="col-sm-2 control-label"><span class="glyph-icon icon-openid"></span>&nbsp;&nbsp;BPS/GiB 增益</label>
  311. <div class="col-sm-3">
  312. <input id="bps_pre_unit" title="BPS/GiB 增益 (MiB)" class="form-control" type="text" value="{{ '%0.2f'|format(config_ret.data.bps_pre_unit / 1024 / 1024) }}" name="bps_pre_unit">
  313. </div>
  314. <span class="col-sm-1"></span>
  315. </div>
  316. <div class="form-group" style="margin-bottom: 0;">
  317. <label class="col-sm-2 control-label">
  318. <span class="glyph-icon icon-exchange" style="transform: rotate(90deg); display: inline-flex;"></span>
  319. &nbsp;&nbsp;IOPS 增益上限
  320. </label>
  321. <div class="col-sm-3">
  322. <input id="iops_cap" title="IOPS 增益上限" class="form-control" type="text" value="{{ config_ret.data.iops_cap }}" name="iops_cap">
  323. </div>
  324. <span class="col-sm-1"></span>
  325. <label class="col-sm-2 control-label"><span class="glyph-icon icon-openid"></span>&nbsp;&nbsp;BPS 增益上限</label>
  326. <div class="col-sm-3">
  327. <input id="bps_cap" title="BPS 增益上限 (MiB)" class="form-control" type="text" value="{{ (config_ret.data.bps_cap / 1024 / 1024) | int }}" name="bps_cap">
  328. </div>
  329. <span class="col-sm-1"></span>
  330. </div>
  331. <div class="form-group" style="margin-bottom: 0;">
  332. <label class="col-sm-2 control-label">
  333. <span class="glyph-icon icon-exchange" style="transform: rotate(90deg); display: inline-flex;"></span>
  334. <span class="glyph-icon icon-bitbucket" style="margin-left: -4px;"></span>
  335. &nbsp;&nbsp;IOPS 桶宽
  336. </label>
  337. <div class="col-sm-3">
  338. <input id="iops_max" title="IOPS 桶宽" class="form-control" type="text" value="{{ config_ret.data.iops_max }}" name="iops_max">
  339. </div>
  340. <span class="col-sm-1"></span>
  341. <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>
  342. <div class="col-sm-3">
  343. <input id="bps_max" title="BPS 桶宽 (MiB)" class="form-control" type="text" value="{{ (config_ret.data.bps_max / 1024 / 1024) | int }}" name="bps_max">
  344. </div>
  345. <span class="col-sm-1"></span>
  346. </div>
  347. <div class="form-group" style="margin-bottom: 0;">
  348. <label class="col-sm-2 control-label">
  349. <span class="glyph-icon icon-exchange" style="transform: rotate(90deg); display: inline-flex;"></span>
  350. <span class="glyph-icon icon-bitbucket" style="margin-left: -4px;"></span>
  351. &nbsp;&nbsp;IOPS 桶高
  352. </label>
  353. <div class="col-sm-3">
  354. <input id="iops_max_length" title="IOPS 桶高 (秒)" class="form-control" type="text" value="{{ config_ret.data.iops_max_length }}" name="iops_max_length">
  355. </div>
  356. <span class="col-sm-1"></span>
  357. <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>
  358. <div class="col-sm-3">
  359. <input id="bps_max_length" title="BPS 桶高 (秒)" class="form-control" type="text" value="{{ config_ret.data.bps_max_length }}" name="bps_max_length">
  360. </div>
  361. <span class="col-sm-1"></span>
  362. </div>
  363. <div class="form-group" style="margin-bottom: 0;">
  364. <div class="col-sm-6">
  365. <label>
  366. <input id="influence_current_guest" type="checkbox" name="influence_current_guest">
  367. 同时更新已存在的实例
  368. </label>
  369. </div>
  370. <div class="col-sm-6">
  371. <div style="padding: 0; text-align: right;">
  372. <button type="button" class="btn btn-sm btn-primary" style="right: 10%;" onclick="update_quota();">更新</button>
  373. </div>
  374. </div>
  375. </div>
  376. </form>
  377. </div>
  378. </div>
  379. </div>
  380. {% endblock content %}