卷创建按键

This commit is contained in:
liujianfei 2021-08-10 15:55:31 +08:00
parent 3fbfc59c3f
commit c59e4e2348
2 changed files with 48 additions and 3 deletions

View File

@ -72,6 +72,14 @@ export function putDataVolumeYaml(name, yaml) {
})
}
export function createDataVolume(data) {
return request({
url: '/virtual/v1/cdi.kubevirt.io.datavolumes',
method: 'post',
data: data
})
}
export function getVirtualMachineYaml(name) {
return request({
url: '/virtual/apis/kubevirt.io/v1/namespaces/default/virtualmachines/' + name,

View File

@ -71,7 +71,7 @@
<el-row type="flex" justify="end">
<el-col :span="2.5">
<el-button type="info" @click="goBack">取消</el-button>
<el-button type="primary">创建</el-button>
<el-button type="primary" @click="create">创建</el-button>
</el-col>
</el-row>
@ -79,7 +79,7 @@
</template>
<script>
import { createDataVolume } from '@/api/one-class-page/virtualMachine'
export default {
data() {
return {
@ -100,9 +100,34 @@ export default {
label: 'VM Image'
}],
options2: [{
value: 'New',
value: 'harvester-amd64.iso',
label: 'harvester-amd64.iso'
}],
volumeData: {
type: 'cdi.kubevirt.io.datavolume',
metadata: {
namespace: 'default',
annotations: {
'field.cattle.io/description': ''
},
labels: {},
name: ''
},
spec: {
pvc: {
resources: {
requests: {
storage: ''
}
},
volumeMode: 'Block',
accessModes: ['ReadWriteMany']
},
source: {
blank: {}
}
}
},
//
rules: {
name: [
@ -144,6 +169,18 @@ export default {
},
removeTag(index) {
this.formData.tag.splice(index, 1)
},
create() {
this.volumeData.metadata.annotations['field.cattle.io/description'] = this.formData.description
for (let item = 0; item < this.formData.tag.length; item++) {
this.volumeData.metadata.labels[this.formData.tag[item].key] = this.formData.tag[item].value
}
this.volumeData.metadata.name = this.formData.name
this.volumeData.spec.pvc.resources.requests.storage = this.formData.size + 'Gi'
console.log(this.volumeData)
createDataVolume(this.volumeData).then(res => {
console.log(res)
})
}
}
}