Commit fb88704a authored by 张俊's avatar 张俊

一键部署storage格式修改

parent 6065e9a7
...@@ -162,7 +162,7 @@ ...@@ -162,7 +162,7 @@
<div class="cloud_save_box"> <div class="cloud_save_box">
<el-checkbox-group v-model="item.value"> <el-checkbox-group v-model="item.value">
<p v-for="(it,idx) in pvc_list" :key="idx"> <p v-for="(it,idx) in pvc_list" :key="idx">
<el-checkbox :label="it.disk_serial_number+';'+it.id">{{it.disk_serial_number}}&nbsp;({{it.disk_cap+'Gi'}})</el-checkbox> <el-checkbox :label="it.disk_serial_number+';'+it.id+';'+it.disk_cap">{{it.disk_serial_number}}&nbsp;({{it.disk_cap+'Gi'}})</el-checkbox>
</p> </p>
</el-checkbox-group> </el-checkbox-group>
</div> </div>
...@@ -377,12 +377,11 @@ export default { ...@@ -377,12 +377,11 @@ export default {
if (e.type == "radio") { if (e.type == "radio") {
e["val"] = e.value[0]; e["val"] = e.value[0];
} else if (e.type == "storage") { } else if (e.type == "storage") {
debugger
this.select_volumn=[] this.select_volumn=[]
e['check_type'] = 0 e['check_type'] = 0
e['storage_type'] = 0 e['storage_type'] = 0
console.log(this.pvc_list); console.log(this.pvc_list);
e['value'] = [this.pvc_list[0].disk_serial_number+';'+this.pvc_list[0].id] e['value'] = [this.pvc_list[0].disk_serial_number+';'+this.pvc_list[0].id+';'+this.pvc_list[0].disk_cap]
} else if (e.type == "resource") { } else if (e.type == "resource") {
let memory = e.memory; let memory = e.memory;
let cpu = e.cpu; let cpu = e.cpu;
...@@ -413,9 +412,33 @@ export default { ...@@ -413,9 +412,33 @@ export default {
console.log(key, val); console.log(key, val);
this.$set(obj, key, val); this.$set(obj, key, val);
}, },
is_size_toge(arr){
if(arr.length){
var temp = arr[0].split(';')[2]
return arr.some(function (value, index, _arr) {
return temp !== value.split(';')[2]
});
}else{
this.$message.error('请选择规格')
return 'kong'
}
},
is_size_id_arr(arr){
if(arr.length){
var temp_arr = []
arr.forEach(e => {
temp_arr.push(e.split(';')[1])
});
return temp_arr
}else{
this.$message.error('请选择规格')
return []
}
},
deal_key_value(key_string, type, value) { deal_key_value(key_string, type, value) {
var key_arr = key_string.split("."); var key_arr = key_string.split(".");
var temp = this.app_set_info; var temp = this.app_set_info;
try {
key_arr.forEach((e, index) => { key_arr.forEach((e, index) => {
if (key_arr.length - 1 == index) { if (key_arr.length - 1 == index) {
if (type == "resource") { if (type == "resource") {
...@@ -430,20 +453,35 @@ export default { ...@@ -430,20 +453,35 @@ export default {
}, },
}; };
} else if (type == "storage") { } else if (type == "storage") {
//临时存储
if(value[1]==0){
temp[e] = {
emptyDir:true
}
}else{//云存储
if(this.is_size_toge(value[0])==true){
this.$message.error('请选择同规格的数据盘')
throw 1
}else if(this.is_size_toge(value[0])=='kong'){
throw 1
}
temp[e] = { temp[e] = {
volumeClaimTemplate: { volumeClaimTemplate: {
spec: { spec: {
storageClassName: "nfs-client", storageClassName: value[2]==0?'nfs-client':'rook-ceph-block',
accessModes: ["ReadWriteOnce"], accessModes: ["ReadWriteOnce"],
resources: { resources: {
requests: { requests: {
storage: value, storage: value[0][0].split(';')[2]+'Gi',
}, },
}, },
}, },
selector: {}, selector: {},
}, },
}; };
this.select_volumn.push(...this.is_size_id_arr(value[0]))
}
} else if(type == "volume") { } else if(type == "volume") {
//临时存储 //临时存储
if(value[1]==0){ if(value[1]==0){
...@@ -467,6 +505,10 @@ export default { ...@@ -467,6 +505,10 @@ export default {
temp = temp[e]; temp = temp[e];
} }
}); });
} catch (error) {
return
}
}, },
deal_key_text(obj, key_string) { deal_key_text(obj, key_string) {
var key_arr = key_string.split("."); var key_arr = key_string.split(".");
...@@ -528,6 +570,8 @@ export default { ...@@ -528,6 +570,8 @@ export default {
if (response.data.success === 1) { if (response.data.success === 1) {
// this.$message.success("开始部署成功"); // this.$message.success("开始部署成功");
this.deploy_id = response.data.data.deploy_id; this.deploy_id = response.data.data.deploy_id;
}else{
this.$message.error(response.data.errMsg)
} }
}) })
.catch(() => { .catch(() => {
...@@ -576,7 +620,7 @@ export default { ...@@ -576,7 +620,7 @@ export default {
if (e.type == "radio") { if (e.type == "radio") {
this.deal_key_value(e.name, e.type, e.val); this.deal_key_value(e.name, e.type, e.val);
} else if (e.type == "storage") { } else if (e.type == "storage") {
this.deal_key_value(e.name, e.type, e.storage); this.deal_key_value(e.name, e.type, [e.value,e.check_type,e.storage_type]);
} else if (e.type == "resource") { } else if (e.type == "resource") {
let memory = e.memory; let memory = e.memory;
let cpu = e.cpu; let cpu = e.cpu;
......
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