|
26 | 26 | import com.cloud.storage.dao.VolumeDao; |
27 | 27 | import com.cloud.utils.exception.CloudRuntimeException; |
28 | 28 | import feign.FeignException; |
| 29 | +import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; |
29 | 30 | import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint; |
30 | 31 | import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector; |
31 | | -import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo; |
32 | 32 | import org.apache.cloudstack.storage.command.CreateObjectCommand; |
33 | 33 | import org.apache.cloudstack.storage.feign.FeignClientFactory; |
34 | 34 | import org.apache.cloudstack.storage.feign.client.JobFeignClient; |
@@ -82,16 +82,21 @@ public void setOntapStorage(OntapStorage ontapStorage) { |
82 | 82 | @Override |
83 | 83 | public CloudStackVolume createCloudStackVolume(CloudStackVolume cloudstackVolume) { |
84 | 84 | s_logger.info("createCloudStackVolume: Create cloudstack volume " + cloudstackVolume); |
85 | | - // Step 1: set cloudstack volume metadata |
86 | | - String volumeUuid = updateCloudStackVolumeMetadata(cloudstackVolume.getDatastoreId(), cloudstackVolume.getVolumeInfo()); |
87 | | - // Step 2: Send command to KVM host to create qcow2 file using qemu-img |
88 | | - Answer answer = createVolumeOnKVMHost(cloudstackVolume.getVolumeInfo()); |
| 85 | + try { |
| 86 | + // Step 1: set cloudstack volume metadata |
| 87 | + String volumeUuid = updateCloudStackVolumeMetadata(cloudstackVolume.getDatastoreId(), cloudstackVolume.getVolumeInfo()); |
| 88 | + // Step 2: Send command to KVM host to create qcow2 file using qemu-img |
| 89 | + Answer answer = createVolumeOnKVMHost(cloudstackVolume.getVolumeInfo()); |
89 | 90 | if (answer == null || !answer.getResult()) { |
90 | 91 | String errMsg = answer != null ? answer.getDetails() : "Failed to create qcow2 on KVM host"; |
91 | 92 | s_logger.error("createCloudStackVolumeForTypeVolume: " + errMsg); |
92 | 93 | throw new CloudRuntimeException(errMsg); |
93 | 94 | } |
94 | 95 | return cloudstackVolume; |
| 96 | + }catch (Exception e) { |
| 97 | + s_logger.error("createCloudStackVolumeForTypeVolume: " + e); |
| 98 | + throw new CloudRuntimeException(e); |
| 99 | + } |
95 | 100 | } |
96 | 101 |
|
97 | 102 | @Override |
@@ -374,18 +379,31 @@ private ExportPolicy createExportPolicyRequest(AccessGroup accessGroup,String sv |
374 | 379 | return exportPolicy; |
375 | 380 | } |
376 | 381 |
|
377 | | - private String updateCloudStackVolumeMetadata(String dataStoreId, VolumeInfo volumeInfo) { |
| 382 | + private String updateCloudStackVolumeMetadata(String dataStoreId, DataObject volumeInfo) { |
378 | 383 | s_logger.info("createManagedNfsVolume called with datastoreID: {} volumeInfo: {} ", dataStoreId, volumeInfo ); |
379 | | - VolumeVO volume = volumeDao.findById(volumeInfo.getId()); |
380 | | - String volumeUuid = volumeInfo.getUuid(); |
381 | | - volume.setPoolType(Storage.StoragePoolType.NetworkFilesystem); |
382 | | - volume.setPoolId(Long.parseLong(dataStoreId)); //need to check if volume0 already has this data filled |
383 | | - volume.setPath(volumeUuid); // Filename for qcow2 file |
384 | | - volumeDao.update(volume.getId(), volume); |
385 | | - return volumeUuid; |
| 384 | + s_logger.info("line 379"); |
| 385 | + try { |
| 386 | + |
| 387 | + |
| 388 | + VolumeVO volume = volumeDao.findById(volumeInfo.getTO().getId()); |
| 389 | + s_logger.info("line 381"); |
| 390 | + String volumeUuid = volumeInfo.getUuid(); |
| 391 | + s_logger.info("line 383"); |
| 392 | + volume.setPoolType(Storage.StoragePoolType.NetworkFilesystem); |
| 393 | + s_logger.info("line 385"); |
| 394 | + volume.setPoolId(Long.parseLong(dataStoreId));//need to check if volume0 already has this data filled |
| 395 | + volume.setPath(volumeUuid); // Filename for qcow2 file |
| 396 | + s_logger.info("starting update"); |
| 397 | + volumeDao.update(volume.getId(), volume); |
| 398 | + s_logger.info("update succesfful 385"); |
| 399 | + return volumeUuid; |
| 400 | + }catch (Exception e){ |
| 401 | + s_logger.error("Exception while updating volumeInfo: {} in volume: {}", dataStoreId, volumeInfo.getUuid(), e); |
| 402 | + throw new CloudRuntimeException("Exception while updating volumeInfo: " + e.getMessage()); |
| 403 | + } |
386 | 404 | } |
387 | 405 |
|
388 | | - private Answer createVolumeOnKVMHost(VolumeInfo volumeInfo) { |
| 406 | + private Answer createVolumeOnKVMHost(DataObject volumeInfo) { |
389 | 407 | s_logger.info("createVolumeOnKVMHost called with volumeInfo: {} ", volumeInfo); |
390 | 408 |
|
391 | 409 | try { |
|
0 commit comments