Pārlūkot izejas kodu

统计计算节点上所承载、运行的虚拟机实例数量,并通过超级链接能检索出相应虚拟机列表

James Iter 7 gadi atpakaļ
vecāks
revīzija
736853ccd4

+ 2 - 1
docs/todo.md

@@ -96,10 +96,11 @@
 - [x] 替换热迁移时计算节点的主机名为 IP 地址
 - [ ] 加入批量执行脚本功能
 - [ ] 创建虚拟机时,加入高级功能,选择 IP 池,选择分组
-- [ ] 统计计算节点上所承载、运行的虚拟机实例数量,并通过超级链接能检索出相应虚拟机列表
+- [x] 统计计算节点上所承载、运行的虚拟机实例数量,并通过超级链接能检索出相应虚拟机列表
 - [ ] IP 字段加入 link 功能,且允许用户定制。通过点击链接,直接打开目标页面
 - [x] 支持 vlan 功能
 - [ ] 加入虚拟机排序功能
 - [ ] 企业版分叉
 - [ ] 加入邮件、短信报警功能
+- [ ] 参照公有云,设计、实现资源搜索过滤功能
 

+ 3 - 0
jimvc/api/guest.py

@@ -1824,6 +1824,9 @@ def r_show():
         'paging': guests_ret['paging'],
         'page': page,
         'page_size': page_size,
+        'order_by': order_by,
+        'order': order,
+        'filter': _filter,
         'keyword': keyword,
         'pages': pages,
         'last_page': last_page

+ 20 - 4
jimvc/themes/default/templates/guests_show.html

@@ -1408,12 +1408,12 @@
                 '</td>' +
                 '<td><a data-autostart="' + guest.autostart + '" class="icon-os icon-autostart" title="' + (function () { if (guest.autostart !== 0) { return '切至手动启动'; } else { return '切至开机启动';}})() + '" href="javascript:;" onclick="autostart_at(this);" style="' + (function () { if (guest.autostart === 0) { return 'filter: grayscale(100%);'; } else { return '';}})() + '"></a></td>' +
                 '<td>' + guest.html.status + '</td>' +
-                '<td>' + guest.hostname + '</td>' +
+                '<td><a href="/guests?filter=node_id:eq:' + guest.node_id + '">' + guest.hostname + '</a></td>' +
                 '<td>' +
                     'CPU :&nbsp;&nbsp;' + guest.cpu + '&nbsp;核<br />' +
                     '内存 :&nbsp;&nbsp;' + guest.memory + '&nbsp;GB<br />' +
                     '带宽 :&nbsp;' + guest.html.bandwidth + '</td>' +
-                '<td>' + guest.ip + '</td>' +
+                '<td>' + guest.ip + '<br><a href="/guests?filter=vlan_id:eq:' + guest.vlan_id + '" title="' + guest.vlan.description + '">' + guest.vlan.label + '</a></td>' +
                 '<td width="150px;"><a href="javascript:;" class="glyph-icon icon-elusive-eye-off" onclick="change_display_password_for_row(this);" style="color: #014c8c;"></a><span class="unreal_password">******</span><span class="real_password" style="display: none;">' + guest.password + '</span></td>' +
                 '<td>' +
                     '<div class="dropdown inline-block">' +
@@ -1502,6 +1502,22 @@
                             '$(\'#adjust_ability_instance_desc\').text($($(this).parent().parent().parent().parent().parent().children()[2]).find(\'div a\')[0].textContent + \'/\' + $($(this).parent().parent().parent().parent().parent().children()[2]).find(\'div p\')[0].textContent)">' +
                             '变更配置' +
                         '</a>' +
+                    '</li>' +
+                    '<li class="">' +
+                        '<a href="javascript:;" data-toggle="modal" data-target="#revise_ip_modal"' +
+                            'onclick="$(\'#instance_uuid\').val($($(this).parent().parent().parent().parent().parent().children()[0]).text());\n' +
+                            '$(\'#revise_ip_instance_desc\').text($($(this).parent().parent().parent().parent().parent().children()[2]).find(\'div a\')[0].textContent + \'/\' + $($(this).parent().parent().parent().parent().parent().children()[2]).find(\'div p\')[0].textContent);\n' +
+                            '$(\'#revisional_ip\').val($($(this).parent().parent().parent().parent().parent().children()[8]).text().trim().replace(/ .*$/g, \'\'));">' +
+                            '修正 IP' +
+                        '</a>' +
+                    '</li>' +
+                    '<li class="">' +
+                        '<a href="javascript:;" data-toggle="modal" data-target="#change_vlan_modal"' +
+                            'onclick="$(\'#instance_uuid\').val($($(this).parent().parent().parent().parent().parent().children()[0]).text());\n' +
+                            '$(\'#change_vlan_instance_desc\').text($($(this).parent().parent().parent().parent().parent().children()[2]).find(\'div a\')[0].textContent + \'/\' + $($(this).parent().parent().parent().parent().parent().children()[2]).find(\'div p\')[0].textContent);">' +
+                            '变更 VLAN' +
+                        '</a>' +
+                    '</li>' +
                     '<li class="divider"></li>' +
                     '<li class="' + exchange_disabled_with_not(guest.status, [2]) + '">' +
                         '<a href="javascript:;" data-toggle="modal" data-target="#reset_password_modal"' +
@@ -1804,7 +1820,7 @@
                         <a data-autostart="{{ item.autostart }}" class="icon-os icon-autostart" title="{% if item.autostart != 0 %}切至手动启动{% else %}切至开机启动{% endif %}" href="javascript:;" onclick="autostart_at(this);" style="{% if item.autostart == 0 %}filter: grayscale(100%);{% endif %}"></a>
                     </td>
                     <td>{{ format_guest_status(item.status, item.progress)|safe }}</td>
-                    <td><a href="/guests?keyword={{ item.node_id | string }}">{{ hosts_mapping_by_node_id[item.node_id | string].hostname }}</a></td>
+                    <td><a href="/guests?filter=node_id:eq:{{ item.node_id | string }}">{{ hosts_mapping_by_node_id[item.node_id | string].hostname }}</a></td>
                     <td>
                         CPU :&nbsp;&nbsp;{{ item.cpu }}&nbsp;核<br />
                         内存 :&nbsp;&nbsp;{{ item.memory }}&nbsp;GB<br />
@@ -1835,7 +1851,7 @@
                     </td>
                     <td>
                         {{ item.ip }}<br>
-                        <a href="/config#vlan" title="{{ item.vlan.description }}">{{ item.vlan.label }}</a>
+                        <a href="/guests?filter=vlan_id:eq:{{ item.vlan_id }}" title="{{ item.vlan.description }}">{{ item.vlan.label }}</a>
                     </td>
                     <td><span class="unreal_password">*********</span><span class="real_password" style="display: none;">{{ item.password }}</span></td>
                     <td>{{ format_datetime_by_tus(item.create_time) }}</td>

+ 3 - 3
jimvc/themes/default/templates/hosts_show.html

@@ -147,15 +147,15 @@
                             <div class="bg-green host-specs">
                                 <div class="row">
                                     <div class="col-md-4">
-                                        <span style="font-size: x-large; color: #C9DD22;"><a class="hawkeye_count_left" href="/guests?keyword={{ item.node_id }}">{{ item.analysis.all_instance }}</a> </span><span style="font-size: x-large"><a class="hawkeye_count_right" href="/guests?keyword={{ item.node_id }}">{{ item.analysis.running_instance }}</a></span>
+                                        <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>
                                         <i>虚拟机实例</i>
                                     </div>
                                     <div class="col-md-4">
-                                        <span style="font-size: x-large; color: #C9DD22;"><a class="hawkeye_count_left" href="/guests?keyword={{ item.node_id }}">{{ item.analysis.all_vcpu }}</a> </span><span style="font-size: x-large"><a class="hawkeye_count_right" href="/guests?keyword={{ item.node_id }}">{{ item.analysis.using_vcpu }}</a></span>
+                                        <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>
                                         <i>vCPU</i>
                                     </div>
                                     <div class="col-md-4">
-                                        <span style="font-size: x-large; color: #C9DD22;"><a class="hawkeye_count_left" href="/guests?keyword={{ item.node_id }}">{{ item.analysis.all_memory }}</a> </span><span style="font-size: x-large"><a class="hawkeye_count_right" href="/guests?keyword={{ item.node_id }}">{{ item.analysis.using_memory }}</a></span>
+                                        <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>
                                         <i>内存</i>
                                     </div>
                                 </div>