Skip to content

Commit e93e17d

Browse files
committed
hide the primary storage from users in UI
hide the primary storage from the users in the UI refactor smoke test
1 parent f3a4263 commit e93e17d

File tree

5 files changed

+55
-17
lines changed

5 files changed

+55
-17
lines changed

test/integration/plugins/storpool/test_snapshot_copy_on_primary_storage.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def test_01_take_snapshot_multi_zone(self):
157157
"""Test to take volume snapshot in multiple StorPool primary storage pools
158158
"""
159159

160-
snapshot = Snapshot.create(self.userapiclient, volume_id=self.volume.id, usestoragereplication=True)
160+
snapshot = Snapshot.create(self.userapiclient, volume_id=self.volume.id, zoneids=[str(self.additional_zone.id)], usestoragereplication=True)
161161
self.snapshot_id = snapshot.id
162162
self.helper.verify_snapshot_copies(self.userapiclient, self.snapshot_id, [self.zone.id, self.additional_zone.id])
163163
time.sleep(420)
@@ -172,7 +172,7 @@ def test_02_copy_snapshot_multi_pools(self):
172172

173173
snapshot = Snapshot.create(self.userapiclient, volume_id=self.volume.id)
174174
self.snapshot_id = snapshot.id
175-
Snapshot.copy(self.userapiclient, self.snapshot_id, source_zone_id=self.zone.id, usestoragereplication=True)
175+
Snapshot.copy(self.userapiclient, self.snapshot_id, zone_ids=[str(self.additional_zone.id)], source_zone_id=self.zone.id, usestoragereplication=True)
176176
self.helper.verify_snapshot_copies(self.userapiclient, self.snapshot_id, [self.zone.id, self.additional_zone.id])
177177
time.sleep(420)
178178
Snapshot.delete(snapshot, self.userapiclient)
@@ -184,7 +184,7 @@ def test_03_take_snapshot_multi_pools_delete_single_zone(self):
184184
"""Test to take volume snapshot in multiple StorPool storages in diff zones and delete from one zone
185185
"""
186186

187-
snapshot = Snapshot.create(self.userapiclient, volume_id=self.volume.id, usestoragereplication=True)
187+
snapshot = Snapshot.create(self.userapiclient, volume_id=self.volume.id, zoneids=[str(self.additional_zone.id)], usestoragereplication=True)
188188
self.snapshot_id = snapshot.id
189189
self.helper.verify_snapshot_copies(self.userapiclient, self.snapshot_id, [self.zone.id, self.additional_zone.id])
190190
time.sleep(420)
@@ -201,7 +201,7 @@ def test_04_copy_snapshot_multi_zone_delete_all(self):
201201

202202
snapshot = Snapshot.create(self.userapiclient, volume_id=self.volume.id)
203203
self.snapshot_id = snapshot.id
204-
Snapshot.copy(self.userapiclient, self.snapshot_id, source_zone_id=self.zone.id, usestoragereplication=True)
204+
Snapshot.copy(self.userapiclient, self.snapshot_id, zone_ids=[str(self.additional_zone.id)], source_zone_id=self.zone.id, usestoragereplication=True)
205205
self.helper.verify_snapshot_copies(self.userapiclient, self.snapshot_id, [self.zone.id, self.additional_zone.id])
206206
time.sleep(420)
207207
Snapshot.delete(snapshot, self.userapiclient)
@@ -216,7 +216,7 @@ def test_05_take_snapshot_multi_zone_create_volume_additional_zone(self):
216216
"""Test to take volume snapshot on StorPool in multiple zones and create a volume in one of the additional zones
217217
"""
218218

219-
snapshot = Snapshot.create(self.userapiclient,volume_id=self.volume.id, usestoragereplication=True)
219+
snapshot = Snapshot.create(self.userapiclient,volume_id=self.volume.id, zoneids=[str(self.additional_zone.id)], usestoragereplication=True)
220220
self.snapshot_id = snapshot.id
221221
self.helper.verify_snapshot_copies(self.userapiclient, self.snapshot_id, [self.zone.id, self.additional_zone.id])
222222
disk_offering_id = None
@@ -243,7 +243,7 @@ def test_05_take_snapshot_multi_zone_create_volume_additional_zone(self):
243243
def test_06_take_snapshot_multi_zone_create_template_additional_zone(self):
244244
"""Test to take volume snapshot in multiple StorPool primary storages in diff zones and create a volume in one of the additional zones
245245
"""
246-
snapshot = Snapshot.create(self.userapiclient, volume_id=self.volume.id, usestoragereplication=True)
246+
snapshot = Snapshot.create(self.userapiclient, volume_id=self.volume.id, zoneids=[str(self.additional_zone.id)], usestoragereplication=True)
247247
self.snapshot_id = snapshot.id
248248
self.helper.verify_snapshot_copies(self.userapiclient, self.snapshot_id, [self.zone.id, self.additional_zone.id])
249249
self.template = self.helper.create_snapshot_template(self.userapiclient, self.services, self.snapshot_id, self.additional_zone.id)

tools/marvin/marvin/lib/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1415,7 +1415,7 @@ def copy(cls, apiclient, snapshotid, zone_ids=None, source_zone_id=None, pool_id
14151415
if source_zone_id:
14161416
cmd.sourcezoneid = source_zone_id
14171417
if zone_ids:
1418-
cmd.zoneids = zone_ids
1418+
cmd.destzoneids = zone_ids
14191419
if pool_ids:
14201420
cmd.storageids = pool_ids
14211421
if usestoragereplication:

ui/src/views/storage/FormSchedule.vue

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@
139139
</a-form-item>
140140
</a-col>
141141
<a-col :md="24" :lg="24" v-if="resourceType === 'Volume'">
142-
<a-form-item ref="zoneids" name="zoneids">
142+
<a-form-item ref="zoneids" name="zoneids" :required="(!isAdmin && form.useStorageReplication)">
143143
<template #label>
144144
<tooltip-label :title="$t('label.zones')" :tooltip="''"/>
145145
</template>
@@ -170,7 +170,10 @@
170170
</a-form-item>
171171
</a-col>
172172
<a-col :md="24" :lg="24" v-if="resourceType === 'Volume'">
173-
<a-form-item ref="storageids" name="storageids">
173+
<a-form-item :label="$t('label.useStorageReplication')" name="useStorageReplication" ref="useStorageReplication">
174+
<a-switch v-model:checked="form.useStorageReplication" />
175+
</a-form-item>
176+
<a-form-item v-if="isAdmin && form.useStorageReplication" ref="storageids" name="storageids">
174177
<template #label>
175178
<tooltip-label :title="$t('label.storagepools')" :tooltip="''"/>
176179
</template>
@@ -250,6 +253,7 @@
250253
<script>
251254
import { ref, reactive, toRaw } from 'vue'
252255
import { api } from '@/api'
256+
import { isAdmin } from '@/role'
253257
import TooltipButton from '@/components/widgets/TooltipButton'
254258
import TooltipLabel from '@/components/widgets/TooltipLabel'
255259
import { timeZone } from '@/utils/timezone'
@@ -310,6 +314,9 @@ export default {
310314
computed: {
311315
formattedAdditionalZoneMessage () {
312316
return `${this.$t('message.snapshot.additional.zones').replace('%x', this.resource.zonename)}`
317+
},
318+
isAdmin () {
319+
return isAdmin()
313320
}
314321
},
315322
methods: {
@@ -322,7 +329,8 @@ export default {
322329
'day-of-week': undefined,
323330
'day-of-month': undefined,
324331
maxsnaps: undefined,
325-
timezone: undefined
332+
timezone: undefined,
333+
useStorageReplication: false
326334
})
327335
this.rules = reactive({
328336
time: [{ type: 'number', required: true, message: this.$t('message.error.required.input') }],
@@ -461,6 +469,7 @@ export default {
461469
params.intervaltype = values.intervaltype
462470
params.timezone = values.timezone
463471
params.maxsnaps = values.maxsnaps
472+
params.useStorageReplication = values.useStorageReplication
464473
if (values.zoneids && values.zoneids.length > 0) {
465474
params.zoneids = values.zoneids.join()
466475
}

ui/src/views/storage/SnapshotZones.vue

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,10 @@
137137
</a-select-option>
138138
</a-select>
139139
</a-form-item>
140-
<a-form-item ref="storageid" name="storageid" :label="$t('label.storagepools')">
140+
<a-form-item :label="$t('label.useStorageReplication')" name="useStorageReplication" ref="useStorageReplication">
141+
<a-switch v-model:checked="form.useStorageReplication" />
142+
</a-form-item>
143+
<a-form-item v-if="isAdmin && form.useStorageReplication" ref="storageid" name="storageid" :label="$t('label.storagepools')">
141144
<a-select
142145
id="storage-selection"
143146
mode="multiple"
@@ -229,6 +232,7 @@
229232
<script>
230233
import { ref, reactive, toRaw } from 'vue'
231234
import { api } from '@/api'
235+
import { isAdmin } from '@/role'
232236
import OsLogo from '@/components/widgets/OsLogo'
233237
import ResourceIcon from '@/components/view/ResourceIcon'
234238
import TooltipButton from '@/components/widgets/TooltipButton'
@@ -331,12 +335,17 @@ export default {
331335
computed: {
332336
isCopySnapshotSubmitDisabled () {
333337
return this.form.storageid.length === 0 && this.form.zoneid.length === 0
338+
},
339+
isAdmin () {
340+
return isAdmin()
334341
}
335342
},
336343
methods: {
337344
initForm () {
338345
this.formRef = ref()
339-
this.form = reactive({})
346+
this.form = reactive({
347+
useStorageReplication: false
348+
})
340349
this.rules = reactive({
341350
zoneid: [{ type: 'array', required: false }]
342351
})
@@ -543,7 +552,9 @@ export default {
543552
this.form.zoneid = []
544553
this.form.storageid = []
545554
this.fetchZoneData()
546-
this.fetchStoragePoolData()
555+
if (isAdmin) {
556+
this.fetchStoragePoolData()
557+
}
547558
this.showCopyActionForm = true
548559
},
549560
onShowDeleteModal (record) {
@@ -572,6 +583,7 @@ export default {
572583
const params = {
573584
id: this.currentRecord.id,
574585
sourcezoneid: this.currentRecord.zoneid,
586+
useStorageReplication: values.useStorageReplication,
575587
destzoneids: values.zoneid.join(),
576588
storageids: values.storageid.join()
577589
}

ui/src/views/storage/TakeSnapshot.vue

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
:placeholder="apiParams.name.description"
3838
v-focus="true" />
3939
</a-form-item>
40-
<a-form-item ref="zoneids" name="zoneids">
40+
<a-form-item ref="zoneids" name="zoneids" :required="(!isAdmin && form.useStorageReplication)">
4141
<template #label>
4242
<tooltip-label :title="$t('label.zones')" :tooltip="''"/>
4343
</template>
@@ -66,7 +66,10 @@
6666
</a-select-option>
6767
</a-select>
6868
</a-form-item>
69-
<a-form-item ref="storageids" name="storageids">
69+
<a-form-item :label="$t('label.useStorageReplication')" name="useStorageReplication" ref="useStorageReplication">
70+
<a-switch v-model:checked="form.useStorageReplication" />
71+
</a-form-item>
72+
<a-form-item v-if="isAdmin && form.useStorageReplication" ref="storageids" name="storageids">
7073
<template #label>
7174
<tooltip-label :title="$t('label.storagepools')" :tooltip="''"/>
7275
</template>
@@ -149,6 +152,7 @@
149152
<script>
150153
import { ref, reactive, toRaw } from 'vue'
151154
import { api } from '@/api'
155+
import { isAdmin } from '@/role'
152156
import { mixinForm } from '@/utils/mixin'
153157
import TooltipButton from '@/components/widgets/TooltipButton'
154158
import TooltipLabel from '@/components/widgets/TooltipLabel'
@@ -195,24 +199,33 @@ export default {
195199
this.initForm()
196200
this.quiescevm = this.resource.quiescevm
197201
this.supportsStorageSnapshot = this.resource.supportsstoragesnapshot
198-
this.fetchZoneData()
199-
this.fetchStoragePoolData()
202+
this.fetchData()
200203
},
201204
computed: {
202205
formattedAdditionalZoneMessage () {
203206
return `${this.$t('message.snapshot.additional.zones').replace('%x', this.resource.zonename)}`
207+
},
208+
isAdmin () {
209+
return isAdmin()
204210
}
205211
},
206212
methods: {
207213
initForm () {
208214
this.formRef = ref()
209215
this.form = reactive({
210216
name: undefined,
217+
useStorageReplication: false,
211218
asyncbackup: undefined,
212219
quiescevm: false
213220
})
214221
this.rules = reactive({})
215222
},
223+
fetchData () {
224+
this.fetchZoneData()
225+
if (isAdmin()) {
226+
this.fetchStoragePoolData()
227+
}
228+
},
216229
fetchZoneData () {
217230
const params = {}
218231
params.showicon = true
@@ -253,6 +266,10 @@ export default {
253266
if (values.name) {
254267
params.name = values.name
255268
}
269+
params.useStorageReplication = false
270+
if (values.useStorageReplication) {
271+
params.useStorageReplication = values.useStorageReplication
272+
}
256273
params.asyncBackup = false
257274
if (values.asyncbackup) {
258275
params.asyncBackup = values.asyncbackup

0 commit comments

Comments
 (0)