DaanHoogland commented on a change in pull request #3606: [WIP DO NOT MERGE] VM ingestion URL: https://github.com/apache/cloudstack/pull/3606#discussion_r342604133
########## File path: engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java ########## @@ -1626,4 +1628,54 @@ public void updateVolumeDiskChain(long volumeId, String path, String chainInfo) _volsDao.update(volumeId, vol); } } + + @Override + public DiskProfile importVolume(Type type, String name, DiskOffering offering, Long size, Long minIops, Long maxIops, + VirtualMachine vm, VirtualMachineTemplate template, Account owner, + Long deviceId, Long poolId, String path, String chainInfo) { + if (size == null) { + size = offering.getDiskSize(); + } else { + size = (size * 1024 * 1024 * 1024); + } + + minIops = minIops != null ? minIops : offering.getMinIops(); + maxIops = maxIops != null ? maxIops : offering.getMaxIops(); + + VolumeVO vol = new VolumeVO(type, name, vm.getDataCenterId(), owner.getDomainId(), owner.getId(), offering.getId(), offering.getProvisioningType(), size, minIops, maxIops, null); + if (vm != null) { + vol.setInstanceId(vm.getId()); + } + + if (deviceId != null) { + vol.setDeviceId(deviceId); + } else if (type.equals(Type.ROOT)) { + vol.setDeviceId(0l); + } else { + vol.setDeviceId(1l); + } + if (template.getFormat() == ImageFormat.ISO) { Review comment: no null check, in normal usage I would expect a user to shrug their shoulders at the thought of a template to come with a volume. I.E. in the future we won't be able to use this import volume without the context of an import VM? (in which case this is dangerous as a public method) ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services