@@ -9873,7 +9873,7 @@ public Optional<UserVm> cloneVirtualMachine(CloneVMCmd cmd) throws ResourceAlloc
98739873 if (rootVolume == null) {
98749874 throw new CloudRuntimeException("Creation of root volume is not queried. The virtual machine cannot be cloned!");
98759875 }
9876- UserVm cloneVM = createCloneVM(cmd, String.valueOf( rootVolume.getId() ));
9876+ UserVm cloneVM = createCloneVM(cmd, rootVolume.getId());
98779877 if (cloneVM == null) {
98789878 throw new CloudRuntimeException("Unable to record the VM to DB!");
98799879 }
@@ -9965,7 +9965,7 @@ public Optional<UserVm> cloneVirtualMachine(CloneVMCmd cmd) throws ResourceAlloc
99659965 return null;
99669966 }
99679967
9968- public UserVm createCloneVM(CloneVMCmd cmd, String rootVolumeId) throws ConcurrentOperationException, ResourceAllocationException, InsufficientCapacityException, ResourceUnavailableException {
9968+ public UserVm createCloneVM(CloneVMCmd cmd, Long rootVolumeId) throws ConcurrentOperationException, ResourceAllocationException, InsufficientCapacityException, ResourceUnavailableException {
99699969 //network configurations and check, then create the template
99709970 UserVm curVm = cmd.getTargetVM();
99719971 // check if host is available
@@ -9975,8 +9975,12 @@ public UserVm createCloneVM(CloneVMCmd cmd, String rootVolumeId) throws Concurre
99759975 DataCenter dataCenter = _entityMgr.findById(DataCenter.class, zoneId);
99769976 Map<String, String> customParameters = userVmDetailsDao.listDetailsKeyPairs(curVm.getId());
99779977 String keyboard = customParameters.get(VmDetailConstants.KEYBOARD);
9978- if (!rootVolumeId.isBlank()) {
9979- customParameters.put("volumeId", rootVolumeId);
9978+ Long size = null; // mutual exclusive with disk offering id
9979+ if (rootVolumeId != null) {
9980+ customParameters.put("volumeId", String.valueOf(rootVolumeId));
9981+ VolumeVO vol = _volsDao.findById(rootVolumeId);
9982+ size = vol.getSize();
9983+ customParameters.put(VmDetailConstants.ROOT_DISK_SIZE, String.valueOf(size / GiB_TO_BYTES));
99809984 }
99819985 HypervisorType hypervisorType = curVm.getHypervisorType();
99829986 Account curAccount = _accountDao.findById(curVm.getAccountId());
@@ -9989,9 +9993,6 @@ public UserVm createCloneVM(CloneVMCmd cmd, String rootVolumeId) throws Concurre
99899993 List<Long> securityGroupIdList = securityGroupList.stream().map(SecurityGroupVO::getId).collect(Collectors.toList());
99909994 String name = cmd.getName();
99919995 String displayName = cmd.getName();
9992- // VolumeVO curVolume = _volsDao.findByInstance(curVm.getId()).get(0);
9993- // Long diskOfferingId = curVolume.getDiskOfferingId();
9994- Long size = null; // mutual exclusive with disk offering id
99959996 String userData = curVm.getUserData();
99969997 // String sshKeyPair = null;
99979998 Map<Long, IpAddresses> ipToNetoworkMap = null; // Since we've specified Ip
0 commit comments