private long getTotalDataDiskSize(VmInstanceSpec spec) { long size = 0; for (DiskOfferingInventory dinv : spec.getDataDiskOfferings()) { size += dinv.getDiskSize(); } return size; }
private ErrorCode checkIfSpecifyPrimaryStorage(VmInstanceSpec spec){ if(spec.getRequiredPrimaryStorageUuidForRootVolume() == null){ ErrorCode errorCode = operr("The cluster[uuid=%s] mounts multiple primary storage[LocalStorage, other non-LocalStorage primary storage], You must specify the primary storage where the root disk is located", spec.getDestHost().getClusterUuid()); return errorCode; } if(spec.getDataDiskOfferings() != null && !spec.getDataDiskOfferings().isEmpty() && spec.getRequiredPrimaryStorageUuidForDataVolume() == null){ ErrorCode errorCode = operr("The cluster[uuid=%s] mounts multiple primary storage[LocalStorage, other non-LocalStorage primary storage], You must specify the primary storage where the data disk is located", spec.getDestHost().getClusterUuid()); return errorCode; } return null; }
private List<AllocatePrimaryStorageMsg> getDataVolumeAllocationMsgs(VmInstanceSpec spec){ List<AllocatePrimaryStorageMsg> msgs = new ArrayList<>(); if (spec.getDataDiskOfferings() == null || spec.getDataDiskOfferings().isEmpty()) { return msgs; List<String> primaryStorageTypes = hostAllocatorMgr.getBackupStoragePrimaryStorageMetrics().get(bsType); for (DiskOfferingInventory dinv : spec.getDataDiskOfferings()) { AllocatePrimaryStorageMsg amsg = new AllocatePrimaryStorageMsg(); amsg.setSize(dinv.getDiskSize());
DebugUtils.Assert(primaryStorageTypes != null, "why primaryStorageTypes is null"); DebugUtils.Assert(spec.getDataDiskOfferings().size() == 0, "create appliance vm can not with data volume");
for (DiskOfferingInventory dinv : spec.getDataDiskOfferings()) { AllocatePrimaryStorageMsg amsg = new AllocatePrimaryStorageMsg(); amsg.setRequiredPrimaryStorageUuid(spec.getRequiredPrimaryStorageUuidForDataVolume());
msgs.add(rmsg); if (!spec.getDataDiskOfferings().isEmpty()) { boolean hasOtherNonLocalStoragePrimaryStorage = isThereOtherNonLocalStoragePrimaryStorageForTheHost( spec.getDestHost().getUuid(), localStorageUuid); for (DiskOfferingInventory dinv : spec.getDataDiskOfferings()) { AllocatePrimaryStorageMsg amsg = new AllocatePrimaryStorageMsg(); amsg.setSize(dinv.getDiskSize());
diskOfferings.addAll(spec.getDataDiskOfferings()); msg.setAvoidHostUuids(getAvoidHost(spec)); msg.setSoftAvoidHostUuids(spec.getSoftAvoidHostUuids());