diff --git a/releasenotes/notes/Show-Data-Disk-Of-Snapshot-3b23e998665187c1.yaml b/releasenotes/notes/Show-Data-Disk-Of-Snapshot-3b23e998665187c1.yaml new file mode 100644 index 00000000..85b6c0b3 --- /dev/null +++ b/releasenotes/notes/Show-Data-Disk-Of-Snapshot-3b23e998665187c1.yaml @@ -0,0 +1,8 @@ +--- +fixes: + - | + `Bug #1992739 `_: + + When the instance snapshot is used to create instance, if the instance + snapshot is associated with data disks, it is supported to show necessary + data disk information and make quota measurable. diff --git a/src/pages/compute/containers/Instance/actions/StepCreate/index.jsx b/src/pages/compute/containers/Instance/actions/StepCreate/index.jsx index 18ae1fd9..c3160b3f 100644 --- a/src/pages/compute/containers/Instance/actions/StepCreate/index.jsx +++ b/src/pages/compute/containers/Instance/actions/StepCreate/index.jsx @@ -22,6 +22,7 @@ import globalProjectStore from 'stores/keystone/project'; import classnames from 'classnames'; import { isEmpty, isFinite, isString } from 'lodash'; import { getUserData } from 'resources/nova/instance'; +import { getAllDataDisks } from 'resources/cinder/snapshot'; import { getGiBValue } from 'utils/index'; import Notify from 'components/Notify'; import ConfirmStep from './ConfirmStep'; @@ -299,12 +300,14 @@ export class StepCreate extends StepAction { count = 1, source: { value: sourceValue } = {}, instanceSnapshotDisk = {}, + instanceSnapshotDataVolumes = [], } = data; const newCountMap = {}; const newSizeMap = {}; let totalNewCount = 0; let totalNewSize = 0; - if (sourceValue === 'instanceSnapshot' && instanceSnapshotDisk) { + const isSnapshotType = sourceValue === 'instanceSnapshot'; + if (isSnapshotType && instanceSnapshotDisk) { const { size, typeOption: { label } = {} } = instanceSnapshotDisk; if (label) { newCountMap[label] = !newCountMap[label] ? 1 : newCountMap[label] + 1; @@ -322,11 +325,19 @@ export class StepCreate extends StepAction { totalNewCount += 1 * count; totalNewSize += size * count; } - if (dataDisk) { - dataDisk.forEach((item) => { - if (item.value && item.value.type) { - const { size } = item.value; - const { label } = item.value.typeOption || {}; + if ( + dataDisk || + (isSnapshotType && instanceSnapshotDataVolumes?.length > 0) + ) { + const allDataDisks = getAllDataDisks({ + dataDisk, + instanceSnapshotDataVolumes, + }); + allDataDisks.forEach((item) => { + const diskItem = item.value || {}; + if (diskItem.type) { + const { size, typeOption } = diskItem; + const { label } = typeOption || {}; newCountMap[label] = !newCountMap[label] ? 1 * count : newCountMap[label] + 1 * count;