Skip to content

Commit e0dc616

Browse files
Srivastava, PiyushSrivastava, Piyush
authored andcommitted
testing fix
1 parent 409d28f commit e0dc616

File tree

4 files changed

+41
-22
lines changed

4 files changed

+41
-22
lines changed

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/driver/OntapPrimaryDatastoreDriver.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ public void createAsync(DataStore dataStore, DataObject dataObject, AsyncComplet
103103
s_logger.info("createAsync: Started for data store [{}] and data object [{}] of type [{}]",
104104
dataStore, dataObject, dataObject.getType());
105105
if (dataObject.getType() == DataObjectType.VOLUME) {
106-
path = createCloudStackVolumeForTypeVolume(dataStore, (VolumeInfo)dataObject);
106+
VolumeInfo volumeInfo = (VolumeInfo) dataObject;
107+
path = createCloudStackVolumeForTypeVolume(dataStore, volumeInfo);
107108
createCmdResult = new CreateCmdResult(path, new Answer(null, true, null));
108109
} else {
109110
errMsg = "Invalid DataObjectType (" + dataObject.getType() + ") passed to createAsync";

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/UnifiedNASStrategy.java

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
import com.cloud.storage.dao.VolumeDao;
2727
import com.cloud.utils.exception.CloudRuntimeException;
2828
import feign.FeignException;
29+
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
2930
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
3031
import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
31-
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
3232
import org.apache.cloudstack.storage.command.CreateObjectCommand;
3333
import org.apache.cloudstack.storage.feign.FeignClientFactory;
3434
import org.apache.cloudstack.storage.feign.client.JobFeignClient;
@@ -82,16 +82,21 @@ public void setOntapStorage(OntapStorage ontapStorage) {
8282
@Override
8383
public CloudStackVolume createCloudStackVolume(CloudStackVolume cloudstackVolume) {
8484
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());
8990
if (answer == null || !answer.getResult()) {
9091
String errMsg = answer != null ? answer.getDetails() : "Failed to create qcow2 on KVM host";
9192
s_logger.error("createCloudStackVolumeForTypeVolume: " + errMsg);
9293
throw new CloudRuntimeException(errMsg);
9394
}
9495
return cloudstackVolume;
96+
}catch (Exception e) {
97+
s_logger.error("createCloudStackVolumeForTypeVolume: " + e);
98+
throw new CloudRuntimeException(e);
99+
}
95100
}
96101

97102
@Override
@@ -374,18 +379,31 @@ private ExportPolicy createExportPolicyRequest(AccessGroup accessGroup,String sv
374379
return exportPolicy;
375380
}
376381

377-
private String updateCloudStackVolumeMetadata(String dataStoreId, VolumeInfo volumeInfo) {
382+
private String updateCloudStackVolumeMetadata(String dataStoreId, DataObject volumeInfo) {
378383
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+
}
386404
}
387405

388-
private Answer createVolumeOnKVMHost(VolumeInfo volumeInfo) {
406+
private Answer createVolumeOnKVMHost(DataObject volumeInfo) {
389407
s_logger.info("createVolumeOnKVMHost called with volumeInfo: {} ", volumeInfo);
390408

391409
try {

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/model/CloudStackVolume.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
package org.apache.cloudstack.storage.service.model;
2121

22-
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
22+
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
2323
import org.apache.cloudstack.storage.feign.model.FileInfo;
2424
import org.apache.cloudstack.storage.feign.model.Lun;
2525

@@ -28,7 +28,7 @@ public class CloudStackVolume {
2828
private FileInfo file;
2929
private Lun lun;
3030
private String datastoreId;
31-
private VolumeInfo volumeInfo;
31+
private DataObject volumeInfo;
3232
public FileInfo getFile() {
3333
return file;
3434
}
@@ -50,10 +50,10 @@ public String getDatastoreId() {
5050
public void setDatastoreId(String datastoreId) {
5151
this.datastoreId = datastoreId;
5252
}
53-
public VolumeInfo getVolumeInfo() {
53+
public DataObject getVolumeInfo() {
5454
return volumeInfo;
5555
}
56-
public void setVolumeInfo(VolumeInfo volumeInfot) {
57-
this.volumeInfo = volumeInfot;
56+
public void setVolumeInfo(DataObject volumeInfo) {
57+
this.volumeInfo = volumeInfo;
5858
}
5959
}

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/Utility.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import com.cloud.utils.StringUtils;
2323
import com.cloud.utils.exception.CloudRuntimeException;
24-
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
24+
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
2525
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
2626
import org.apache.cloudstack.storage.feign.model.Lun;
2727
import org.apache.cloudstack.storage.feign.model.LunSpace;
@@ -56,7 +56,7 @@ public static String generateAuthHeader (String username, String password) {
5656
return BASIC + StringUtils.SPACE + new String(encodedBytes);
5757
}
5858

59-
public static CloudStackVolume createCloudStackVolumeRequestByProtocol(StoragePoolVO storagePool, Map<String, String> details, VolumeInfo volumeObject) {
59+
public static CloudStackVolume createCloudStackVolumeRequestByProtocol(StoragePoolVO storagePool, Map<String, String> details, DataObject volumeObject) {
6060
CloudStackVolume cloudStackVolumeRequest = null;
6161

6262
String protocol = details.get(Constants.PROTOCOL);

0 commit comments

Comments
 (0)