feat: add host related information

(cherry picked from commit bb9a51fbc16fe100a769cbdc121d9ffd030096eb)
This commit is contained in:
Hu gang 2023-12-22 10:45:31 +08:00 committed by openeuler-sync-bot
parent 4b72ca6a25
commit 3ecdf5ebd9
3 changed files with 416 additions and 2 deletions

View File

@ -0,0 +1,261 @@
From 47aaab21d6606f27d6117eb53034f6c2c5f3edf3 Mon Sep 17 00:00:00 2001
From: Hu gang <18768366022@163.com>
Date: Wed, 20 Dec 2023 19:26:33 +0800
Subject: [PATCH] fix: host status adaptation
---
src/api/leaks.js | 3 +-
src/vendor/ant-design-pro/utils/request.js | 6 ++++
src/views/assests/HostDetail.vue | 34 +++++++------------
.../assests/components/HostBasicInfo.vue | 4 +--
.../assests/components/HostChartInfo.vue | 33 +++++++-----------
src/views/leaks/CVEsDetail.vue | 21 +++++-------
src/views/leaks/LeakTaskDetail.vue | 3 +-
src/views/leaks/components/HostTable.vue | 12 +++----
8 files changed, 49 insertions(+), 67 deletions(-)
diff --git a/src/api/leaks.js b/src/api/leaks.js
index c6f704b..da3fbf8 100644
--- a/src/api/leaks.js
+++ b/src/api/leaks.js
@@ -347,6 +347,7 @@ export function setCveStatus({cveList, status}) {
}
export function getHostUnderCVE({tableInfo, ...parameter}) {
+ const repoList = tableInfo.filters.repo ? tableInfo.filters.repo.map((v) => (v === '' ? null : v)) : null;
return request({
url: api.getHostUnderCVE,
method: 'post',
@@ -358,7 +359,7 @@ export function getHostUnderCVE({tableInfo, ...parameter}) {
fixed: tableInfo.fixed,
host_name: tableInfo.filters.host_name === null ? undefined : tableInfo.filters.host_name,
host_group: tableInfo.filters.host_group === null ? undefined : tableInfo.filters.host_group,
- repo: tableInfo.filters.repo === null ? undefined : tableInfo.filters.repo,
+ repo: repoList === null ? undefined : repoList,
last_scan: tableInfo.filters.last_scan
},
page: tableInfo.pagination.current,
diff --git a/src/vendor/ant-design-pro/utils/request.js b/src/vendor/ant-design-pro/utils/request.js
index 11be85a..36615ad 100644
--- a/src/vendor/ant-design-pro/utils/request.js
+++ b/src/vendor/ant-design-pro/utils/request.js
@@ -165,6 +165,12 @@ request.interceptors.response.use((response) => {
});
});
return retryRequest;
+ case '1108':
+ notification.error({
+ message: '暂无指标数据!',
+ description: response.data.message
+ });
+ break;
default:
notification.error({
message: response.data.label,
diff --git a/src/views/assests/HostDetail.vue b/src/views/assests/HostDetail.vue
index 6eadb05..ea08cfa 100644
--- a/src/views/assests/HostDetail.vue
+++ b/src/views/assests/HostDetail.vue
@@ -49,30 +49,20 @@ export default {
};
},
methods: {
- fetchHostInfo() {
+ async fetchHostInfo() {
this.basicHostInfoIsLoading = true;
- getHostDetail(Number(this.hostId), true)
- .then((res) => {
- this.basicHostInfo = res.data.host_infos[0];
- this.scene = this.basicHostInfo.scene;
- })
- .catch((err) => {
- this.$message.error(err.response.message);
- })
- .finally(() => {
- this.basicHostInfoIsLoading = false;
- });
this.basicInfoIsLoading = true;
- getHostDetail(Number(this.hostId), false)
- .then((res) => {
- this.basicInfo = res.data.host_infos[0];
- })
- .catch((err) => {
- this.$message.error(err.response.message);
- })
- .finally(() => {
- this.basicInfoIsLoading = false;
- });
+ const basicHostRes = await getHostDetail(Number(this.hostId), true);
+ if (basicHostRes) {
+ this.basicHostInfo = basicHostRes.data.host_infos[0];
+ this.scene = this.basicHostInfo.scene;
+ }
+ const basicRes = await getHostDetail(Number(this.hostId), false);
+ if (basicRes) {
+ this.basicInfo = basicRes.data.host_infos[0];
+ }
+ this.basicInfoIsLoading = false;
+ this.basicHostInfoIsLoading = false;
},
reFetchHostInfo() {
this.fetchHostInfo();
diff --git a/src/views/assests/components/HostBasicInfo.vue b/src/views/assests/components/HostBasicInfo.vue
index bab1074..9909e44 100644
--- a/src/views/assests/components/HostBasicInfo.vue
+++ b/src/views/assests/components/HostBasicInfo.vue
@@ -235,6 +235,7 @@ export default {
getDetail() {
let data = this.basicInfo;
data = data.host_info;
+ this.basicInfo.status !== null && (this.status = this.basicInfo.status);
for (const member in data.os) {
this.os[member] = data.os[member] || '暂无';
}
@@ -257,8 +258,7 @@ export default {
this.detailIcon = 'up';
}
}
- },
- mounted() {}
+ }
};
</script>
<style lang="less" scoped>
diff --git a/src/views/assests/components/HostChartInfo.vue b/src/views/assests/components/HostChartInfo.vue
index 2763d3c..d9e8fe7 100644
--- a/src/views/assests/components/HostChartInfo.vue
+++ b/src/views/assests/components/HostChartInfo.vue
@@ -120,29 +120,20 @@ export default {
methods: {
// 获取指标项,一个指标项对应一个图表
getHostMetrics() {
- const _this = this;
- _this.chartLoading = true;
+ this.chartLoading = true;
getHostMetrics({
- query_ip: _this.queryIp
- })
- .then((res) => {
- _this.metrics = res.data.results;
- if (_this.selectedMetrics.length < 1) {
- _this.selectedMetrics = res.data.results.slice(0, 4);
- storage.set('hostChartsSelectedMetrics', _this.selectedMetrics, 30 * 24 * 60 * 60 * 1000);
+ query_ip: this.queryIp
+ }).then((res) => {
+ if (res) {
+ this.metrics = res.data.results;
+ if (this.selectedMetrics.length < 1) {
+ this.selectedMetrics = res.data.results.slice(0, 4);
+ storage.set('hostChartsSelectedMetrics', this.selectedMetrics, 30 * 24 * 60 * 60 * 1000);
}
- _this.getMetricData();
- })
- .catch((err) => {
- if (err.response.code === '1108') {
- _this.$message.info('暂无指标数据!');
- } else {
- _this.$message.error(err.response.message);
- }
- })
- .finally(() => {
- _this.chartLoading = false;
- });
+ this.getMetricData();
+ }
+ this.chartLoading = false;
+ });
},
// 获取各个指标项下的所有序列数据
getMetricData() {
diff --git a/src/views/leaks/CVEsDetail.vue b/src/views/leaks/CVEsDetail.vue
index 3736592..4887c50 100644
--- a/src/views/leaks/CVEsDetail.vue
+++ b/src/views/leaks/CVEsDetail.vue
@@ -175,26 +175,21 @@ export default {
this.getHostList(this.cve_id, data);
},
getHostList(cveId, data) {
- const _this = this;
this.hostIsLoading = true;
getHostUnderCVE({
...data,
cve_id: cveId
- })
- .then(function (res) {
- _this.hostList = res.data.result || [];
- _this.hostList.forEach((item) => {
+ }).then((res) => {
+ if (res) {
+ this.hostList = res.data.result || [];
+ this.hostList.forEach((item) => {
item.hp_status = item.hp_status ? item.hp_status : '——';
item.fixStatus = item.hotpatch ? `是(${item.hp_status})` : '否';
});
- _this.paginationTotal = res.data.total_count || (res.data.total_count === 0 ? 0 : undefined);
- })
- .catch(function (err) {
- _this.$message.error(err.response.message);
- })
- .finally(function () {
- _this.hostIsLoading = false;
- });
+ this.paginationTotal = res.data.total_count || (res.data.total_count === 0 ? 0 : undefined);
+ }
+ });
+ this.hostIsLoading = false;
},
setStatus(status) {
const _this = this;
diff --git a/src/views/leaks/LeakTaskDetail.vue b/src/views/leaks/LeakTaskDetail.vue
index 56056c9..134a0cb 100644
--- a/src/views/leaks/LeakTaskDetail.vue
+++ b/src/views/leaks/LeakTaskDetail.vue
@@ -105,7 +105,7 @@
<a-input-search
:placeholder="taskType === 'hotpatch remove' ? `按CVE ID搜索` : `按主机名或IP搜索`"
style="width: 200px"
- maxLength="20"
+ :maxLength="20"
@search="onSearch"
/>
</a-col>
@@ -646,6 +646,7 @@ export default {
this.tableIsLoading = false;
},
handleTableChange(pagination, filters, sorter) {
+ this.expandedRowKeys = [];
// 存储翻页状态
for (var key in filters) {
if (filters[key] !== null) {
diff --git a/src/views/leaks/components/HostTable.vue b/src/views/leaks/components/HostTable.vue
index b83feb8..1546260 100644
--- a/src/views/leaks/components/HostTable.vue
+++ b/src/views/leaks/components/HostTable.vue
@@ -960,8 +960,8 @@ export default {
},
getRepoList() {
const _this = this;
- getRepoList()
- .then(function (res) {
+ getRepoList().then((res) => {
+ if (res) {
const arr = (res.data.result || []).map((repo) => {
return {
text: repo.repo_name,
@@ -972,11 +972,9 @@ export default {
text: '未设置',
value: ''
});
- _this.repoFilterList = arr;
- })
- .catch(function (err) {
- _this.$message.error(err.response.message);
- });
+ this.repoFilterList = arr;
+ }
+ });
},
// 检查是否有筛选条件
checkHasFilter(filters) {
--
Gitee

View File

@ -0,0 +1,146 @@
From aaeef74c72b47edd85c79fceddd99e0b6f333f64 Mon Sep 17 00:00:00 2001
From: Hu gang <18768366022@163.com>
Date: Fri, 22 Dec 2023 09:44:17 +0800
Subject: [PATCH] feat: host info add reboot
---
src/vendor/ant-design-pro/utils/request.js | 14 +++++-------
src/views/assests/components/addMoreHost.vue | 3 ++-
src/views/leaks/HostLeakDetail.vue | 3 +++
.../components/CreateRepairTaskDrawer.vue | 22 +++++++++++++++++++
vue.config.js | 4 ++--
5 files changed, 35 insertions(+), 11 deletions(-)
diff --git a/src/vendor/ant-design-pro/utils/request.js b/src/vendor/ant-design-pro/utils/request.js
index 36615ad..d1c8d43 100644
--- a/src/vendor/ant-design-pro/utils/request.js
+++ b/src/vendor/ant-design-pro/utils/request.js
@@ -101,7 +101,7 @@ request.interceptors.response.use((response) => {
const code = response.data.code || response.status;
// 不处理所有2xx的状态码
if (!code.toString().match(/^2[0-9]{2,2}$/)) {
- // let err = null;
+ let err = null;
switch (code) {
case '1201':
if (!timestamp1 || timestamp1 + 1632252465 < new Date().getTime()) {
@@ -171,18 +171,16 @@ request.interceptors.response.use((response) => {
description: response.data.message
});
break;
+ case '1000':
+ err = new Error(response.data.message);
+ err.data = response.data.data;
+ err.response = response.data;
+ throw err;
default:
notification.error({
message: response.data.label,
description: response.data.message
});
- return new Promise((resolve) => {
- resolve(null);
- });
- // err = new Error(response.data.message);
- // err.data = response.data.data;
- // err.response = response.data;
- // throw err;
}
}
if (response.headers['content-type'] === 'application/octet-stream') {
diff --git a/src/views/assests/components/addMoreHost.vue b/src/views/assests/components/addMoreHost.vue
index 0b05ffd..1a6c62f 100644
--- a/src/views/assests/components/addMoreHost.vue
+++ b/src/views/assests/components/addMoreHost.vue
@@ -316,6 +316,8 @@ export default {
},
showModal() {
this.visible = true;
+ this.tableVis = false;
+ this.fileDataList = [];
},
closeModal() {
this.visible = false;
@@ -468,7 +470,6 @@ export default {
}
});
// 当部分成功移除成功的主机
-
this.$message.success('部分主机添加成功!');
this.$emit('addSuccess');
}
diff --git a/src/views/leaks/HostLeakDetail.vue b/src/views/leaks/HostLeakDetail.vue
index ef1295d..27ed786 100644
--- a/src/views/leaks/HostLeakDetail.vue
+++ b/src/views/leaks/HostLeakDetail.vue
@@ -36,6 +36,9 @@
<a-col span="8">
<p>{{ `不受影响的CVE数量 ${detail.unaffected_cve_num}` }}</p>
</a-col>
+ <a-col span="8">
+ <p>{{ `重启后内核变更: ${detail.reboot ? '是' : '否'}` }}</p>
+ </a-col>
</a-row>
</div>
</a-spin>
diff --git a/src/views/leaks/components/CreateRepairTaskDrawer.vue b/src/views/leaks/components/CreateRepairTaskDrawer.vue
index b302439..30efbe5 100644
--- a/src/views/leaks/components/CreateRepairTaskDrawer.vue
+++ b/src/views/leaks/components/CreateRepairTaskDrawer.vue
@@ -55,6 +55,17 @@
<a-icon slot="unCheckedChildren" type="close" />
</a-switch>
</a-form-item>
+ <div class="notice" v-if="taskType === 'cve fix'">
+ <a-popover placement="topLeft">
+ <template slot="content">
+ <p>1. 冷、热补丁将拆分成2个任务分别执行</p>
+ <p>2. 同一主机,热补丁任务需在冷补丁修复任务前执行</p>
+ <p>3. 冷补丁任务执行完毕后,需重启才能生效</p>
+ </template>
+ <span slot="title">注意事项:</span>
+ <span class="notice-container">注意事项 <a-icon type="question-circle" /></span>
+ </a-popover>
+ </div>
<a-form-item label="选择REPO" v-if="taskType === 'repo set'">
<a-select
v-decorator="['repo', {rules: [{required: true, message: '请选择REPO'}]}]"
@@ -196,6 +207,7 @@
>点击跳转到{{ item.fix_way }}{{ taskType === 'cve fix' ? '修复' : '移除' }}任务页面</a
>
</p>
+ <p v-if="jumpTaskId.length > 1">只执行热补丁任务,冷补丁任务需手动执行</p>
<p>{{ countDown }}秒后回到原页面</p>
</a-col>
</a-row>
@@ -1076,3 +1088,13 @@ export default {
}
};
</script>
+
+<style scoped lang="less">
+.notice {
+ padding: 0 0 10px 40px;
+ cursor: pointer;
+ &-container {
+ font-size: 14px;
+ }
+}
+</style>
diff --git a/vue.config.js b/vue.config.js
index 402e69c..61c5a37 100644
--- a/vue.config.js
+++ b/vue.config.js
@@ -26,8 +26,8 @@ function getGitHash() {
const serverMap = {
// serverIpBase: 'http://127.0.0.1'
- // serverIpBase: 'http://172.168.61.81'
- serverIpBase: 'http://172.168.235.132'
+ // serverIpBase: 'http://172.168.235.132'
+ serverIpBase: 'http://172.168.97.229'
};
// vue.config.js
--
Gitee

View File

@ -2,7 +2,7 @@
Name: aops-hermes Name: aops-hermes
Version: v1.4.0 Version: v1.4.0
Release: 3 Release: 4
Summary: Web for an intelligent diagnose frame Summary: Web for an intelligent diagnose frame
License: MulanPSL2 License: MulanPSL2
URL: https://gitee.com/openeuler/%{name} URL: https://gitee.com/openeuler/%{name}
@ -13,7 +13,8 @@ Patch002: 002-fix-hotpatch-remove-filter.patch
Patch003: 003-change-search-placeholder.patch Patch003: 003-change-search-placeholder.patch
Patch004: 004-modify-search-key-for-hostlist.patch Patch004: 004-modify-search-key-for-hostlist.patch
Patch005: 005-add-input-text-limit.patch Patch005: 005-add-input-text-limit.patch
Patch006: 006-host-status-adaption.patch
Patch007: 007-host-info-and-generate-task.patch
BuildRequires: nodejs node-gyp nodejs-yarn BuildRequires: nodejs node-gyp nodejs-yarn
Requires: nginx Requires: nginx
@ -48,6 +49,12 @@ cp -r deploy/aops-hermes.service %{buildroot}/usr/lib/systemd/system/
%changelog %changelog
* Fri Dec 22 2023 Hu gang<18768366022@163.com> - v1.4.0-4
- Added an interface adaptation for host status
- Added a field to determine whether the kernel changes after the host is restarted
- Added a new hot patch prompt for creating a repair task
- Fix some bug
* Tue Dec 19 2023 Hu gang<18768366022@163.com> - v1.4.0-3 * Tue Dec 19 2023 Hu gang<18768366022@163.com> - v1.4.0-3
- Add imput text limit - Add imput text limit