Skip to content

Commit aea12e5

Browse files
authored
Merge pull request #7629 from GuoLiBin6/automated-cherry-pick-of-#7628-upstream-release-3.9
Automated cherry pick of #7628: feat: 磁盘支持设置关机自动重置
2 parents d08f047 + e9ad62f commit aea12e5

File tree

13 files changed

+178
-14
lines changed

13 files changed

+178
-14
lines changed

containers/Compute/locales/en.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1660,5 +1660,7 @@
16601660
"compute.tooltip.check_fake_baremetal_server": "This operation is not supported on the machine",
16611661
"compute.transfer.bandwidth.number.check": "Only positive integers can be entered",
16621662
"compute.bios": "Boot Mode",
1663-
"compute.lvm_shared_storage.validate_tooltip": "LVM disk host does not support this operation"
1663+
"compute.lvm_shared_storage.validate_tooltip": "LVM disk host does not support this operation",
1664+
"compute.shutdown_auto_reset": "Shutdown and automatic reset",
1665+
"compute.disk_set_auto_reset": "Set automatic reset"
16641666
}

containers/Compute/locales/zh-CN.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1661,5 +1661,7 @@
16611661
"compute.tooltip.check_fake_baremetal_server": "托管的机器不支持该操作",
16621662
"compute.transfer.bandwidth.number.check": "只能输入正整数",
16631663
"compute.bios": "引导模式",
1664-
"compute.lvm_shared_storage.validate_tooltip": "LVM磁盘主机不支持该操作"
1664+
"compute.lvm_shared_storage.validate_tooltip": "LVM磁盘主机不支持该操作",
1665+
"compute.shutdown_auto_reset": "关机自动重置",
1666+
"compute.disk_set_auto_reset": "设置自动重置"
16651667
}

containers/Compute/sections/DataDisk/index.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
:storageParams="storageParams"
2222
:storageHostParams="storageHostParams"
2323
:isStorageShow="isStorageShow"
24+
:isAutoResetShow="isAutoResetShow"
2425
@snapshotChange="val => snapshotChange(item, val, i)"
2526
@diskTypeChange="val => diskTypeChange(item, val)"
2627
@storageHostChange="(val) => $emit('storageHostChange', val)" />
@@ -122,6 +123,10 @@ export default {
122123
type: Object,
123124
},
124125
storageHostParams: Object,
126+
isAutoResetShow: {
127+
type: Boolean,
128+
default: false,
129+
},
125130
},
126131
data () {
127132
return {

containers/Compute/sections/Disk/index.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@
4545
<storage style="min-width: 480px; max-width: 500px;" :diskKey="diskKey" :decorators="decorator" :storageParams="storageParams" v-if="showStorage" :form="form" :storageHostParams="storageHostParams" @storageHostChange="(val) => $emit('storageHostChange', val)" />
4646
<a-button v-if="!disabled" class="mt-1" type="link" @click="storageShowClick">{{ showStorage ? $t('compute.text_135') : $t('compute.text_1350') }}</a-button>
4747
</template>
48+
<!-- 关机重置 -->
49+
<a-form-item v-if="isAutoResetShow">
50+
<a-checkbox v-decorator="decorator.auto_reset">{{ $t('compute.shutdown_auto_reset') }}</a-checkbox>
51+
</a-form-item>
4852
<!-- 磁盘容量预警信息提示 -->
4953
<a-tooltip v-if="storageStatusMap.tooltip">
5054
<template slot="title">
@@ -144,6 +148,10 @@ export default {
144148
type: Boolean,
145149
default: false,
146150
},
151+
isAutoResetShow: {
152+
type: Boolean,
153+
default: false,
154+
},
147155
},
148156
data () {
149157
return {

containers/Compute/utils/createServer.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,13 @@ export const createVmDecorators = type => {
288288
}],
289289
},
290290
],
291+
auto_reset: [
292+
'systemDiskAutoReset',
293+
{
294+
valuePropName: 'checked',
295+
initialValue: false,
296+
},
297+
],
291298
},
292299
dataDisk: {
293300
type: i => [
@@ -368,6 +375,13 @@ export const createVmDecorators = type => {
368375
}],
369376
},
370377
],
378+
auto_reset: i => [
379+
`dataDiskAutoReset[${i}]`,
380+
{
381+
valuePropName: 'checked',
382+
initialValue: false,
383+
},
384+
],
371385
},
372386
network: {
373387
networkType: [
@@ -774,6 +788,9 @@ export class GenCreateData {
774788
if (diskSupportTypeMedium(this.fd.hypervisor)) {
775789
ret.backend = getOriginDiskKey(ret.backend)
776790
}
791+
if (item.auto_reset) {
792+
ret.auto_reset = true
793+
}
777794
return ret
778795
}
779796

@@ -818,6 +835,9 @@ export class GenCreateData {
818835
if (this.fd.systemDiskStorage) {
819836
systemDisk.storage_id = this.fd.systemDiskStorage
820837
}
838+
if (this.fd.systemDiskAutoReset) {
839+
systemDisk.auto_reset = this.fd.systemDiskAutoReset
840+
}
821841
// #7356 新建vmware主机,数据盘没有传磁盘类型字段
822842
if (this.fd.hypervisor === HYPERVISORS_MAP.esxi.key) {
823843
dataDiskType = dataDiskType || sysDiskType
@@ -852,6 +872,9 @@ export class GenCreateData {
852872
if (this.fi.dataDiskMedium) {
853873
diskObj.medium = this.fi.dataDiskMedium
854874
}
875+
if (this.fd.dataDiskAutoReset && this.fd.dataDiskAutoReset[key]) {
876+
diskObj.auto_reset = this.fd.dataDiskAutoReset[key]
877+
}
855878
dataDisk.push(diskObj)
856879
}, this.fd.dataDiskSizes)
857880
const disks = { data: dataDisk, system: systemDisk }
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<template>
2+
<base-dialog @cancel="cancelDialog">
3+
<div slot="header">{{$t('compute.disk_set_auto_reset')}}</div>
4+
<div slot="body">
5+
<dialog-selected-tips :count="params.data.length" :name="$t('dictionary.disk')" :action="$t('compute.disk_set_auto_reset')" />
6+
<dialog-table v-if="params.columns && params.columns.length" :data="params.data" :columns="params.columns.slice(0, 3)" />
7+
<a-form
8+
:form="form.fc">
9+
<a-form-item :label="$t('compute.shutdown_auto_reset')" v-bind="formItemLayout">
10+
<a-checkbox v-decorator="decorators.auto_reset" />
11+
</a-form-item>
12+
</a-form>
13+
</div>
14+
<div slot="footer">
15+
<a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t('dialog.ok') }}</a-button>
16+
<a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
17+
</div>
18+
</base-dialog>
19+
</template>
20+
21+
<script>
22+
import DialogMixin from '@/mixins/dialog'
23+
import WindowsMixin from '@/mixins/windows'
24+
25+
export default {
26+
name: 'DiskSetAutoResetDialog',
27+
mixins: [DialogMixin, WindowsMixin],
28+
data () {
29+
return {
30+
loading: false,
31+
scope: this.$store.getters.scope,
32+
form: {
33+
fc: this.$form.createForm(this),
34+
},
35+
decorators: {
36+
auto_reset: [
37+
'auto_reset',
38+
{
39+
valuePropName: 'checked',
40+
initialValue: this.params.data[0].auto_reset || false,
41+
},
42+
],
43+
},
44+
formItemLayout: {
45+
labelCol: {
46+
sm: { span: 3 },
47+
},
48+
wrapperCol: {
49+
sm: { span: 21 },
50+
},
51+
},
52+
}
53+
},
54+
computed: {
55+
domain () {
56+
return this.params.data[0].domain_id
57+
},
58+
tenant () {
59+
return this.params.data[0].tenant_id
60+
},
61+
},
62+
created () {
63+
},
64+
methods: {
65+
async handleConfirm () {
66+
this.loading = true
67+
try {
68+
const values = await this.form.fc.validateFields()
69+
this.loading = true
70+
await this.params.onManager('update', {
71+
id: this.params.data[0].id,
72+
managerArgs: {
73+
data: {
74+
auto_reset: values.auto_reset,
75+
},
76+
},
77+
})
78+
this.loading = false
79+
this.params.refresh()
80+
this.cancelDialog()
81+
} catch (error) {
82+
this.loading = false
83+
throw error
84+
}
85+
},
86+
},
87+
}
88+
</script>

containers/Compute/views/disk/mixins/columns.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,13 @@ export default {
127127
},
128128
hidden: this.hiddenColumns.includes('medium_type'),
129129
},
130+
{
131+
field: 'auto_reset',
132+
title: this.$t('compute.shutdown_auto_reset'),
133+
formatter: ({ row }) => {
134+
return row.auto_reset ? this.$t('common.true') : this.$t('common.false')
135+
},
136+
},
130137
]
131138
},
132139
}

containers/Compute/views/disk/mixins/singleActions.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,25 @@ export default {
346346
},
347347
hidden: () => this.$isScopedPolicyMenuHidden('disk_hidden_menus.disk_perform_setup_snapshot_policy'),
348348
},
349+
{
350+
label: i18n.t('compute.disk_set_auto_reset'),
351+
permission: 'disks_update',
352+
action: () => {
353+
this.createDialog('DiskSetAutoResetDialog', {
354+
vm: this,
355+
data: [obj],
356+
onManager: this.onManager,
357+
columns: this.columns,
358+
refresh: this.refresh,
359+
})
360+
},
361+
meta: () => {
362+
return {
363+
validate: true,
364+
}
365+
},
366+
hidden: () => this.$isScopedPolicyMenuHidden('disk_hidden_menus.disk_perform_auto_reset'),
367+
},
349368
{
350369
label: i18n.t('compute.driver.update'),
351370
permission: 'disks_update',

containers/Compute/views/disk/sidepage/Detail.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,13 @@ export default {
138138
return '-'
139139
},
140140
},
141+
{
142+
field: 'auto_reset',
143+
title: this.$t('compute.shutdown_auto_reset'),
144+
formatter: ({ row }) => {
145+
return row.auto_reset ? this.$t('common.true') : this.$t('common.false')
146+
},
147+
},
141148
],
142149
extraInfo: [
143150
{

containers/Compute/views/vminstance/create/components/SystemDisk.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
:size-disabled="sizeDisabled || disabled"
1717
:storage-status-map="storageStatusMap"
1818
:isStorageShow="isStorageShow"
19+
:isAutoResetShow="isAutoResetShow"
1920
@showStorageChange="showStorageChange"
2021
@diskTypeChange="setDiskMedium"
2122
@storageHostChange="(val) => $emit('storageHostChange', val)" />
@@ -106,6 +107,10 @@ export default {
106107
type: Boolean,
107108
default: false,
108109
},
110+
isAutoResetShow: {
111+
type: Boolean,
112+
default: false,
113+
},
109114
},
110115
computed: {
111116
isPublic () {

0 commit comments

Comments
 (0)