hosts_show.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. {% extends theme("layout.html") %}
  2. {% block head %}
  3. {{ super() }}
  4. <style type="text/css">
  5. .hawkeye_count_left {
  6. color: #C9DD22;
  7. }
  8. .hawkeye_count_right {
  9. color: #FFFFFF;
  10. }
  11. .hawkeye_count_left:hover, .hawkeye_count_right:hover{
  12. text-decoration: none;
  13. }
  14. </style>
  15. {% endblock head %}
  16. {% block content %}
  17. <script type="text/javascript">
  18. var page = 1;
  19. var page_size = 10;
  20. var keyword = '';
  21. var resource_path = window.location.pathname;
  22. var cur_url = resource_path;
  23. $(document).ready(function() {
  24. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
  25. var last_ready = null;
  26. $('#content_search').keydown(function() {
  27. if (last_ready !== null) {
  28. clearTimeout(last_ready);
  29. }
  30. last_ready = setTimeout(function () {
  31. keyword = $('#content_search').val();
  32. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
  33. if (keyword.length > 0) {
  34. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size + '&keyword=' + keyword;
  35. }
  36. window.location.href=cur_url;
  37. }, 1000);
  38. });
  39. $('body').addClass('add-transition');
  40. $('.add-page-transition').on('click', function(){
  41. var transAttr = $(this).attr('data-transition');
  42. $('.add-transition').attr('class', 'add-transition');
  43. $('.add-transition').addClass(transAttr);
  44. });
  45. });
  46. function refresh() {
  47. window.location.href=resource_path;
  48. }
  49. function remove(uuids) {
  50. $.ajax({
  51. url : '/api/hosts/' + uuids.join(','),
  52. type : 'DELETE',
  53. contentType: "application/json; charset=utf-8",
  54. error : function() {
  55. alter_danger('计算节点删除指令发送失败!');
  56. },
  57. success : function() {
  58. alter_success('计算节点删除指令发送成功!');
  59. }
  60. });
  61. }
  62. function delete_at(me) {
  63. var node_id = $('#instance_node_id').val();
  64. remove([node_id]);
  65. refresh()
  66. }
  67. function panel_onmouseover(me) {
  68. $(me).find(".show_detail_link").css('display','block');
  69. }
  70. function panel_onmouseout(me) {
  71. $(me).find(".show_detail_link").css('display','none');
  72. }
  73. function nonrandom_click_handler(hostname, nonrandom) {
  74. $.ajax({
  75. url : '/api/hosts/' + hostname + '/' + (! nonrandom),
  76. type : 'PUT',
  77. error : function() {
  78. alter_danger('计算节点随机分配模式指令发送失败!');
  79. },
  80. success : function() {
  81. alter_success('计算节点随机分配模式指令发送成功!');
  82. setTimeout(function() {
  83. refresh();
  84. }, 1000);
  85. }
  86. });
  87. }
  88. </script>
  89. <div class="panel">
  90. <div class="panel-body">
  91. <h3 class="title-hero" style="font-size: 24px;">
  92. 计算节点
  93. </h3>
  94. <div>
  95. <div id="datatable-row-highlight_wrapper" class="dataTables_wrapper form-inline">
  96. <div class="row" style="padding: 10px 10px 10px 0; width: 100%;">
  97. <div class="col-sm-12" style="padding-right: 0;">
  98. <div id="datatable-row-highlight_filter" class="dataTables_filter" style="display: inline-block;">
  99. <input id="content_search" type="search" class="form-control" placeholder="模糊搜索..." value="{%- if keyword -%} {{ keyword }} {%- endif -%}" style="margin-left: 0; border-radius: 0;">
  100. </div>
  101. <div class="pull-right">
  102. </div>
  103. </div>
  104. </div>
  105. </div>
  106. <div class="row">
  107. {% for item in hosts %}
  108. <div class="col-md-4" onmouseover="panel_onmouseover(this);" onmouseout="panel_onmouseout(this);">
  109. <div class="host-box content-box {% if not item.alive %}panel-gray{% endif %}">
  110. <h2 class="bg-black host-title">{{ item.hostname }}
  111. <i style="float: right;" class="glyph-icon icon-circle font-size-23 {% if item.alive == true %}font-green{% else %}font-red{% endif %}"></i>
  112. <a href="javascript:;" onclick="nonrandom_click_handler('{{ item.hostname }}', {{ item.nonrandom | lower }});" title="{% if item.nonrandom == true %}加入{% else %}取消{% endif %}自动分配" style="float: left; margin-top: 8%;" class="glyph-icon icon-elusive-shuffle font-size-12 {% if item.nonrandom == true %}font-gray{% else %}font-green{% endif %}"></a>
  113. </h2>
  114. <div class="bg-blue host-specs">
  115. <div class="show_detail_link" style="display: none; position: absolute; z-index: 9999; margin-top: 20px; right: 2%;">
  116. <a href="/host/detail/{{ item.node_id }}" style="color: white; background-color: black;">&nbsp;&nbsp;&nbsp;&nbsp;主机详情&nbsp;&nbsp;&nbsp;&nbsp;</a>
  117. </div>
  118. <div style="{% if item.alive == true %}display: none;{% endif %}position: absolute; z-index: 9999; margin-top: 0; top: 56px; right: 0; left: 0;">
  119. <span style="color: white; background-color: black; font-size: 13px; display: block; color: #2d2d2d; background-color: #cbcbcb;">&nbsp;&nbsp;&nbsp;&nbsp;最后在线时间: {{ format_datetime_by_tus(item.timestamp * 1000 * 1000) }}&nbsp;&nbsp;&nbsp;&nbsp;
  120. <span style="display: none;">{{ item.node_id }}</span>
  121. <a href="javascript:;" style="color: black;" data-toggle="modal" data-target="#delete_modal"
  122. onclick="$('#instance_node_id').val($(this).prev().text());
  123. $('#delete_instance_desc').text($(this).parent().parent().parent().prev()[0].innerText)">
  124. 删除该计算节点
  125. </a>
  126. </span>
  127. </div>
  128. <span>{{ '%0.2f'| format(item.system_load[0] / item.cpu) }}</span>
  129. <i>当前系统负载</i>
  130. </div>
  131. <div class="bg-orange host-specs">
  132. <span>{{(((item.memory - item.memory_available) / item.memory) * 100) | int}}%</span>
  133. <i>内存使用率</i>
  134. </div>
  135. <div class="bg-green host-specs">
  136. <div class="row">
  137. <div class="col-md-4">
  138. <span style="font-size: x-large; color: #C9DD22;"><a class="hawkeye_count_left" href="/guests?filter=node_id:eq:{{ item.node_id }}">{{ item.analysis.all_instance }}</a> </span><span style="font-size: x-large"><a class="hawkeye_count_right" href="/guests?filter=status:eq:2;node_id:eq:{{ item.node_id }}">{{ item.analysis.running_instance }}</a></span>
  139. <i>虚拟机实例</i>
  140. </div>
  141. <div class="col-md-4">
  142. <span style="font-size: x-large; color: #C9DD22;"><a class="hawkeye_count_left" href="/guests?filter=node_id:eq:{{ item.node_id }}&order_by=cpu&order=desc">{{ item.analysis.all_vcpu }}</a> </span><span style="font-size: x-large"><a class="hawkeye_count_right" href="/guests?filter=status:eq:2;node_id:eq:{{ item.node_id }}&order_by=cpu&order=desc">{{ item.analysis.using_vcpu }}</a></span>
  143. <i>vCPU</i>
  144. </div>
  145. <div class="col-md-4">
  146. <span style="font-size: x-large; color: #C9DD22;"><a class="hawkeye_count_left" href="/guests?filter=node_id:eq:{{ item.node_id }}&order_by=memory&order=desc">{{ item.analysis.all_memory }}</a> </span><span style="font-size: x-large"><a class="hawkeye_count_right" href="/guests?filter=status:eq:2;node_id:eq:{{ item.node_id }}&order_by=memory&order=desc">{{ item.analysis.using_memory }}</a></span>
  147. <i>内存</i>
  148. </div>
  149. </div>
  150. </div>
  151. <ul {% if not item.alive %}class="bg-gray"{% endif %}>
  152. <li>CPU: {{ item.cpu }} 核</li>
  153. <li>内存: {{ (item.memory / 1024 / 1024 / 1024)|int }} GB</li>
  154. <!--<li><i class="glyph-icon icon-circle font-size-23 {% if item.alive == true %}font-green{% else %}font-red{% endif %}"></i></li>-->
  155. {% for nic_name, nic in item.interfaces.iteritems() %}
  156. <li>网卡: {{ nic_name }} | IP: {{ nic.ip }}</li>
  157. {% endfor %}
  158. {% for mountpoint, disk in item.disks.iteritems() %}
  159. <li>挂载点: {{ mountpoint }} | {{ (disk.total / 1024 / 1024 / 1024) | int }} GB | 使用率: {{ disk.percent }}%</li>
  160. {% endfor %}
  161. <li>版本: {{ item.version }}</li>
  162. </ul>
  163. </div>
  164. </div>
  165. {% endfor %}
  166. </div>
  167. </div>
  168. </div>
  169. </div>
  170. <input id="instance_node_id" title="实例 node id" class="form-control" name="node_id" hidden>
  171. <div class="modal" id="delete_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  172. <div class="modal-dialog">
  173. <div class="modal-content">
  174. <div class="modal-header">
  175. <h4 class="modal-title">删除离线的计算节点:</h4>
  176. </div>
  177. <div class="modal-body">
  178. <p>删除的计算节点,上面的统计数据将永久消失。您确定要删除该计算节点吗?</p>
  179. <h3 style="color: orangered;" id="delete_instance_desc"></h3>
  180. </div>
  181. <div class="modal-footer">
  182. <button type="button" class="btn btn-sm btn-primary" onclick="delete_at();">确定</button>
  183. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  184. </div>
  185. </div>
  186. </div>
  187. </div>
  188. {% endblock content %}