Commit 1adcb9f9 authored by 徐一鸣's avatar 徐一鸣

一键部署数据处理

parent d38804f0
......@@ -184,10 +184,10 @@
style="margin-top: 30px;"
></deployment-info>
<div class="apass_button step_action">
<el-button type="primary">
<el-button type="primary" v-if="finallyState === 1">
前往查看
</el-button>
<el-button type="primary">
<el-button type="primary" v-if="finallyState === 2">
重新部署
</el-button>
</div>
......@@ -238,7 +238,7 @@ export default {
"v-apaas-code": codes,
},
data: () => ({
step: 0,
step: 2,
senior_flag: false,
begin_code: "",
dialogInfo: {
......@@ -314,95 +314,8 @@ export default {
},
evtUuid: "",
evtSource: null,
listStatus: [],
state: "",
text: "",
url: "",
act: 0,
stateList: [
{
name: "获取部署参数",
value: "values",
content: [
"======================================",
"host: mapvideo.wodcloud.com",
"repository: hub.wodcloud.com/apaas/apaas-mapvideos",
"tag: 1.0.0",
"",
"======================================",
],
state: 1,
},
{
name: "拉取部署文件",
value: "pull-chart",
content: [
"======================================",
"host: mapvideo.wodcloud.com",
"repository: hub.wodcloud.com/apaas/apaas-mapvideos",
"tag: 2.0.0",
"",
"======================================",
],
state: 1,
},
{
name: "开始部署",
value: "install",
content: [
"======================================",
"host: mapvideo.wodcloud.com",
"repository: hub.wodcloud.com/apaas/apaas-mapvideos",
"tag: 3.0.0",
"",
"======================================",
],
state: 1,
},
{
name: "部署状态",
value: "deploy-status",
content: [
"======================================",
"host: mapvideo.wodcloud.com",
"repository: hub.wodcloud.com/apaas/apaas-mapvideos",
"tag: 4.0.0",
"",
"======================================",
"host: mapvideo.wodcloud.com",
"repository: hub.wodcloud.com/apaas/apaas-mapvideos",
"tag: 4.0.0",
"",
"======================================",
"host: mapvideo.wodcloud.com",
"repository: hub.wodcloud.com/apaas/apaas-mapvideos",
"tag: 4.0.0",
"",
"======================================",
"host: mapvideo.wodcloud.com",
"repository: hub.wodcloud.com/apaas/apaas-mapvideos",
"tag: 4.0.0",
"",
"======================================",
"host: mapvideo.wodcloud.com",
"repository: hub.wodcloud.com/apaas/apaas-mapvideos",
"tag: 4.0.0",
"",
"======================================",
"host: mapvideo.wodcloud.com",
"repository: hub.wodcloud.com/apaas/apaas-mapvideos",
"tag: 4.0.0",
"",
"======================================",
"host: mapvideo.wodcloud.com",
"repository: hub.wodcloud.com/apaas/apaas-mapvideos",
"tag: 4.0.0",
"",
"======================================",
],
state: 2,
},
],
stateList: [],
finallyState: 0,
}),
methods: {
get_step_info() {
......@@ -454,72 +367,124 @@ export default {
this.evtUuid = evtUuid;
this.evtSource = evtSource;
evtSource.addEventListener("message", function(e) {
if (this.listStatus.map((o) => o.status).indexOf(e.lastEventId) == -1) {
if (this.listStatus.length) {
this.listStatus[this.listStatus.length - 1].success = "success";
}
let messages = [
{
id: "values",
type: "message",
data: {
state: "notes",
data: "======================================",
},
},
{
id: "values",
type: "message",
data: {
state: "notes",
data:
"host: mapvideo.wodcloud.com\nrepository: hub.wodcloud.com/apaas/apaas-mapvideos\ntag: 1.0.0\n",
},
},
{
id: "values",
type: "message",
data: {
state: "notes",
data: "======================================",
},
},
{
id: "pull-chart",
type: "message",
data: {
state: "notes",
data: "正在下载charts文件 apaas-mapvideos-1.0",
},
},
{
id: "pull-chart",
type: "message",
data: {
state: "notes",
data: "下载charts文件apaas-mapvideos-1.0成功",
},
},
{
id: "pull-chart",
type: "message",
data: { state: "notes", data: "正在解压 apaas-ui-1.0.0.tgz" },
},
{
id: "pull-chart",
type: "message",
data: { state: "notes", data: "解压 apaas-ui-1.0.0.tgz 完成" },
},
{
id: "install",
type: "message",
data: {
state: "notes",
data:
"NAME: ram001\nLAST DEPLOYED: Wed Jul 1 16:09:25 2020\nNAMESPACE: test\nSTATUS: DEPLOYED\n\nRESOURCES:\n==\u003e v1/Pod(related)\nNAME READY STATUS RESTARTS AGE\nram001-65c84bfd8d-xmt2k 0/1 ContainerCreating 0 \u003cinvalid\u003e\n\n==\u003e v1/Service\nNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE\nram001 ClusterIP 10.3.181.74 \u003cnone\u003e 80/TCP \u003cinvalid\u003e\n\n==\u003e v1beta1/Deployment\nNAME READY UP-TO-DATE AVAILABLE AGE\nram001 0/1 1 0 \u003cinvalid\u003e\n\n==\u003e v1beta1/Ingress\nNAME HOSTS ADDRESS PORTS AGE\nram001 mapvideo.wodcloud.com 80 \u003cinvalid\u003e\n\n\n",
},
},
{
id: "deploy-status",
type: "message",
data: {
state: "success",
data: "在命名空间 test 下部署 ram001 成功!",
},
},
];
this.listStatus.push({
status: e.lastEventId,
success: JSON.parse(e.data).state,
data: JSON.parse(e.data).data,
messages.forEach((msg, index) => {
setTimeout(() => {
this.updateStatus(msg);
}, (index + 1) * 200);
});
this.text = this.listStatus[this.listStatus.length - 1].data;
this.text = "<span class='linenum'></span>" + this.text;
this.text = this.text.replace(
/\n/g,
"\n<span class='linenum'></span>"
);
this.text = this.text.replace(/>==>/g, ">>");
this.act = this.listStatus.length - 1;
} else {
let i = this.listStatus.map((o) => o.status).indexOf(e.lastEventId);
let item = this.listStatus[i].data;
evtSource.addEventListener("message", (event) => {
console.log(event);
});
},
updateStatus(event) {
let names = {
values: "获取部署参数",
"pull-chart": "拉取部署文件",
install: "开始部署",
"deploy-status": "部署状态",
};
let currentState = this.stateList.find((state) => {
return state.value === event.id;
});
item = item + "\n" + JSON.parse(e.data).data;
if (!currentState) {
if (this.stateList.length > 0) {
this.stateList[this.stateList.length - 1].state = 1;
}
this.listStatus[i].data = item;
this.text = this.listStatus[this.listStatus.length - 1].data;
this.text = "<span class='linenum'></span>" + this.text;
this.text = this.text.replace(
/\n/g,
"\n<span class='linenum'></span>"
);
this.text = this.text.replace(/>==>/g, ">>");
this.act = this.listStatus.length - 1;
this.stateList.push({
name: names[event.id],
value: event.id,
content: [],
state: 0,
});
if (JSON.parse(e.data).state != "notes") {
this.listStatus[i].success = JSON.parse(e.data).state;
}
currentState = this.stateList[this.stateList.length - 1];
}
if (JSON.parse(e.data).state == "success") {
this.state = "部署成功!";
this.url = `https://${window.location.host}/apaas/ui/#/pods?namespace=${this.baseInfoForm.namespace}`;
}
currentState.content.push(...event.data.data.split("\n"));
for (let i = 0; i < this.listStatus.length; i++) {
switch (this.listStatus[i].status) {
case "values":
this.listStatus[i].statusHan = "获取部署参数";
break;
case "pull-chart":
this.listStatus[i].statusHan = "拉取部署文件";
break;
case "install":
this.listStatus[i].statusHan = "开始部署";
break;
case "deploy-status":
this.listStatus[i].statusHan = "部署状态";
break;
default:
this.listStatus[i].statusHan = "其他";
break;
if (event.id === "deploy-status") {
let finallyState = event.data.state === "success" ? 1 : 2;
this.finallyState = finallyState;
currentState.state = finallyState;
} else {
if (event.data.state !== "notes") {
currentState.state = 2;
}
}
});
},
},
created() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment